From: Gilbert Adikankwu <gilbertadikankwu@gmail.com>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: outreachy@lists.linux.dev, manishc@marvell.com,
GR-Linux-NIC-Dev@marvell.com, coiby.xu@gmail.com,
gregkh@linuxfoundation.org, netdev@vger.kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: qlge: Add bool type to qlge_idc_wait()
Date: Sat, 14 Oct 2023 08:39:34 +0100 [thread overview]
Message-ID: <ZSpFtrC5xuYzgZhw@gilbert-PC> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2310140819450.3383@hadrien>
On Sat, Oct 14, 2023 at 08:23:13AM +0200, Julia Lawall wrote:
>
>
> On Sat, 14 Oct 2023, Gilbert Adikankwu wrote:
>
> > Reported by checkpatch:
> >
> > WARNING: else is not generally useful after a break or return
> >
> > The idea of the break statements in the if/else is so that the loop is
> > exited immediately the value of status is changed. And returned
> > immediately. For if/else conditionals, the block to be executed will
> > always be one of the two. Introduce a bool type variable 's_sig' that
> > evaluates to true when the value of status is changed within the if/else
> > block.
>
> The idea of the checkpatch warning is that eg
>
> found = search();
> if (!found)
> break;
> else do_something();
>
> is equvalent to:
>
> found = search();
> if (!found)
> break;
> do_something();
>
> Because now the normal computation is at top level and the if branches are
> only used for error handling.
>
> But that is not the case in your code. In your code, it seems that there
> are two cases where one would like to break out of the loop. The code
> would be better left as it is.
>
> julia
Thank you for the quick review. I thought about it the you described but
then realised the else was not redundant that was why I went the route
of trying to suppress the warning. I will revert the changes as you
have suggested
Gilbert
>
> >
> > Signed-off-by: Gilbert Adikankwu <gilbertadikankwu@gmail.com>
> > ---
> > drivers/staging/qlge/qlge.h | 1 +
> > drivers/staging/qlge/qlge_mpi.c | 8 ++++++--
> > 2 files changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h
> > index d0dd659834ee..b846bca82571 100644
> > --- a/drivers/staging/qlge/qlge.h
> > +++ b/drivers/staging/qlge/qlge.h
> > @@ -11,6 +11,7 @@
> > #include <linux/netdevice.h>
> > #include <linux/rtnetlink.h>
> > #include <linux/if_vlan.h>
> > +#include <linux/types.h>
> >
> > /*
> > * General definitions...
> > diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c
> > index 96a4de6d2b34..44cb879240a0 100644
> > --- a/drivers/staging/qlge/qlge_mpi.c
> > +++ b/drivers/staging/qlge/qlge_mpi.c
> > @@ -909,6 +909,7 @@ int qlge_mb_wol_set_magic(struct qlge_adapter *qdev, u32 enable_wol)
> > static int qlge_idc_wait(struct qlge_adapter *qdev)
> > {
> > int status = -ETIMEDOUT;
> > + bool s_sig = false;
> > struct mbox_params *mbcp = &qdev->idc_mbc;
> > long wait_time;
> >
> > @@ -934,14 +935,17 @@ static int qlge_idc_wait(struct qlge_adapter *qdev)
> > } else if (mbcp->mbox_out[0] == AEN_IDC_CMPLT) {
> > netif_err(qdev, drv, qdev->ndev, "IDC Success.\n");
> > status = 0;
> > - break;
> > + s_sig = true;
> > } else {
> > netif_err(qdev, drv, qdev->ndev,
> > "IDC: Invalid State 0x%.04x.\n",
> > mbcp->mbox_out[0]);
> > status = -EIO;
> > - break;
> > + s_sig = true;
> > }
> > +
> > + if (s_sig)
> > + break;
> > }
> >
> > return status;
> > --
> > 2.34.1
> >
> >
> >
next prev parent reply other threads:[~2023-10-14 7:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-14 6:11 [PATCH] staging: qlge: Add bool type to qlge_idc_wait() Gilbert Adikankwu
2023-10-14 6:23 ` Julia Lawall
2023-10-14 7:39 ` Gilbert Adikankwu [this message]
2023-10-14 6:58 ` Nam Cao
2023-10-14 7:14 ` Nam Cao
2023-10-14 7:50 ` Gilbert Adikankwu
2023-10-16 14:19 ` Przemek Kitszel
2023-10-17 4:21 ` Dan Carpenter
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=ZSpFtrC5xuYzgZhw@gilbert-PC \
--to=gilbertadikankwu@gmail.com \
--cc=GR-Linux-NIC-Dev@marvell.com \
--cc=coiby.xu@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=julia.lawall@inria.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=manishc@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=outreachy@lists.linux.dev \
/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.