Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5876841ybi; Wed, 31 Jul 2019 04:47:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwXfJ0KGDz1EJmgBe2Yyw18dRQCOdN1SKEg2B//XVN/95ZnNK/UiUh+6lEPYogzwHMlNyc X-Received: by 2002:aa7:98da:: with SMTP id e26mr46803198pfm.34.1564573656041; Wed, 31 Jul 2019 04:47:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564573656; cv=none; d=google.com; s=arc-20160816; b=0sWgFy6XOgk2CeqfAj9uuMhjWj5Z1Lfe++XDSHdVLmXpYR+Oh7s+IST8yN6BC7gvyc 6TERgTtR8eCkQoH7hq07ggqErVtlwt1hGSCRhdEIRwkXlF0mq4wP2UIJ2KXx6iRPCwW0 fbM3AuYlfHN3D5liAVEWFFXArYN0HdyaGufnxbmdho2k16Abo0MbbGY8XjgrjaWXvUF5 B7ETPhwn6LNZ6tZo8HjK/aJD7SwhO0k+tIkwX3bnnwhl9kRBxDPuh8ESa6ns6C1HK2ye Wn9T5gfgPASIivnLS8aprWMCaEM3khpRib5t9bvhVGC3o3gXb9QJpDhfqq8DftodH65p gBSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=U5/aKyE8Iyn/KuJHNm8Nnbc3/K2wFZKu9b0P1y3NLZc=; b=NJw+50x2mUwWLC/gbAl/FW/dxxpCpwzHid5h1+kON1x6cGbMO6b1eAGrGWySNnRJmI sUNKz/guQSEw2gRmcABfWEYwSFWeIW/tRiXptgZLTG0gD4RsKccPBRbNPk/KoMOfwTYv ntI9sN6LGPNgRL1rpF3D+JaFHUhOvzlgZgCww8Ts70M0urnLy19hyHVDnpHJDZyl/H+x yJfEZNQQ9HFWhoDzNmleqyPiib1XD9BwkmH8Byph0KmHs2iGJaivVPGx5xT6CiqOHWY6 w42y9/XyUw59wmRnCWhr3iDNLDHVXoecQSTc6RqqzxDzi2+NRqLZ/2QYkXEFThOkpwot MnGg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 67si31482236pfb.242.2019.07.31.04.47.19; Wed, 31 Jul 2019 04:47:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727221AbfGaLqj (ORCPT + 99 others); Wed, 31 Jul 2019 07:46:39 -0400 Received: from ozlabs.org ([203.11.71.1]:54333 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbfGaLqi (ORCPT ); Wed, 31 Jul 2019 07:46:38 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 45zBTm01V7z9s00; Wed, 31 Jul 2019 21:46:35 +1000 (AEST) From: Michael Ellerman To: Kees Cook Cc: Stephen Rothwell , Benjamin Herrenschmidt , PowerPC , "Gustavo A. R. Silva" , Linux kernel Mailing List Subject: Re: [PATCH] drivers/macintosh/smu.c: Mark expected switch fall-through In-Reply-To: <201907301005.0661E63CF@keescook> References: <20190730143704.060a2606@canb.auug.org.au> <878ssfzjdk.fsf@concordia.ellerman.id.au> <201907301005.0661E63CF@keescook> Date: Wed, 31 Jul 2019 21:46:34 +1000 Message-ID: <87ef26qvdx.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kees Cook writes: > On Wed, Jul 31, 2019 at 12:28:55AM +1000, Michael Ellerman wrote: >> Stephen Rothwell writes: >> > Mark switch cases where we are expecting to fall through. >> > >> > This patch fixes the following warning (Building: powerpc): >> > >> > drivers/macintosh/smu.c: In function 'smu_queue_i2c': >> > drivers/macintosh/smu.c:854:21: warning: this statement may fall through [-Wimplicit-fallthrough=] >> > cmd->info.devaddr &= 0xfe; >> > ~~~~~~~~~~~~~~~~~~^~~~~~~ >> > drivers/macintosh/smu.c:855:2: note: here >> > case SMU_I2C_TRANSFER_STDSUB: >> > ^~~~ >> > >> > Cc: Benjamin Herrenschmidt >> > Cc: Gustavo A. R. Silva >> > Cc: Kees Cook >> > Signed-off-by: Stephen Rothwell >> > --- >> > drivers/macintosh/smu.c | 1 + >> > 1 file changed, 1 insertion(+) >> > >> > diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c >> > index 276065c888bc..23f1f41c8602 100644 >> > --- a/drivers/macintosh/smu.c >> > +++ b/drivers/macintosh/smu.c >> > @@ -852,6 +852,7 @@ int smu_queue_i2c(struct smu_i2c_cmd *cmd) >> > break; >> > case SMU_I2C_TRANSFER_COMBINED: >> > cmd->info.devaddr &= 0xfe; >> > + /* fall through */ >> > case SMU_I2C_TRANSFER_STDSUB: >> > if (cmd->info.sublen > 3) >> > return -EINVAL; >> >> Why do we think it's an expected fall through? I can't really convince >> myself from the surrounding code that it's definitely intentional. > > Yeah, good question. Just now when I went looking for who > used SMU_I2C_TRANSFER_COMBINED, I found the only caller in > arch/powerpc/platforms/powermac/low_i2c.c and it is clearly using a > fall-through for building the command for "stdsub" and "combined", > so I think that's justification enough: > > switch(bus->mode) { > case pmac_i2c_mode_std: > if (subsize != 0) > return -EINVAL; > cmd->info.type = SMU_I2C_TRANSFER_SIMPLE; > break; > case pmac_i2c_mode_stdsub: > case pmac_i2c_mode_combined: > if (subsize > 3 || subsize < 1) > return -EINVAL; > cmd->info.sublen = subsize; > /* that's big-endian only but heh ! */ > memcpy(&cmd->info.subaddr, ((char *)&subaddr) + (4 - subsize), > subsize); > if (bus->mode == pmac_i2c_mode_stdsub) > cmd->info.type = SMU_I2C_TRANSFER_STDSUB; > else > cmd->info.type = SMU_I2C_TRANSFER_COMBINED; > > > Reviewed-by: Kees Cook Thanks. cheers