Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1388089rdg; Fri, 13 Oct 2023 23:24:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2hmPB65aZzFS9zB8ePzEVBnO88gr+6308Hs555gT47zJr8FW/5UeFtRRkioCuyk8WVa8F X-Received: by 2002:a05:6871:5288:b0:1e9:ccec:645a with SMTP id hu8-20020a056871528800b001e9ccec645amr5752813oac.44.1697264667799; Fri, 13 Oct 2023 23:24:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697264667; cv=none; d=google.com; s=arc-20160816; b=mxwVwxkUNf8phW8B99eYWQb89LD+SDEAqeE5TiwzKj8+2WNb810pDYq4UsCGNr4p7T FqoNKmTlXWRQNtRzHWzUqWdJrIiSshUEYRR9BOGH5qgVj0smLp3FCy3KmaV1N4ODCQHb kkDenpSbbAOdPMvwQSPHUYD9BvG9E5P6pIIzZF6+ouZnJnwy0O67RmoEOwZxm7iTcpxP UkHRBkhx/e6dy6D+OXMj347Me+ZzzNYC870WcXWBDntHlOU09Jiq4Co0dKEqDpYjQu28 eN3H8+KRSv2GiEokDpfO4c4FjDjLj5y9um4H3jtETXl5e9BkbmtECr/Bi6Y1Lj8n+jgU cZCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=yFzlpkyvZPpAIoodnzAqzdRSObdnjJuYo39Mj5FNOmQ=; fh=Y/3Wn+KbkQjqqsA1ioRHkhpt8ligmWBl+5hpCgKo+LA=; b=zc5LWYgljez/uJRqnzs49409z7vKOynVRZ98GIU2PkhhRdq+GtFSPq/1MxR7fD9EFi pUYopbQp1LTm+INyHo5rbISrF7jCJivJgtDS4TEhEsop1zU7UsNsNXnLo+KSF2MRI89O VguSOx+bgeFJd1V2XJY9F1C74ABwBT0CBaz0ihZH+3sQ7nCC2QVW4B8JNOLffSf0n5vM 2dWfdSc5tpr25J6J9vLKMpxU74ZNKRihZlLYoxP+BcoFvFEddmrpfN3rnA0duppVPuqD p9cqbdhItBR3LKzsIHn603WX/RhdQsi6NpL3yey2AteVwC+5gitwlm+S8bt9jrcwdxaw 6MrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=eXEh3NBJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id 7-20020a631947000000b00578a66db83fsi6151861pgz.141.2023.10.13.23.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 23:24:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=eXEh3NBJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2D75780C345D; Fri, 13 Oct 2023 23:24:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231377AbjJNGXS (ORCPT + 99 others); Sat, 14 Oct 2023 02:23:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjJNGXR (ORCPT ); Sat, 14 Oct 2023 02:23:17 -0400 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D50E2BF for ; Fri, 13 Oct 2023 23:23:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=yFzlpkyvZPpAIoodnzAqzdRSObdnjJuYo39Mj5FNOmQ=; b=eXEh3NBJLfWVhwyl2lcUoAdjPzfbpjWCfIF9HQW00x8N1GW1u2LyLc2o H0RkghrxGuq/PxCITTFZ0JH2G9fxzFlVX4ZcumAclr9pwm0dE6GgQlIu5 e6AFw8IUYBjHIAA6B/zia4er/+EEeBCS7an3UL42DTrhVbebr+9O1mKVh c=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=julia.lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.03,224,1694728800"; d="scan'208";a="131207271" Received: from 231.85.89.92.rev.sfr.net (HELO hadrien) ([92.89.85.231]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2023 08:23:12 +0200 Date: Sat, 14 Oct 2023 08:23:13 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien 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() In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 13 Oct 2023 23:24:25 -0700 (PDT) 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 > > 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 > > >