RE: [PATCH] mmc: core: Delete an error message for a failed memory allocation in three functions

From: Winkler, Tomas
Date: Sat May 13 2017 - 13:24:45 EST




> -----Original Message-----
> From: SF Markus Elfring [mailto:elfring@xxxxxxxxxxxxxxxxxxxxx]
> Sent: Saturday, May 13, 2017 15:54
> To: linux-mmc@xxxxxxxxxxxxxxx; Bojan Prtvar <prtvar.b@xxxxxxxxx>; Linus
> Walleij <linus.walleij@xxxxxxxxxx>; Paul Burton <paul.burton@xxxxxxxxxx>;
> Shawn Lin <shawn.lin@xxxxxxxxxxxxxx>; Ulf Hansson
> <ulf.hansson@xxxxxxxxxx>; Uri Yanai <uri.yanai@xxxxxxxxxxx>; Winkler,
> Tomas <tomas.winkler@xxxxxxxxx>
> Cc: LKML <linux-kernel@xxxxxxxxxxxxxxx>; kernel-janitors@xxxxxxxxxxxxxxx
> Subject: [PATCH] mmc: core: Delete an error message for a failed memory
> allocation in three functions
>
> From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> Date: Sat, 13 May 2017 14:40:08 +0200
>
> Omit an extra message for a memory allocation failure in these functions.
>
> This issue was detected by using the Coccinelle software.
>
> Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-
> Refactor_Strings-WSang_0.pdf
> Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>

Looks, OK to me.
Tomas

> ---
> drivers/mmc/core/sd.c | 16 +++-------------
> 1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index
> d109634fbfce..1d7542daecbe 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -294,12 +294,8 @@ static int mmc_read_switch(struct mmc_card *card)
> err = -EIO;
>
> status = kmalloc(64, GFP_KERNEL);
> - if (!status) {
> - pr_err("%s: could not allocate a buffer for "
> - "switch capabilities.\n",
> - mmc_hostname(card->host));
> + if (!status)
> return -ENOMEM;
> - }
>
> /*
> * Find out the card's support bits with a mode 0 operation.
> @@ -359,11 +355,8 @@ int mmc_sd_switch_hs(struct mmc_card *card)
> return 0;
>
> status = kmalloc(64, GFP_KERNEL);
> - if (!status) {
> - pr_err("%s: could not allocate a buffer for "
> - "switch capabilities.\n", mmc_hostname(card-
> >host));
> + if (!status)
> return -ENOMEM;
> - }
>
> err = mmc_sd_switch(card, 1, 0, 1, status);
> if (err)
> @@ -596,11 +589,8 @@ static int mmc_sd_init_uhs_card(struct mmc_card
> *card)
> return 0;
>
> status = kmalloc(64, GFP_KERNEL);
> - if (!status) {
> - pr_err("%s: could not allocate a buffer for "
> - "switch capabilities.\n", mmc_hostname(card-
> >host));
> + if (!status)
> return -ENOMEM;
> - }
>
> /* Set 4-bit bus width */
> if ((card->host->caps & MMC_CAP_4_BIT_DATA) &&
> --
> 2.12.3