Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp863005ybp; Fri, 4 Oct 2019 06:12:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7SHuYi9ao55o9AO2pkjvBLJC6JmuMCyPiN7fHo6THiwxKexD1/+HBf6TF/tG+Df/hG1u/ X-Received: by 2002:a17:907:20a2:: with SMTP id pw2mr12173470ejb.163.1570194762704; Fri, 04 Oct 2019 06:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570194762; cv=none; d=google.com; s=arc-20160816; b=Vn8E/+mDKWAch7w1LonWu0stCinZttHWX9aKp07P3K/IW8ycLE3ocNO2ZFxdcVuTRt CmohLqyXbpqivLmYGwqBqLABoN1VXdqpdMV4OPcgiPLF3KRxI6GPltPXn8/wAe6tHai+ nc27/VXr6EGrd3ORwF5SZZCUiQz5TiJiClE2X6cLKcztdgzDHw3UXGllasTFLF50NbCn Ut339Ld3g092E16UIFuNprv5MxcoY5SebF/iVTDq9KKfMzHp33hDR/WJ8qdsRTQP+4bo ZNYoZhNAhE2FUzJ84GCDrYCt/7b70fSVkwrhrun6w4wXpuyG5kvjnobzN6E1BDlbdSqX sVKQ== 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=c7K0mWGu+AI0b6WD6vjlrWra6mM2Bhm7aHo+ZfW09aA=; b=dqYISBS8teUDGB0Pqp14BJ98nJ2ghsDCwnUNR+Mqu606tPpsp4hUwkzS8dGI22PsW8 uHlmuU96LgPhioDRLTDIsE3Px4HNQk15oJLQ77lGS2b1okblvEdbH5keUBhrYmMKWMKX 1Sr6uXf6VoOnsV7VyXOXnb29UesNO8YoWQx3xX8vCuFkBUNWtnHPd5286z0up9n5rypi 8omHL6LMcXGTL3nQDjmIdOFFnrPkC4bi+A8YcWTt25iMBUAYKs+kjV4Cc6usDczI8e1K fqY+bPunDMhOhAZYrwqsXaCGSSqHQ1+FGOfsBA9jNADMUysq04ybLb6EGUKF4GHBjx6p cRuQ== 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 26si3165539ejl.292.2019.10.04.06.12.17; Fri, 04 Oct 2019 06:12:42 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388249AbfJDNIk (ORCPT + 99 others); Fri, 4 Oct 2019 09:08:40 -0400 Received: from mga14.intel.com ([192.55.52.115]:38014 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387545AbfJDNIk (ORCPT ); Fri, 4 Oct 2019 09:08:40 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Oct 2019 06:08:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,256,1566889200"; d="scan'208";a="276041229" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by orsmga001.jf.intel.com with SMTP; 04 Oct 2019 06:08:36 -0700 Received: by stinkbox (sSMTP sendmail emulation); Fri, 04 Oct 2019 16:08:35 +0300 Date: Fri, 4 Oct 2019 16:08:35 +0300 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Benjamin GAIGNARD Cc: Benjamin Gaignard , David Airlie , Daniel Vetter , Linux Kernel Mailing List , ML dri-devel Subject: Re: [PATCH] drm: atomic helper: fix W=1 warnings Message-ID: <20191004130835.GX1208@intel.com> References: <20190909135205.10277-1-benjamin.gaignard@st.com> <20190909135205.10277-2-benjamin.gaignard@st.com> <20191003142738.GM1208@intel.com> <20191003150526.GN1208@intel.com> <20191003154627.GQ1208@intel.com> <20191004122747.GT1208@intel.com> <5fe9d7e2-f434-70cb-ac0f-ad66a565093d@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5fe9d7e2-f434-70cb-ac0f-ad66a565093d@st.com> 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 Fri, Oct 04, 2019 at 12:36:56PM +0000, Benjamin GAIGNARD wrote: > > On 10/4/19 2:27 PM, Ville Syrj?l? wrote: > > On Fri, Oct 04, 2019 at 12:48:02PM +0200, Benjamin Gaignard wrote: > >> Le jeu. 3 oct. 2019 ? 17:46, Ville Syrj?l? > >> a ?crit : > >>> On Thu, Oct 03, 2019 at 05:37:15PM +0200, Benjamin Gaignard wrote: > >>>> Le jeu. 3 oct. 2019 ? 17:05, Ville Syrj?l? > >>>> a ?crit : > >>>>> On Thu, Oct 03, 2019 at 04:46:54PM +0200, Benjamin Gaignard wrote: > >>>>>> Le jeu. 3 oct. 2019 ? 16:27, Ville Syrj?l? > >>>>>> a ?crit : > >>>>>>> On Mon, Sep 09, 2019 at 03:52:05PM +0200, Benjamin Gaignard wrote: > >>>>>>>> Fix warnings with W=1. > >>>>>>>> Few for_each macro set variables that are never used later. > >>>>>>>> Prevent warning by marking these variables as __maybe_unused. > >>>>>>>> > >>>>>>>> Signed-off-by: Benjamin Gaignard > >>>>>>>> --- > >>>>>>>> drivers/gpu/drm/drm_atomic_helper.c | 36 ++++++++++++++++++------------------ > >>>>>>>> 1 file changed, 18 insertions(+), 18 deletions(-) > >>>>>>>> > >>>>>>>> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c > >>>>>>>> index aa16ea17ff9b..b69d17b0b9bd 100644 > >>>>>>>> --- a/drivers/gpu/drm/drm_atomic_helper.c > >>>>>>>> +++ b/drivers/gpu/drm/drm_atomic_helper.c > >>>>>>>> @@ -262,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state, > >>>>>>>> struct drm_encoder *encoder) > >>>>>>>> { > >>>>>>>> struct drm_crtc_state *crtc_state; > >>>>>>>> - struct drm_connector *connector; > >>>>>>>> + struct drm_connector __maybe_unused *connector; > >>>>>>> Rather ugly. IMO would be nicer if we could hide something inside > >>>>>>> the iterator macros to suppress the warning. > >>>>>> Ok but how ? > >>>>>> connector is assigned in the macros but not used later and we can't > >>>>>> set "__maybe_unused" > >>>>>> in the macro. > >>>>>> Does another keyword exist for that ? > >>>>> Stick a (void)(connector) into the macro? > >>>> That could work but it will look strange inside the macro. > >>>> > >>>>> Another (arguably cleaner) idea would be to remove the connector/crtc/plane > >>>>> argument from the iterators entirely since it's redundant, and instead just > >>>>> extract it from the appropriate new/old state as needed. > >>>>> > >>>>> We could then also add a for_each_connector_in_state()/etc. which omit > >>>>> s the state arguments and just has the connector argument, for cases where > >>>>> you don't care about the states when iterating. > >>>> That may lead to get a macro for each possible combination of used variables. > >>> We already have new/old/oldnew, so would "just" add one more. > >> Not just one, it will be one each new/old/oldnew macro to be able to distinguish > >> when connector is used or not. > > What I'm suggesting is this: > > for_each_connector_in_state(state, connector, i) > > for_each_old_connector_in_state(state, old_conn_state, i) > > for_each_new_connector_in_state(state, new_conn_state, i) > > for_each_oldnew_connector_in_state(state, old_conn_state, new_conn_state, i) > > > > So only four in total for each object type, instead of the current > > three. > > You are missing these cases: old and connector, new and connector, > > old and new and connector are needed together. No, that's redundant. You can always get the connector from old/new_conn_state->connector if you need it. -- Ville Syrj?l? Intel