Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp7063601ybf; Fri, 6 Mar 2020 09:38:30 -0800 (PST) X-Google-Smtp-Source: ADFU+vtIk7iUr/2wlB7/iyCnOr9mNCULRFFg6EXJPvYqnmIGdnjxsXc8sdGU8FjXqD6UlyCwzc1B X-Received: by 2002:aca:d50f:: with SMTP id m15mr3479322oig.33.1583516310617; Fri, 06 Mar 2020 09:38:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583516310; cv=none; d=google.com; s=arc-20160816; b=eSYu+jL7wQFq2TTwShKBBgerXOVKMbqPWH2Vd26vg7r5+JrJYcaw/Fzelm0rG4w6ty L7HshhDQRpSq6eiX2z8tXVl9peNQOEeWivPQwZo6MlRv0ieK6HJq5eNlDEqK6pJ90FZQ j8esWN+IltnYpucQKRqLZqmuqm7KX5a0FU+p3d2gbSHtI36LJKLinDNbdxOBKarFSxjs UX8wdC1jUSsHQtr0O9qFDf03ROVaG2392x/ZGsenrHqMpGd7vgRAonRgqJfHKRahumTO 7c6O+roG7xeZNUyOi0jmCDKFnizUe3/8FSg0Bp5SucaTcVa2/jXnYURXfnotjijtGgOD rcQw== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=NeDvLUIAgc3P9ZWfiEiKoaXL/UdWw2NQZoEeQ03LjSg=; b=gP/i4F43d2pd3plVC7i+xqC9KdHahGV0aGPumrTSXXaRwblpSIHEg+NWA1j5GP9jc4 ve22WMAHg60/iaRxIg+GKxmr5dB6gIfCVkpfWLar0TLYNzB7WkHVS6QVW0e0cqHt8C7Q j93KrXj1jXZ5zKdtW31VpPAMmLKNHNdONtsBovnjzFHVvJklp+nW+eA6JiWjbo95hij1 fHwe1EVHrYuZlOWZbAW7CsdxOrtQJbTUNU2Z31aIwXwWkCUgPElJdJctBcoUM2Yw2z6V +L5sij5udrNnndMvnusNa09Oh2PX9GMq+/Ru7921llW8ebLK8I8nibOewTK3DLrVA7OB UctQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="D0br/Nlb"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o18si1853822otk.80.2020.03.06.09.38.18; Fri, 06 Mar 2020 09:38:30 -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; dkim=pass header.i=@google.com header.s=20161025 header.b="D0br/Nlb"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726307AbgCFRhd (ORCPT + 99 others); Fri, 6 Mar 2020 12:37:33 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:39973 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725835AbgCFRhc (ORCPT ); Fri, 6 Mar 2020 12:37:32 -0500 Received: by mail-pl1-f193.google.com with SMTP id y1so1139004plp.7 for ; Fri, 06 Mar 2020 09:37:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=NeDvLUIAgc3P9ZWfiEiKoaXL/UdWw2NQZoEeQ03LjSg=; b=D0br/NlbNxvoL9TXlmxeq92xR9LOySVqWPptgRmI7yZBh9lwwKWTBqYrzAJOiSIT6a 0W95ydJ1+00kpx5Mzqz5n7INFYoaj80fuF5VUbUwI1G+J1Ta1+ImQWdHUFGQm/jTzQu4 Y9wLWhHQ56EgWO4PESPp+axZxaAuyctFrpMaaiTcl6WnCgxpomvujEKVxEcYfR8WROz4 /4whbR9iPH57mNyyILuffYjfU94um5guvxF4f1Ls4W1QBnFh17cSCigZUwzqdzhE4eNb iMeCcgsup7m5GmYkVfdJtGXwHvXZDcypm8dbt4kdrojliB2+eRuPMMkqMrzBnaaLRVkf BiCw== 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=NeDvLUIAgc3P9ZWfiEiKoaXL/UdWw2NQZoEeQ03LjSg=; b=Z+ymMoRYIwk68qoXPQKbqXFwIdzkxHSPxCrD7xbRpmfFR9Acz/FwrRn5mw5CzT0dxO 11xCFRv5doNq+h7TyvMhEtu+X1WCPYHuEX4RPdUqAyutBbvjz5yK0xJnTBSYuXpYox7/ 7piZKhPhEsvLl3Ib5kHiqauNaX1HymiJPFamD868ViPK+muUSAhdqOdtNywxqywGyXwu puCYmeP75xUNrWH3HV4l3iGlthfpE/xoYj2/nC+sEcLOLv8rYXXgn/CUyajme/PsQhNR KiCbAiHrgEaVd3D/T4L+5GVYtWBzbnevBAHwXLLVZtygLD/NYQ8SWz8RQAXVfluELSb3 HyjA== X-Gm-Message-State: ANhLgQ2LevSpqKMqr8la7Ej8oC7yzn0GUXJUL5UOuTipT1vhb0jWWCly y0+HpAFHEFHRKZz/IOB7lI7+SYElzmR4taSQD0N+dA== X-Received: by 2002:a17:90a:ead0:: with SMTP id ev16mr4798094pjb.164.1583516251450; Fri, 06 Mar 2020 09:37:31 -0800 (PST) MIME-Version: 1.0 References: <202003060930.DDCCB6659@keescook> In-Reply-To: From: Nick Desaulniers Date: Fri, 6 Mar 2020 09:37:20 -0800 Message-ID: Subject: Re: [PATCH v2] drm/edid: Distribute switch variables for initialization To: Kees Cook Cc: Daniel Vetter , Maarten Lankhorst , Maxime Ripard , David Airlie , dri-devel , clang-built-linux , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 6, 2020 at 9:36 AM Nick Desaulniers w= rote: > > On Fri, Mar 6, 2020 at 9:32 AM 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 the= y > > don't get initialized). Clang's automatic stack variable initialization > > (via CONFIG_INIT_STACK_ALL=3Dy) doesn't throw a warning, but it also > > doesn't initialize such variables[1]. Note that these warnings (or sile= nt > > That's not good, have you filed a bug against Clang yet? It should at > least warn when the corresponding stack init flag is set. D'oh, link is below. > > > 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, lift such variables up into the next code > > block. > > > > drivers/gpu/drm/drm_edid.c: In function =E2=80=98drm_edid_to_eld=E2=80= =99: > > drivers/gpu/drm/drm_edid.c:4395:9: warning: statement will never be > > executed [-Wswitch-unreachable] > > 4395 | int sad_count; > > | ^~~~~~~~~ > > > > [1] https://bugs.llvm.org/show_bug.cgi?id=3D44916 > > > > Signed-off-by: Kees Cook > > Reviewed-by: Nick Desaulniers > > > --- > > v2: move into function block instead being switch-local (Ville Syrj=C3= =A4l=C3=A4) > > --- > > drivers/gpu/drm/drm_edid.c | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c > > index 805fb004c8eb..46cee78bc175 100644 > > --- a/drivers/gpu/drm/drm_edid.c > > +++ b/drivers/gpu/drm/drm_edid.c > > @@ -4381,6 +4381,7 @@ static void drm_edid_to_eld(struct drm_connector = *connector, struct edid *edid) > > > > if (cea_revision(cea) >=3D 3) { > > int i, start, end; > > + int sad_count; > > > > if (cea_db_offsets(cea, &start, &end)) { > > start =3D 0; > > @@ -4392,8 +4393,6 @@ static void drm_edid_to_eld(struct drm_connector = *connector, struct edid *edid) > > dbl =3D cea_db_payload_len(db); > > > > switch (cea_db_tag(db)) { > > - int sad_count; > > - > > case AUDIO_BLOCK: > > /* Audio Data Block, contains SADs */ > > sad_count =3D min(dbl / 3, 15 - total_s= ad_count); > > -- > > 2.20.1 > > > > > > -- > > Kees Cook > > > > -- > > You received this message because you are subscribed to the Google Grou= ps "Clang Built Linux" group. > > To unsubscribe from this group and stop receiving emails from it, send = an email to clang-built-linux+unsubscribe@googlegroups.com. > > To view this discussion on the web visit https://groups.google.com/d/ms= gid/clang-built-linux/202003060930.DDCCB6659%40keescook. > > > > -- > Thanks, > ~Nick Desaulniers --=20 Thanks, ~Nick Desaulniers