Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1410807rdg; Sat, 14 Oct 2023 00:39:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2ISyRK320sKnMzHiWmjhzCiBVufTzyK3dafqrTKSbtc4yIZ5QaBE/EjULQhXUUdcNljFE X-Received: by 2002:a05:6358:702:b0:143:9bc0:a975 with SMTP id e2-20020a056358070200b001439bc0a975mr26679925rwj.7.1697269189442; Sat, 14 Oct 2023 00:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697269189; cv=none; d=google.com; s=arc-20160816; b=zGMayzhaVBb5B3eKeKcq76U5tmGfzjJATV15TqeVdrTDGYJjW2CJfEpXH4u93YGE5W PxYgSGIhCLlHJ8yHvFHhRdh3Ix6vrLHvJ/u0JTU+GdQJG7+KBs9Wpj5pcBCRZdSIfxV7 zHCJmV4fn/lrEKuW3DtKjXXQJTRZTVlm8eZTA6jjrzXhv4sIofu/CcbSwJUQb4d1Cber dwyH5m12rFFE+Qrj+zrdCPe9VyKRJyXT0S2OTA0aQ2fxSNJw4SdWtg+nXTqMpyJCwSHE CEAkX6sdEa6Fcx52TIP1MRnh+B2QJDpBxcfHUNynRWr3zTAm7x9fOkD9nuBlp484MPX4 6DvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=O3pfyKY5IaoFuTuLVntmNnqtU1SUqO73JEN0YvBTiXE=; fh=GzrTR1CtusH80zUAxMPGRq6eSTIpzsqz2MJOamujj6Q=; b=cImkVlqtqpX+u8NfaR5TOnFTirPcJ73uhLMXPF/n0W/56emB/thT0IzTUuwtcS/qLr jP7SYXGlCAJb8DUuTf6+C9lJZBjqyg14VU5gTbQC/frx4qyy5QuTUXlMlNjHyXxrvjpP Sr2hF+ccrqB+HN4Qb8lyt8F6aQ1YMenDkTsSKp8HJpwLYYd1+6Sp3oRCDlIkGC27Cqud 7UjZ0z+jeE2pBsVhNlhYrHLnx6aHpaudpeCx7Bszn0hcXA19LsQiQnfswqBPtOsJfhh1 lP5FDlRAB0Y3664pEMpBvheqB/F3iadlYpYXrU1VwE+lUsQSbxqq5cOqI4XVE1UUnHu3 /wBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SdtIzRSn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id cl4-20020a056a0032c400b0068a5877bfaesi18443479pfb.382.2023.10.14.00.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 00:39:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SdtIzRSn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 692B28028E6C; Sat, 14 Oct 2023 00:39:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232860AbjJNHjr (ORCPT + 99 others); Sat, 14 Oct 2023 03:39:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjJNHjp (ORCPT ); Sat, 14 Oct 2023 03:39:45 -0400 Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D1ADB3; Sat, 14 Oct 2023 00:39:44 -0700 (PDT) Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-5a7bbcc099fso35776867b3.3; Sat, 14 Oct 2023 00:39:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697269183; x=1697873983; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=O3pfyKY5IaoFuTuLVntmNnqtU1SUqO73JEN0YvBTiXE=; b=SdtIzRSngbDs7E0rP8faZ+PDnoHk3mznG1rAaaPw+OASvSG5z3grZj5lEruvIBS5Fx or/umvCf/WWMYOhQTMR2Il3PCJB0zsSHhTXcXqrNMOjzjMWqieCWXfkg1+pxPEVGLqmg 7ZnktwaiYWNeb+argnfMHr8SWGyTymAnUgDnc1R+uf0JF8cwJW2otGkZunAsphF1Hfv6 GuzUmpw20urdwXl0VMgNOJHshxckQmupqq0zAxhdzJE1GnIPq7N8a12HRXoxMzlJ2AUF GJGAPOhkWUNYwOMy4RRoo7IR3O20Sz5OVSD1IsHY0OmuFuk/+KPLtRxxN8am/Tb9dj8C GZMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697269183; x=1697873983; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=O3pfyKY5IaoFuTuLVntmNnqtU1SUqO73JEN0YvBTiXE=; b=PuKlazZ6kJ5NxCifid51GINXjHx1jXoCSPEazuOOKI1x+DWUtYvKwSJK2lxpStSHy4 +sfpddqZM/+3YADn0gA1CffBkhOQ37ylWfeuSditkw7D4tHIKjwNr9d84BMrvf/ItRas mbIrZuaznq3d30JbQlxGDWWS6Bp9ep49K1PYcS2YYr7DV3XZjavNbtmldMDjorsN0u/F pn1eOlDc/zEUlgIrV9UzHKubAfmQ/iyX54oZv7clKFG6RSZRZ6ihpsH8R8ZrfB+QiBNX +QoNRa7gNENhOf0+3zJZ/Thlti3BmrRb+r365UeWaCzak7OQt7oHj8hHPB109fh8yXcN 9Q6Q== X-Gm-Message-State: AOJu0Yxqwl5lyT8XhVRJMNO71DprBGet4b1c5oG0D4W5G3N4G/HuIQhB Mfe9q8VwAVpalPqv5iR3030= X-Received: by 2002:a81:a546:0:b0:592:5def:5c0d with SMTP id v6-20020a81a546000000b005925def5c0dmr31356836ywg.45.1697269183527; Sat, 14 Oct 2023 00:39:43 -0700 (PDT) Received: from gilbert-PC ([105.112.18.68]) by smtp.gmail.com with ESMTPSA id w3-20020a818603000000b0059c8387f673sm394202ywf.51.2023.10.14.00.39.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 00:39:41 -0700 (PDT) Date: Sat, 14 Oct 2023 08:39:34 +0100 From: Gilbert Adikankwu To: Julia Lawall 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: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Sat, 14 Oct 2023 00:39:48 -0700 (PDT) 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 > > --- > > 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 > > > > > >