public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Phillip Potter <phil@philpotter.co.uk>,
	Larry.Finger@lwfinger.net, paskripkin@gmail.com,
	straube.linux@gmail.com, martin@kaiser.cx,
	abdun.nihaal@gmail.com, philipp.g.hortmann@gmail.com,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] staging: r8188eu: convert rtw_pwr_wakeup to correct error code semantics
Date: Wed, 27 Jul 2022 15:43:42 +0300	[thread overview]
Message-ID: <20220727124342.GR2316@kadam> (raw)
In-Reply-To: <YuDcKoSibAo93a6P@kroah.com>

On Wed, Jul 27, 2022 at 08:33:14AM +0200, Greg KH wrote:
> > diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c
> > index cf9020a73933..8b1c50668dfe 100644
> > --- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c
> > +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c
> > @@ -381,24 +381,24 @@ int rtw_pwr_wakeup(struct adapter *padapter)
> >  	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
> >  	unsigned long timeout = jiffies + msecs_to_jiffies(3000);
> >  	unsigned long deny_time;
> > -	int ret = _SUCCESS;
> > +	int ret = 0;
> >  
> >  	while (pwrpriv->ps_processing && time_before(jiffies, timeout))
> >  		msleep(10);
> >  
> >  	/* I think this should be check in IPS, LPS, autosuspend functions... */
> >  	if (check_fwstate(pmlmepriv, _FW_LINKED)) {
> > -		ret = _SUCCESS;
> > +		ret = 0;
> 
> Nit, you don't need to set this again, as you already set it above to 0.
> 

I would sort of prefer to drop the initialization and keep this one.

Otherwise it causes a Smatch warning about missing error codes.  It
*looks* buggy too, like it should be an error path.  Sometimes people
add a comment explaining why those are success paths and not error paths
which also works.

The Smatch check will no warn if there is a "ret = 0;" within 4(?) lines
of the goto because that's probably intentional.

regards,
dan carpenter


  reply	other threads:[~2022-07-27 12:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-25 22:07 [PATCH v2] staging: r8188eu: convert rtw_pwr_wakeup to correct error code semantics Phillip Potter
2022-07-26  5:09 ` Philipp Hortmann
2022-07-26 13:35 ` Dan Carpenter
2022-07-26 15:46   ` Dan Carpenter
2022-07-26 22:14     ` Phillip Potter
2022-07-27  6:33 ` Greg KH
2022-07-27 12:43   ` Dan Carpenter [this message]
2022-07-27 12:47     ` Greg KH

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=20220727124342.GR2316@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=abdun.nihaal@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=martin@kaiser.cx \
    --cc=paskripkin@gmail.com \
    --cc=phil@philpotter.co.uk \
    --cc=philipp.g.hortmann@gmail.com \
    --cc=straube.linux@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox