Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B31F13D74; Sat, 14 Oct 2023 06:58:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="rZv9zF57"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="zI/SGN9W" Date: Sat, 14 Oct 2023 08:58:13 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1697266697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sN/M4L6Q9tZIGosWFp/kcGmAa2Y/6EWiUPwyWfd8rKE=; b=rZv9zF571294pKPYQEo+flX23oNTcz7yICfujI8U7SWOjEeeQU2OGHKTocOVg8qTK6qRuE 0mn5Ec8Hq/nbnU5rIKwT4ogtLCW0nFDa8cyMkdijXM0yc0Eioe0gPdIowLOGiYSwXokVYq JsJFUPuNvBFy/bm/4YQInOd+cPaMDL5iPBnMOraBIafXrx3KcfFMiT0Xi+RzKI+1Tczx7d 8HTp1qamuebvdSiUlwMZBbD/5nQsjnqSHWMK41UodMJXMHkyGTn9rN70xZ8k5NCEnjocBI L64bjgO9iLDM7p0H6zdkODOX5RXAf1OA6pGbMvr1r4DbgU6Ifhftp6df1uyDKA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1697266697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sN/M4L6Q9tZIGosWFp/kcGmAa2Y/6EWiUPwyWfd8rKE=; b=zI/SGN9WX+UWpuGElmwJn8VnnTpxCeZTQAIXKLSxcDwJO/92htVLVxVMct33PGHEzHMWny OIte2F/uIaH8oAAw== From: Nam Cao To: Gilbert Adikankwu 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() Message-ID: <20231014065813.mQvFyjWb@linutronix.de> References: Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Sat, Oct 14, 2023 at 07:11:59AM +0100, Gilbert Adikankwu wrote: > Reported by checkpatch: > > WARNING: else is not generally useful after a break or return > What checkpatch is telling you here is that the "else" is redundant and can be removed. Although your patch suppresses the warning, it makes the code messier :( Best regards, Nam > 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. > > Signed-off-by: Gilbert Adikankwu > --- > 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 > #include > #include > +#include > > /* > * 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 >