mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Simona Vetter <simona.vetter@ffwll.ch>
To: Maxime Ripard <mripard@kernel.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Jyri Sarha <jyri.sarha@iki.fi>,
	Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	Devarsh Thakkar <devarsht@ti.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 01/28] drm/atomic: Fix unused but set warning in state iterator macros
Date: Thu, 21 May 2026 11:51:08 +0200	[thread overview]
Message-ID: <ag7VjBeFQ1Q7tTr9@phenom.ffwll.local> (raw)
In-Reply-To: <20260423-drm-state-readout-v2-1-8549f87cb978@kernel.org>

On Thu, Apr 23, 2026 at 12:18:14PM +0200, Maxime Ripard wrote:
> A number of state iterator macros trigger a compiler warning if an
> iterator parameter isn't used in the code block.
> 
> Add a similar workaround than in most other macros.

I'm not on top of macro-fu, so not leaning out the window and dropping an
r-b here. But sounds reasonable.

Acked-by: Simona Vetter <simona.vetter@ffwll.ch>

> 
> Signed-off-by: Maxime Ripard <mripard@kernel.org>
> ---
>  include/drm/drm_atomic.h | 64 +++++++++++++++++++++++++++++++-----------------
>  1 file changed, 42 insertions(+), 22 deletions(-)
> 
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index f03cd199aee7..b9e7281cfc97 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -946,13 +946,15 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	for ((__i) = 0;								\
>  	     (__i) < (__state)->num_connector;					\
>  	     (__i)++)								\
>  		for_each_if ((__state)->connectors[__i].ptr &&			\
>  			     ((connector) = (__state)->connectors[__i].ptr,	\
> -			     (void)(connector) /* Only to avoid unused-but-set-variable warning */, \
> -			     (old_connector_state) = (__state)->connectors[__i].old_state,	\
> -			     (new_connector_state) = (__state)->connectors[__i].new_state, 1))
> +			      (void)(connector) /* Only to avoid unused-but-set-variable warning */, \
> +			      (old_connector_state) = (__state)->connectors[__i].old_state,	\
> +			      (void)(old_connector_state) /* Only to avoid unused-but-set-variable warning */, \
> +			      (new_connector_state) = (__state)->connectors[__i].new_state,	\
> +			      (void)(new_connector_state) /* Only to avoid unused-but-set-variable warning */, 1))
>  
>  /**
>   * for_each_old_connector_in_state - iterate over all connectors in an atomic update
>   * @__state: &struct drm_atomic_state pointer
>   * @connector: &struct drm_connector iteration cursor
> @@ -968,12 +970,13 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	for ((__i) = 0;								\
>  	     (__i) < (__state)->num_connector;					\
>  	     (__i)++)								\
>  		for_each_if ((__state)->connectors[__i].ptr &&			\
>  			     ((connector) = (__state)->connectors[__i].ptr,	\
> -			     (void)(connector) /* Only to avoid unused-but-set-variable warning */, \
> -			     (old_connector_state) = (__state)->connectors[__i].old_state, 1))
> +			      (void)(connector) /* Only to avoid unused-but-set-variable warning */, \
> +			      (old_connector_state) = (__state)->connectors[__i].old_state, \
> +			      (void)(old_connector_state) /* Only to avoid unused-but-set-variable warning */, 1))
>  
>  /**
>   * for_each_new_connector_in_state - iterate over all connectors in an atomic update
>   * @__state: &struct drm_atomic_state pointer
>   * @connector: &struct drm_connector iteration cursor
> @@ -989,13 +992,13 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	for ((__i) = 0;								\
>  	     (__i) < (__state)->num_connector;					\
>  	     (__i)++)								\
>  		for_each_if ((__state)->connectors[__i].ptr &&			\
>  			     ((connector) = (__state)->connectors[__i].ptr,	\
> -			     (void)(connector) /* Only to avoid unused-but-set-variable warning */, \
> -			     (new_connector_state) = (__state)->connectors[__i].new_state, \
> -			     (void)(new_connector_state) /* Only to avoid unused-but-set-variable warning */, 1))
> +			      (void)(connector) /* Only to avoid unused-but-set-variable warning */, \
> +			      (new_connector_state) = (__state)->connectors[__i].new_state, \
> +			      (void)(new_connector_state) /* Only to avoid unused-but-set-variable warning */, 1))
>  
>  /**
>   * for_each_oldnew_crtc_in_state - iterate over all CRTCs in an atomic update
>   * @__state: &struct drm_atomic_state pointer
>   * @crtc: &struct drm_crtc iteration cursor
> @@ -1012,14 +1015,14 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	     (__i) < (__state)->dev->mode_config.num_crtc;		\
>  	     (__i)++)							\
>  		for_each_if ((__state)->crtcs[__i].ptr &&		\
>  			     ((crtc) = (__state)->crtcs[__i].ptr,	\
>  			      (void)(crtc) /* Only to avoid unused-but-set-variable warning */, \
> -			     (old_crtc_state) = (__state)->crtcs[__i].old_state, \
> -			     (void)(old_crtc_state) /* Only to avoid unused-but-set-variable warning */, \
> -			     (new_crtc_state) = (__state)->crtcs[__i].new_state, \
> -			     (void)(new_crtc_state) /* Only to avoid unused-but-set-variable warning */, 1))
> +			      (old_crtc_state) = (__state)->crtcs[__i].old_state, \
> +			      (void)(old_crtc_state) /* Only to avoid unused-but-set-variable warning */, \
> +			      (new_crtc_state) = (__state)->crtcs[__i].new_state, \
> +			      (void)(new_crtc_state) /* Only to avoid unused-but-set-variable warning */, 1))
>  
>  /**
>   * for_each_old_crtc_in_state - iterate over all CRTCs in an atomic update
>   * @__state: &struct drm_atomic_state pointer
>   * @crtc: &struct drm_crtc iteration cursor
> @@ -1035,11 +1038,12 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	     (__i) < (__state)->dev->mode_config.num_crtc;		\
>  	     (__i)++)							\
>  		for_each_if ((__state)->crtcs[__i].ptr &&		\
>  			     ((crtc) = (__state)->crtcs[__i].ptr,	\
>  			     (void)(crtc) /* Only to avoid unused-but-set-variable warning */, \
> -			     (old_crtc_state) = (__state)->crtcs[__i].old_state, 1))
> +			     (old_crtc_state) = (__state)->crtcs[__i].old_state, \
> +			     (void)(old_crtc_state) /* Only to avoid unused-but-set-variable warning */, 1))
>  
>  /**
>   * for_each_new_crtc_in_state - iterate over all CRTCs in an atomic update
>   * @__state: &struct drm_atomic_state pointer
>   * @crtc: &struct drm_crtc iteration cursor
> @@ -1120,12 +1124,14 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	     (__i) < (__state)->dev->mode_config.num_total_plane;	\
>  	     (__i)++)							\
>  		for_each_if ((__state)->planes[__i].ptr &&		\
>  			     ((plane) = (__state)->planes[__i].ptr,	\
>  			      (void)(plane) /* Only to avoid unused-but-set-variable warning */, \
> -			      (old_plane_state) = (__state)->planes[__i].old_state,\
> -			      (new_plane_state) = (__state)->planes[__i].new_state, 1))
> +			      (old_plane_state) = (__state)->planes[__i].old_state, \
> +			      (void)(old_plane_state) /* Only to avoid unused-but-set-variable warning */, \
> +			      (new_plane_state) = (__state)->planes[__i].new_state, \
> +			      (void)(new_plane_state) /* Only to avoid unused-but-set-variable warning */, 1))
>  
>  /**
>   * for_each_oldnew_plane_in_state_reverse - iterate over all planes in an atomic
>   * update in reverse order
>   * @__state: &struct drm_atomic_state pointer
> @@ -1142,12 +1148,15 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	for ((__i) = ((__state)->dev->mode_config.num_total_plane - 1);	\
>  	     (__i) >= 0;						\
>  	     (__i)--)							\
>  		for_each_if ((__state)->planes[__i].ptr &&		\
>  			     ((plane) = (__state)->planes[__i].ptr,	\
> -			      (old_plane_state) = (__state)->planes[__i].old_state,\
> -			      (new_plane_state) = (__state)->planes[__i].new_state, 1))
> +			      (void)(plane) /* Only to avoid unused-but-set-variable warning */, \
> +			      (old_plane_state) = (__state)->planes[__i].old_state, \
> +			      (void)(old_plane_state) /* Only to avoid unused-but-set-variable warning */, \
> +			      (new_plane_state) = (__state)->planes[__i].new_state, \
> +			      (void)(new_plane_state) /* Only to avoid unused-but-set-variable warning */, 1))
>  
>  /**
>   * for_each_new_plane_in_state_reverse - other than only tracking new state,
>   * it's the same as for_each_oldnew_plane_in_state_reverse
>   * @__state: &struct drm_atomic_state pointer
> @@ -1159,11 +1168,13 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	for ((__i) = ((__state)->dev->mode_config.num_total_plane - 1);	\
>  	     (__i) >= 0;						\
>  	     (__i)--)							\
>  		for_each_if ((__state)->planes[__i].ptr &&		\
>  			     ((plane) = (__state)->planes[__i].ptr,	\
> -			      (new_plane_state) = (__state)->planes[__i].new_state, 1))
> +			      (void)(plane) /* Only to avoid unused-but-set-variable warning */, \
> +			      (new_plane_state) = (__state)->planes[__i].new_state, \
> +			      (void)(new_plane_state) /* Only to avoid unused-but-set-variable warning */, 1))
>  
>  /**
>   * for_each_old_plane_in_state - iterate over all planes in an atomic update
>   * @__state: &struct drm_atomic_state pointer
>   * @plane: &struct drm_plane iteration cursor
> @@ -1178,11 +1189,14 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	for ((__i) = 0;							\
>  	     (__i) < (__state)->dev->mode_config.num_total_plane;	\
>  	     (__i)++)							\
>  		for_each_if ((__state)->planes[__i].ptr &&		\
>  			     ((plane) = (__state)->planes[__i].ptr,	\
> -			      (old_plane_state) = (__state)->planes[__i].old_state, 1))
> +			      (void)(plane) /* Only to avoid unused-but-set-variable warning */, \
> +			      (old_plane_state) = (__state)->planes[__i].old_state, \
> +			      (void)(old_plane_state) /* Only to avoid unused-but-set-variable warning */, 1))
> +
>  /**
>   * for_each_new_plane_in_state - iterate over all planes in an atomic update
>   * @__state: &struct drm_atomic_state pointer
>   * @plane: &struct drm_plane iteration cursor
>   * @new_plane_state: &struct drm_plane_state iteration cursor for the new state
> @@ -1216,12 +1230,15 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>   */
>  #define for_each_oldnew_private_obj_in_state(__state, obj, old_obj_state, new_obj_state, __i) \
>  	for ((__i) = 0; \
>  	     (__i) < (__state)->num_private_objs && \
>  		     ((obj) = (__state)->private_objs[__i].ptr, \
> +		      (void)(obj) /* Only to avoid unused-but-set-variable warning */, \
>  		      (old_obj_state) = (__state)->private_objs[__i].old_state,	\
> -		      (new_obj_state) = (__state)->private_objs[__i].new_state, 1); \
> +		      (void)(old_obj_state) /* Only to avoid unused-but-set-variable warning */, \
> +		      (new_obj_state) = (__state)->private_objs[__i].new_state, \
> +		      (void)(new_obj_state) /* Only to avoid unused-but-set-variable warning */, 1); \
>  	     (__i)++)
>  
>  /**
>   * for_each_old_private_obj_in_state - iterate over all private objects in an atomic update
>   * @__state: &struct drm_atomic_state pointer
> @@ -1235,11 +1252,13 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>   */
>  #define for_each_old_private_obj_in_state(__state, obj, old_obj_state, __i) \
>  	for ((__i) = 0; \
>  	     (__i) < (__state)->num_private_objs && \
>  		     ((obj) = (__state)->private_objs[__i].ptr, \
> -		      (old_obj_state) = (__state)->private_objs[__i].old_state, 1); \
> +		      (void)(obj) /* Only to avoid unused-but-set-variable warning */, \
> +		      (old_obj_state) = (__state)->private_objs[__i].old_state, \
> +		      (void)(old_obj_state) /* Only to avoid unused-but-set-variable warning */, 1); \
>  	     (__i)++)
>  
>  /**
>   * for_each_new_private_obj_in_state - iterate over all private objects in an atomic update
>   * @__state: &struct drm_atomic_state pointer
> @@ -1254,11 +1273,12 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  #define for_each_new_private_obj_in_state(__state, obj, new_obj_state, __i) \
>  	for ((__i) = 0; \
>  	     (__i) < (__state)->num_private_objs && \
>  		     ((obj) = (__state)->private_objs[__i].ptr, \
>  		      (void)(obj) /* Only to avoid unused-but-set-variable warning */, \
> -		      (new_obj_state) = (__state)->private_objs[__i].new_state, 1); \
> +		      (new_obj_state) = (__state)->private_objs[__i].new_state, \
> +		      (void)(new_obj_state) /* Only to avoid unused-but-set-variable warning */, 1); \
>  	     (__i)++)
>  
>  /**
>   * drm_atomic_crtc_needs_modeset - compute combined modeset need
>   * @state: &drm_crtc_state for the CRTC
> 
> -- 
> 2.53.0
> 

-- 
Simona Vetter
Software Engineer
http://blog.ffwll.ch

  reply	other threads:[~2026-05-21  9:51 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-23 10:18 [PATCH v2 00/28] drm: Implement state readout support Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 01/28] drm/atomic: Fix unused but set warning in state iterator macros Maxime Ripard
2026-05-21  9:51   ` Simona Vetter [this message]
2026-04-23 10:18 ` [PATCH v2 02/28] drm/atomic_helper: Skip over NULL private_obj pointers Maxime Ripard
2026-05-21  9:49   ` Simona Vetter
2026-04-23 10:18 ` [PATCH v2 03/28] drm/atomic_state_helper: Remove memset in __drm_atomic_helper_bridge_reset() Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 04/28] drm/atomic: Convert drm_priv_to_bridge_state to container_of_const Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 05/28] drm/atomic: Add drm_private_obj name Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 06/28] drm/bridge: Add drm_private_obj_is_bridge() Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 07/28] drm/bridge: Implement atomic_print_state Maxime Ripard
2026-04-24 14:13   ` Jani Nikula
2026-04-23 10:18 ` [PATCH v2 08/28] drm/atomic: Export drm_atomic_*_print_state Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 09/28] drm/atomic: Only call atomic_destroy_state on a !NULL pointer Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 10/28] drm/atomic_sro: Create drm_atomic_sro_state container Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 11/28] drm/atomic_sro: Create kernel parameter to force or disable readout Maxime Ripard
2026-05-21 10:51   ` Simona Vetter
2026-06-09 14:59     ` Simona Vetter
2026-04-23 10:18 ` [PATCH v2 12/28] drm/atomic_sro: Add atomic state readout infrastructure Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 13/28] drm/atomic_sro: Add function to install state into drm objects Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 14/28] drm/atomic_sro: Create documentation Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 15/28] drm/bridge: Handle bridges with hardware state readout Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 16/28] drm/mode_config: Read out hardware state in drm_mode_config_create_state Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 17/28] drm/atomic_sro: Provide helpers to implement hardware state readout Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 18/28] drm/atomic_helper: Pass nonblock to commit_tail Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 19/28] drm/atomic_helper: Compare actual and readout states once the commit is done Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 20/28] drm/atomic_state_helper: Provide comparison macros Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 21/28] drm/atomic_state_helper: Provide atomic_compare_state helpers Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 22/28] drm/encoder: Create atomic_sro_get_current_crtc hook Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 23/28] drm/bridge: display-connector: Implement readout support Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 24/28] drm/bridge_connector: Implement hw readout for connector Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 25/28] drm/tidss: dispc: Improve mode checking logs Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 26/28] drm/tidss: Implement readout support Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 27/28] drm/tidss: encoder: Implement atomic_sro_get_current_crtc Maxime Ripard
2026-04-23 10:18 ` [PATCH v2 28/28] drm/bridge: sii902x: Implement hw state readout Maxime Ripard
  -- strict thread matches above, loose matches on Subject: below --
2026-04-23 10:06 [PATCH v2 00/28] drm: Implement state readout support Maxime Ripard
2026-04-23 10:06 ` [PATCH v2 01/28] drm/atomic: Fix unused but set warning in state iterator macros Maxime Ripard

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=ag7VjBeFQ1Q7tTr9@phenom.ffwll.local \
    --to=simona.vetter@ffwll.ch \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=devarsht@ti.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=jyri.sarha@iki.fi \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tomi.valkeinen@ideasonboard.com \
    --cc=tzimmermann@suse.de \
    /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

Powered by JetHome