All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Tang Bin <tangbin@cmss.chinamobile.com>
Cc: k.opasiak@samsung.com, davem@davemloft.net,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Subject: Re: [PATCH] nfc: s3fwrn5: fix undefined parameter values in dev_err()
Date: Tue, 27 Jul 2021 10:34:52 -0700	[thread overview]
Message-ID: <YQBDvOG51Tl0ts+g@Ryzen-9-3900X.localdomain> (raw)
In-Reply-To: <20210727122506.6900-1-tangbin@cmss.chinamobile.com>

On Tue, Jul 27, 2021 at 08:25:06PM +0800, Tang Bin wrote:
> In the function s3fwrn5_fw_download(), the 'ret' is not assigned,
> so the correct value should be given in dev_err function.
> 
> Fixes: a0302ff5906a ("nfc: s3fwrn5: remove unnecessary label")
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>

This clears up a clang warning that I see:

drivers/nfc/s3fwrn5/firmware.c:425:41: error: variable 'ret' is uninitialized when used here [-Werror,-Wuninitialized]
                        "Cannot allocate shash (code=%d)\n", ret);
                                                             ^~~
./include/linux/dev_printk.h:144:65: note: expanded from macro 'dev_err'
        dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
                                                                       ^~~~~~~~~~~
./include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
                _p_func(dev, fmt, ##__VA_ARGS__);                       \
                                    ^~~~~~~~~~~
drivers/nfc/s3fwrn5/firmware.c:416:9: note: initialize the variable 'ret' to silence this warning
        int ret;
               ^
                = 0
1 error generated.

One comment below but regardless:

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  drivers/nfc/s3fwrn5/firmware.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/nfc/s3fwrn5/firmware.c b/drivers/nfc/s3fwrn5/firmware.c
> index 1421ffd46d9a..52c6f76adfb2 100644
> --- a/drivers/nfc/s3fwrn5/firmware.c
> +++ b/drivers/nfc/s3fwrn5/firmware.c
> @@ -422,7 +422,7 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info)
>  	tfm = crypto_alloc_shash("sha1", 0, 0);
>  	if (IS_ERR(tfm)) {
>  		dev_err(&fw_info->ndev->nfc_dev->dev,
> -			"Cannot allocate shash (code=%d)\n", ret);
> +			"Cannot allocate shash (code=%d)\n", PTR_ERR(tfm));

We know this is going to be an error pointer so this could be changed to

"Cannot allocate shash (code=%pe)\n", tfm);

to make it a little cleaner to understand. See commit 57f5677e535b
("printf: add support for printing symbolic error names").

>  		return PTR_ERR(tfm);
>  	}
>  
> -- 
> 2.18.2

Cheers,
Nathan

  parent reply	other threads:[~2021-07-27 17:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-27 12:25 [PATCH] nfc: s3fwrn5: fix undefined parameter values in dev_err() Tang Bin
2021-07-27 16:59 ` kernel test robot
2021-07-27 16:59 ` kernel test robot
2021-07-27 17:34 ` Nathan Chancellor [this message]
2021-07-28  1:32   ` tangbin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YQBDvOG51Tl0ts+g@Ryzen-9-3900X.localdomain \
    --to=nathan@kernel.org \
    --cc=davem@davemloft.net \
    --cc=k.opasiak@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tangbin@cmss.chinamobile.com \
    --cc=zhangshengju@cmss.chinamobile.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.