Received: by 2002:a17:90a:9307:0:0:0:0 with SMTP id p7csp3955063pjo; Tue, 3 Mar 2020 10:03:04 -0800 (PST) X-Google-Smtp-Source: ADFU+vsK+Ehg4EtP5H/vpMA3e1oOFvfQMuc83OxkBmmwH/b1txEGju7RUXSf3F1eUZWmlTzMJ/5f X-Received: by 2002:a9d:7a96:: with SMTP id l22mr4303170otn.217.1583258584817; Tue, 03 Mar 2020 10:03:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583258584; cv=none; d=google.com; s=arc-20160816; b=BXtXW6SkOdx6KbpVOw8E25YFccFktzkVNQDZDAVpmkMMKkcG1qgwgIwKoqYfZ+mxDr iOwSZhcAbeJ9OlADbgIOEsqyim7Zr28uJxbLzVqZk1zFgYkjLAK0L5CQ6fisljqAnSLn u3feuIDoYs4gfWKSBvZmswDCRNKZOTseCvwb9hwnCvRLGZBAw444jrSTZHR59vIeWEnF i7W/OfmMOYLHeoEDe49zz9isk7Jzrcvr3+QiqH9VWeVmeiqvRZB0TMAzttbiR9wMhfa9 rSocw1+coIEBY6G+czA+UM3G0ktSna54LA4GHNCypEOPEXFw5bjsfaWJTHs/kyJ4yzNe AHNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=UFnymm3SrAnexPpo21Ov4ZPbKrRSb4Mw4VAwIryEd4w=; b=exa42uESF9J0pBjP3DCT7BH8ZyJRU4K4lJG3M377QmaUHCc9nDauqcIhwvOWACglrR dZ4bM3KH5Ryq6ZU6Lfi+phql3OBw/7WTlmopvkNZ4GbIhRUrVxnoyI53hv05AhHB40tw Dlth+hqdb6dOWbCC6RdKxQxg/rv6uUzuUyIAbAQkff+crK/RTAvhERkGrCf0HAANiv7t ms+4E/AF6z0MTSSlDMkIQ8qa8h6+OjKHxgPPwvvq4oK/QRaWcJ6Iols04j7HoNMBGnqL vttsI3POoCdNI1XtMnx4acFqZb2YPOi6hfELyem4NuEYktJBqgPMZyoaSMEeHtXu2FgM b6Mw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5si9941194otm.88.2020.03.03.10.02.51; Tue, 03 Mar 2020 10:03:04 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387641AbgCCSCG (ORCPT + 99 others); Tue, 3 Mar 2020 13:02:06 -0500 Received: from mga07.intel.com ([134.134.136.100]:25490 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388130AbgCCSCE (ORCPT ); Tue, 3 Mar 2020 13:02:04 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Mar 2020 10:02:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,511,1574150400"; d="scan'208";a="233714477" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by orsmga008.jf.intel.com with SMTP; 03 Mar 2020 10:02:00 -0800 Received: by stinkbox (sSMTP sendmail emulation); Tue, 03 Mar 2020 20:01:59 +0200 Date: Tue, 3 Mar 2020 20:01:59 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Kees Cook Cc: Maarten Lankhorst , Maxime Ripard , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, Alexander Potapenko , linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/edid: Distribute switch variables for initialization Message-ID: <20200303180159.GA13686@intel.com> References: <20200220062229.68762-1-keescook@chromium.org> <202003022038.07A611E@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202003022038.07A611E@keescook> X-Patchwork-Hint: comment User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 02, 2020 at 08:39:37PM -0800, Kees Cook wrote: > On Wed, Feb 19, 2020 at 10:22:29PM -0800, 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/gpu/drm/drm_edid.c: In function ‘drm_edid_to_eld’: > > 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=44916 > > > > Signed-off-by: Kees Cook > > Ping. Can someone pick this up, please? > > Thanks! > > -Kees > > > --- > > drivers/gpu/drm/drm_edid.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c > > index 805fb004c8eb..2941b65b427f 100644 > > --- a/drivers/gpu/drm/drm_edid.c > > +++ b/drivers/gpu/drm/drm_edid.c > > @@ -4392,9 +4392,9 @@ static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid) > > dbl = cea_db_payload_len(db); > > > > switch (cea_db_tag(db)) { > > - int sad_count; > > + case AUDIO_BLOCK: { I've never been a fan of {} inside switch statements. I'd just move this one level up. > > > > - case AUDIO_BLOCK: > > + int sad_count; > > /* Audio Data Block, contains SADs */ > > sad_count = min(dbl / 3, 15 - total_sad_count); > > if (sad_count >= 1) > > @@ -4402,6 +4402,7 @@ static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid) > > &db[1], sad_count * 3); > > total_sad_count += sad_count; > > break; > > + } > > case SPEAKER_BLOCK: > > /* Speaker Allocation Data Block */ > > if (dbl >= 1) > > > > -- > Kees Cook > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Ville Syrjälä Intel