Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp810886pxv; Thu, 1 Jul 2021 09:44:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnYSgQltO/RcIP7kRDUDyBr6kd4k6Sz2XHjcc9puOD/Ks1RXAKOi4cSrwvSkRDeAu/Cxxt X-Received: by 2002:a17:906:b6c5:: with SMTP id ec5mr848244ejb.290.1625157851799; Thu, 01 Jul 2021 09:44:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625157851; cv=none; d=google.com; s=arc-20160816; b=RXv7eij2nOnpI+8V4KLXoX/Uls2byzABYx7n6VsTuABfksjrcAcLHHm76Bvc4Xf7jo 1bUkQsiaoguhl+5d7TKq2XokLb/kAFyMHCtOoe3VCalcmi/oDzhmosPO5c35MQ9gOwc3 rvWLYHVVFpuYTIblyPovbhh+bzo2JLFYiJ5OAaioyX7sTnaJe3jqQMgGQxCo27p3T+7+ 22/Bk5zP1khBHSHYuEMTWJZcsHtlN/Jy13F6cDtCQrv9QyjNRlM6RnbJmdbFn8+tnuti fVl9N2YA+6Q9LWIcnjwAxU4hSItiLcmUQfvLRvnjmXH6IRSVEUf/WMMEgnQqMbOTmIw2 p9yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=QHFKEr0jZIvRTBLmcnPN2b1Db6AXXQ7U60XAhP1ewhQ=; b=ZhLnI85PcYZnbCRRVq4MscRb6de/pFOkbQzwWfzzcJvb6ulfsmSeq74GvSIt/cv9oW Y4fDliq/Ki5iEqqY+g+8sFWKkss7RCIsV8g30fdQfLjPgqoT4+8rbpQIAQ63nxVSMk3F BJ0nfJ7aWwG7zdO3GObAljIVvDvzea0xD4FoX3PN4UgOQjXjLWyGsYJp23S8eY1yrrY3 e5Nqu3JqdVBeMbbwNnBqoZNMgWwR+cHvnZV06V7CdU7hi/kWRrwpTR3m5xiZ6w9Pv4Q6 /G7OT3PGf2E+XNsaorwj7Dt2XrS/KX2R3jd8Ox2fVWwg+M6m5JAdhb5RzUuxzFYY0aNM +/YA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 5si459092ejn.172.2021.07.01.09.43.48; Thu, 01 Jul 2021 09:44:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229978AbhGAQnc (ORCPT + 99 others); Thu, 1 Jul 2021 12:43:32 -0400 Received: from smtprelay0194.hostedemail.com ([216.40.44.194]:57082 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229764AbhGAQnb (ORCPT ); Thu, 1 Jul 2021 12:43:31 -0400 Received: from omf05.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id 6A3B5100E472A; Thu, 1 Jul 2021 16:40:59 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf05.hostedemail.com (Postfix) with ESMTPA id 37C34B2793; Thu, 1 Jul 2021 16:40:58 +0000 (UTC) Message-ID: <6ddc71efad6cd45e45991028a7656eab203df12d.camel@perches.com> Subject: Re: [PATCH] scsi: aic94xx: Fix fall-through warning for Clang From: Joe Perches To: "Gustavo A. R. Silva" , "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Kees Cook Date: Thu, 01 Jul 2021 09:40:56 -0700 In-Reply-To: <20210701010433.GA57746@embeddedor> References: <20210701010433.GA57746@embeddedor> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.0-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.88 X-Rspamd-Server: rspamout02 X-Rspamd-Queue-Id: 37C34B2793 X-Stat-Signature: gznc799dteu3m8s9wumnqrhepq5map57 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19DwiLC1MjWGtvuepLMBtmJQwGEjJXxw9w= X-HE-Tag: 1625157658-948689 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2021-06-30 at 20:04 -0500, Gustavo A. R. Silva wrote: > In preparation to enable -Wimplicit-fallthrough for Clang, fix a > warning by explicitly adding a fallthrough; statement. > > Notice that this seems to be a Duff device for performance[1]. So, > although the code looks a bit _funny_, I didn't want to refactor > or modify it beyond merely adding a fallthrough marking, which > might be the least disruptive way to fix this issue. If you read the surrounding calling code, it appears it's not performant. * @start has to be the _base_ element start, since the * linked list entries's offset is from this pointer. * Some linked list entries use only the first id, in which case * you can pass 0xFF for the second. > diff --git a/drivers/scsi/aic94xx/aic94xx_sds.c b/drivers/scsi/aic94xx/aic94xx_sds.c [] > @@ -718,10 +718,12 @@ static void *asd_find_ll_by_id(void * const start, const u8 id0, const u8 id1) > ? do { > ? switch (id1) { > ? default: > - if (el->id1 == id1) > + if (el->id1 == id1) { > + fallthrough; > ? case 0xFF: > ? if (el->id0 == id0) > ? return el; > + } > ? } > ? el = start + le16_to_cpu(el->next); > ? } while (el != start); And this is still horrible code to read. I think the below is rather more sensible and it doesn't change the defconfig with aic94xx object size. $ size drivers/scsi/aic94xx/aic94xx_sds.o* text data bss dec hex filename 10010 192 0 10202 27da drivers/scsi/aic94xx/aic94xx_sds.o.new 10010 192 0 10202 27da drivers/scsi/aic94xx/aic94xx_sds.o.old --- drivers/scsi/aic94xx/aic94xx_sds.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/aic94xx/aic94xx_sds.c b/drivers/scsi/aic94xx/aic94xx_sds.c index 297a66770260c..069278f6d6cea 100644 --- a/drivers/scsi/aic94xx/aic94xx_sds.c +++ b/drivers/scsi/aic94xx/aic94xx_sds.c @@ -717,11 +717,14 @@ static void *asd_find_ll_by_id(void * const start, const u8 id0, const u8 id1) do { switch (id1) { - default: - if (el->id1 == id1) case 0xFF: - if (el->id0 == id0) - return el; + if (el->id0 == id0) + return el; + break; + default: + if (el->id0 == id0 && el->id1 == id1) + return el; + break; } el = start + le16_to_cpu(el->next); } while (el != start);