linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Benjamin GAIGNARD <benjamin.gaignard@st.com>
Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	ML dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] drm: atomic helper: fix W=1 warnings
Date: Fri, 4 Oct 2019 16:08:35 +0300	[thread overview]
Message-ID: <20191004130835.GX1208@intel.com> (raw)
In-Reply-To: <5fe9d7e2-f434-70cb-ac0f-ad66a565093d@st.com>

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ä
> >> <ville.syrjala@linux.intel.com> 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ä
> >>>> <ville.syrjala@linux.intel.com> 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ä
> >>>>>> <ville.syrjala@linux.intel.com> 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 <benjamin.gaignard@st.com>
> >>>>>>>> ---
> >>>>>>>>   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

  reply	other threads:[~2019-10-04 13:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-09 13:52 [PATCH] drm: include: fix W=1 warnings in struct drm_dsc_config Benjamin Gaignard
2019-09-09 13:52 ` [PATCH] drm: atomic helper: fix W=1 warnings Benjamin Gaignard
2019-09-16 13:19   ` Benjamin Gaignard
2019-10-03  9:52     ` Benjamin Gaignard
2019-10-03 14:27   ` Ville Syrjälä
2019-10-03 14:46     ` Benjamin Gaignard
2019-10-03 15:05       ` Ville Syrjälä
2019-10-03 15:37         ` Benjamin Gaignard
2019-10-03 15:46           ` Ville Syrjälä
2019-10-04 10:48             ` Benjamin Gaignard
2019-10-04 12:27               ` Ville Syrjälä
2019-10-04 12:36                 ` Benjamin GAIGNARD
2019-10-04 13:08                   ` Ville Syrjälä [this message]
2019-10-08  9:55           ` Daniel Vetter
2019-09-10 12:58 ` [PATCH] drm: include: fix W=1 warnings in struct drm_dsc_config Harry Wentland
2019-09-10 17:58   ` Manasi Navare

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191004130835.GX1208@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=airlied@linux.ie \
    --cc=benjamin.gaignard@linaro.org \
    --cc=benjamin.gaignard@st.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).