Linux kernel staging patches
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Nihar Chaithanya <niharchaithanya@gmail.com>
Cc: dpenkler@gmail.com, dan.carpenter@linaro.org,
	roheetchavan@gmail.com, arnd@arndb.de,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	skhan@linuxfoundation.org
Subject: Re: [PATCH] staging: gpib: cb7210: Add error handling
Date: Sat, 21 Dec 2024 08:51:28 +0100	[thread overview]
Message-ID: <2024122158-bunch-critter-0696@gregkh> (raw)
In-Reply-To: <20241221022632.20931-1-niharchaithanya@gmail.com>

On Sat, Dec 21, 2024 at 07:56:33AM +0530, Nihar Chaithanya wrote:
> The if condition in cb7210_init_module() would always fail as
> the value of err is constantly 0.
> Add error handling to cb_pcmcia_init_module() where it returns
> appropriate error code if pcmcia_register_driver() fails.
> 
> This issue was reported by Coverity Scan.
> Report:
> 
> CID 1635894: (#1 of 1): 'Constant' variable guards dead code (DEADCODE)
> dead_error_line: Execution cannot reach this statement: return -1;.
> 
> Signed-off-by: Nihar Chaithanya <niharchaithanya@gmail.com>
> ---
>  drivers/staging/gpib/cb7210/cb7210.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/gpib/cb7210/cb7210.c b/drivers/staging/gpib/cb7210/cb7210.c
> index 63df7f3eb3f3..b2f6ad70ccaf 100644
> --- a/drivers/staging/gpib/cb7210/cb7210.c
> +++ b/drivers/staging/gpib/cb7210/cb7210.c
> @@ -1353,7 +1353,11 @@ static struct pcmcia_driver cb_gpib_cs_driver = {
>  
>  int cb_pcmcia_init_module(void)
>  {
> -	pcmcia_register_driver(&cb_gpib_cs_driver);
> +	int ret;
> +
> +	ret = pcmcia_register_driver(&cb_gpib_cs_driver);
> +	if (ret < 0)
> +		return ret;
>  	return 0;

Why not make this whole function just one line?  And then, as it's one
line, why is it a function at all?

thanks,

greg k-h

  reply	other threads:[~2024-12-21  7:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-21  2:26 [PATCH] staging: gpib: cb7210: Add error handling Nihar Chaithanya
2024-12-21  7:51 ` Greg KH [this message]
2024-12-21  8:36   ` Nihar Chaithanya

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=2024122158-bunch-critter-0696@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=arnd@arndb.de \
    --cc=dan.carpenter@linaro.org \
    --cc=dpenkler@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=niharchaithanya@gmail.com \
    --cc=roheetchavan@gmail.com \
    --cc=skhan@linuxfoundation.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox