Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1988255ybv; Fri, 21 Feb 2020 06:54:26 -0800 (PST) X-Google-Smtp-Source: APXvYqy3Gb1TUqwdNG5MRWLx8RFnVTg9qUvcgcoYh8zvN2CbITFrIhZEoq+TRNjL9vZrf/qqAoIE X-Received: by 2002:a9d:6b95:: with SMTP id b21mr27067120otq.96.1582296866515; Fri, 21 Feb 2020 06:54:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582296866; cv=none; d=google.com; s=arc-20160816; b=pWfJJod6344gkz7balz7yoJPYHcRm14yAgA67HsREeLV5nPK2fWWmgyzsIpD3ZdCxY pDXeVCXJzWnu5QzrSoEKK8OEV3yaaswWgwelLyZGmHG28b8ZTQ+lcYm3ccoHC9qc7xO8 iIeSP4yS9esfxIGXMAJTzedP1hXI6oOnVm2dv6+6vg6VVnuzwl2IaZqETa4iYdOEC7YD 7o/6InmhG23Vj5BPnjGX3kjKVtmEjP9NJr4e+ClriP2SZmvGrCO5k05f8KYe8IH90NvN LqjrrZPDX8DnJWvFCVQMR96aP+ZsHZBh0mLVAi2SZRrGav7TmjsJjQXI3RMxxuXUC7NS 0n5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:in-reply-to:subject:cc:to:from:date; bh=N9WTjtJQ4iwJr+krFIBWdYBYoLBACcb2H12/mdcTRmY=; b=vP62HgnhBz7tFIxBKEJFppcn3u16cTELA7VNr5stSsxIyAAu+ckwredL2G7UpZ8n9X jw1D3zuE7fuYQG+s6MKjA3oxrcOBDZ3QHiQhoMbzqNDwG0MzZpLbkU0KOisD6wzNgvoz hGzpNqDhC0PDgdgYsKvvtInm1HpMBKa8miTp4jgePOrEvlR2yTCRjJiRU3LJwokXI6Ok dMIcL6G24YlG+4VDPp2yUkiMmv8aP+3nt3w1jhacbRl0EZ0WeKHkBRVCIoM2UbSpB4bf V7z3LeRZhmwW9gVkOGPvAJi1fos7YpeO0YX9of2gVmh24F7OnpPU2JRKmo0Wkh6hmF9/ 0Yiw== 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 s11si1577209otd.245.2020.02.21.06.54.13; Fri, 21 Feb 2020 06:54:26 -0800 (PST) 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 S1728943AbgBUOyD (ORCPT + 99 others); Fri, 21 Feb 2020 09:54:03 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:53798 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1728436AbgBUOyD (ORCPT ); Fri, 21 Feb 2020 09:54:03 -0500 Received: (qmail 1498 invoked by uid 2102); 21 Feb 2020 09:54:02 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 21 Feb 2020 09:54:02 -0500 Date: Fri, 21 Feb 2020 09:54:02 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Kees Cook cc: Greg Kroah-Hartman , Felipe Balbi , Alexander Potapenko , , Subject: Re: [PATCH v2] usb: gadget: net2280: Distribute switch variables for initialization In-Reply-To: <202002201515.DFC51CF@keescook> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 20 Feb 2020, Kees Cook wrote: > Variables declared in a switch statement before any case statements > cannot be automatically initialized with compiler instrumentation (as > they are not part of any execution flow). With GCC's proposed automatic > stack variable initialization feature, this triggers a warning (and they > don't get initialized). Clang's automatic stack variable initialization > (via CONFIG_INIT_STACK_ALL=y) doesn't throw a warning, but it also > doesn't initialize such variables[1]. Note that these warnings (or silent > skipping) happen before the dead-store elimination optimization phase, > so even when the automatic initializations are later elided in favor of > direct initializations, the warnings remain. > > To avoid these problems, move such variables into the "case" where > they're used or lift them up into the main function body. > > drivers/usb/gadget/udc/net2280.c: In function ‘handle_stat0_irqs_superspeed’: > drivers/usb/gadget/udc/net2280.c:2871:22: warning: statement will never be executed [-Wswitch-unreachable] > 2871 | struct net2280_ep *e; > | ^ > > [1] https://bugs.llvm.org/show_bug.cgi?id=44916 > > Signed-off-by: Kees Cook > --- > v2: put everything in function body (Alan Stern) > v1: https://lore.kernel.org/lkml/20200220062315.69253-1-keescook@chromium.org You might want to remove part of the last sentence in the patch description. Aside from that, Acked-by: Alan Stern Alan Stern