From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AD58C43461 for ; Mon, 14 Sep 2020 16:43:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD9F5206A5 for ; Mon, 14 Sep 2020 16:43:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbgINQnO (ORCPT ); Mon, 14 Sep 2020 12:43:14 -0400 Received: from smtprelay0063.hostedemail.com ([216.40.44.63]:48834 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726061AbgINQnC (ORCPT ); Mon, 14 Sep 2020 12:43:02 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id 7633B100E8465; Mon, 14 Sep 2020 16:42:52 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: twig87_0f068782710a X-Filterd-Recvd-Size: 3560 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf16.hostedemail.com (Postfix) with ESMTPA; Mon, 14 Sep 2020 16:42:50 +0000 (UTC) Message-ID: <8c95d3d02dbdd36a048280cb8d9e8f171c3b4959.camel@perches.com> Subject: Re: [RESEND PATCH] staging: rtl8188eu: Fix else after return WARNING (checkpatch) From: Joe Perches To: Dan Carpenter , Sohom Datta Cc: Greg Kroah-Hartman , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Larry Finger Date: Mon, 14 Sep 2020 09:42:49 -0700 In-Reply-To: <20200914145755.GD4282@kadam> References: <230f781dcaadfc797a016cc6036d63efe6542062.camel@learner.manipal.edu> <20200914145755.GD4282@kadam> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.36.4-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2020-09-14 at 17:57 +0300, Dan Carpenter wrote: > On Sun, Sep 13, 2020 at 12:19:50PM +0530, Sohom Datta wrote: > > > From 4c8c8f3ff7f4d711daea4ac3bb987fcecc7ef1ed Mon Sep 17 00:00:00 2001 > > From: Sohom > > Date: Sat, 12 Sep 2020 18:04:56 +0530 > > Subject: [RESEND PATCH] staging: rtl8188eu: Fix else after return WARNING > > (checkpatch) > > > > Fixed: > > WARNING: else is not generally useful after a break or return > > 1636: FILE: ./rtw_recv.c:1636: > > + return false; > > + else > > > > Separated the return statement into a separate block since > > it doesn't seem to depend on the SN_LESS explicity being false. > > > > Signed-off-by: Sohom > > --- > > drivers/staging/rtl8188eu/core/rtw_recv.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c > > index 5fe7a0458dd2..5e81134ffb6d 100644 > > --- a/drivers/staging/rtl8188eu/core/rtw_recv.c > > +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c > > @@ -1629,10 +1629,11 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, > > hdr = list_entry(plist, struct recv_frame, list); > > pnextattrib = &hdr->attrib; > > > > + if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num)) > > + return false; > > + > > if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) > > plist = plist->next; > > - else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num)) > > - return false; > > else > > break; > > } > > Checkpatch is just wrong here. Ignore it when it's wrong. It's not "wrong" here. It's making a suggestion. Perhaps read the SN_EQUAL and SN_LESS macros. a and b are both u16's here. drivers/staging/rtl8188eu/include/rtw_recv.h:#define SN_LESS(a, b) (((a - b) & 0x800) != 0) drivers/staging/rtl8188eu/include/rtw_recv.h:#define SN_EQUAL(a, b) (a == b) Reordering works, perhaps it's just a question of whether it's the most likely result of the test. This is in a while loop. If the expected test is really the most likely that SN_LESS is true, then perhaps this loop could be something like: if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) { plist = plist->next; continue; } if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num)) return false; break; } The real question is whether or not that's more readable.