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=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED 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 C0D10C282C0 for ; Wed, 23 Jan 2019 12:12:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8DD152183F for ; Wed, 23 Jan 2019 12:12:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linaro.org header.i=@linaro.org header.b="H+m7GGMj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727308AbfAWMMj (ORCPT ); Wed, 23 Jan 2019 07:12:39 -0500 Received: from mail-io1-f66.google.com ([209.85.166.66]:36939 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726322AbfAWMMi (ORCPT ); Wed, 23 Jan 2019 07:12:38 -0500 Received: by mail-io1-f66.google.com with SMTP id g8so1490174iok.4 for ; Wed, 23 Jan 2019 04:12:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=7CuKdBNpc7lIzSxWikvoBf9wcEakd+B812ZHSpJjJVY=; b=H+m7GGMjF6744xT1D2UwyNiY/KMpTtbRw5bi2y+pCDduRAgSAvhW2ZIPfnH2kOOExh 3Su0JFmxMJMowRT9N2wYUjrjYvuBsgKmxpYbizh11PtffeWo9FwZbrdMYunm9gcvYSN7 D7CAGGUmeHybx5kZaQ1Zx2WU51V6DvtSTJ2bc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=7CuKdBNpc7lIzSxWikvoBf9wcEakd+B812ZHSpJjJVY=; b=UxZi2eaqDyaSgjcQ33vZE2FXTpkX97i9sK3THPyYrMtbtg96Ah1YgjJNgwFjIlvBFn rGOTpZe66dOnRyxbN62ttzHSrzqUko+ttLZWiZSLWNaEfltCXZfmUsIaLw1j4qfMorfo Me8Z/rf7HsmuiGCTg526/gyD+s5wHH3D/ZpOBqBKUb01k15agbofNkqV6g5p7F4vAGr3 XwlQxThktW1WWu3MueMJbDCQvd85uMUONNPgH4hMH3PopujEJqv9DfVjmQ+m7LYaht6S BEUGUe0KksdLXeKVoHc6Cfu5KUTHiCl7t9HX9DRAtmZVZVsCeMqniEmqe2lKVdv+MsxC DmYA== X-Gm-Message-State: AHQUAuauL+B1rH7/7XY3XQdRFwX07G3o6Uz4rsIuCVLhm37Msq0qca6t y19VJfyv6yW00uhXPcbTz6qPq+uNOZCgOgEIpTCrPw== X-Google-Smtp-Source: ALg8bN4sFH3iEczabalnBNhAFEjMavAEqGBGd/B710UVgMJuAnz9dDSdLnQkCrtIxakuPDjbIn3RSmgeu7Pdts1qkOs= X-Received: by 2002:a5d:8410:: with SMTP id i16mr1019729ion.173.1548245557818; Wed, 23 Jan 2019 04:12:37 -0800 (PST) MIME-Version: 1.0 References: <20190123110349.35882-1-keescook@chromium.org> <20190123110349.35882-2-keescook@chromium.org> <20190123115829.GA31385@kroah.com> In-Reply-To: From: Ard Biesheuvel Date: Wed, 23 Jan 2019 13:12:26 +0100 Message-ID: Subject: Re: [PATCH 1/3] treewide: Lift switch variables out of switches To: Jann Horn Cc: Greg KH , Kees Cook , kernel list , Laura Abbott , Alexander Popov , xen-devel , dri-devel , intel-gfx@lists.freedesktop.org, intel-wired-lan@lists.osuosl.org, Network Development , linux-usb , linux-fsdevel@vger.kernel.org, Linux-MM , dev@openvswitch.org, Linux Kbuild mailing list , linux-security-module , Kernel Hardening Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, 23 Jan 2019 at 13:09, Jann Horn wrote: > > On Wed, Jan 23, 2019 at 1:04 PM Greg KH wrot= e: > > On Wed, Jan 23, 2019 at 03:03:47AM -0800, Kees Cook wrote: > > > Variables declared in a switch statement before any case statements > > > cannot be initialized, so move all instances out of the switches. > > > After this, future always-initialized stack variables will work > > > and not throw warnings like this: > > > > > > fs/fcntl.c: In function =E2=80=98send_sigio_to_task=E2=80=99: > > > fs/fcntl.c:738:13: warning: statement will never be executed [-Wswitc= h-unreachable] > > > siginfo_t si; > > > ^~ > > > > That's a pain, so this means we can't have any new variables in { } > > scope except for at the top of a function? > > AFAICS this only applies to switch statements (because they jump to a > case and don't execute stuff at the start of the block), not blocks > after if/while/... . > I guess that means it may apply to other cases where you do a 'goto' into the middle of a for() loop, for instance (at the first iteration), which is also a valid pattern. Is there any way to tag these assignments so the diagnostic disregards them= ?