Re: [PATCH v2] staging: r8188eu: convert rtw_pwr_wakeup to correct error code semantics

Dan Carpenter
2022-07-27T12:44:19Z

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