[PATCH 03/29] drm/atomic: Fix unused but set warning in for_each_old_private_obj_in_state

Maxime Ripard posted 29 patches 1 month ago
[PATCH 03/29] drm/atomic: Fix unused but set warning in for_each_old_private_obj_in_state
Posted by Maxime Ripard 1 month ago
The for_each_old_private_obj_in_state() macro triggers a compiler
warning if the obj parameter passed to it isn't used in the code block.

Add a similar workaround than in most other macros.

Signed-off-by: Maxime Ripard <mripard@kernel.org>
---
 include/drm/drm_atomic.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 689a29bdeb4a06672ab6fffecb513d58ff6e07f9..f13f926d21047e42bb9ac692c2dd4b88f2ebd91c 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -1112,10 +1112,11 @@ 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, \
+		      (void)(obj) /* Only to avoid unused-but-set-variable warning */, \
 		      (old_obj_state) = (__state)->private_objs[__i].old_state, 1); \
 	     (__i)++)
 
 /**
  * for_each_new_private_obj_in_state - iterate over all private objects in an atomic update

-- 
2.50.1
Re: [PATCH 03/29] drm/atomic: Fix unused but set warning in for_each_old_private_obj_in_state
Posted by Laurent Pinchart 1 month ago
Hi Maxime,

Thank you for the patch.

On Tue, Sep 02, 2025 at 10:32:31AM +0200, Maxime Ripard wrote:
> The for_each_old_private_obj_in_state() macro triggers a compiler
> warning if the obj parameter passed to it isn't used in the code block.
> 
> Add a similar workaround than in most other macros.
> 

I'd squash this with the previous patch, and also address the other
similar macros.

> Signed-off-by: Maxime Ripard <mripard@kernel.org>
> ---
>  include/drm/drm_atomic.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index 689a29bdeb4a06672ab6fffecb513d58ff6e07f9..f13f926d21047e42bb9ac692c2dd4b88f2ebd91c 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -1112,10 +1112,11 @@ 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, \
> +		      (void)(obj) /* Only to avoid unused-but-set-variable warning */, \
>  		      (old_obj_state) = (__state)->private_objs[__i].old_state, 1); \
>  	     (__i)++)
>  
>  /**
>   * for_each_new_private_obj_in_state - iterate over all private objects in an atomic update

-- 
Regards,

Laurent Pinchart
Re: [PATCH 03/29] drm/atomic: Fix unused but set warning in for_each_old_private_obj_in_state
Posted by Thomas Zimmermann 1 month ago

Am 02.09.25 um 10:32 schrieb Maxime Ripard:
> The for_each_old_private_obj_in_state() macro triggers a compiler
> warning if the obj parameter passed to it isn't used in the code block.
>
> Add a similar workaround than in most other macros.
>
> Signed-off-by: Maxime Ripard <mripard@kernel.org>

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>   include/drm/drm_atomic.h | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index 689a29bdeb4a06672ab6fffecb513d58ff6e07f9..f13f926d21047e42bb9ac692c2dd4b88f2ebd91c 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -1112,10 +1112,11 @@ 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, \
> +		      (void)(obj) /* Only to avoid unused-but-set-variable warning */, \
>   		      (old_obj_state) = (__state)->private_objs[__i].old_state, 1); \
>   	     (__i)++)
>   
>   /**
>    * for_each_new_private_obj_in_state - iterate over all private objects in an atomic update
>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)