diff mbox series

[v2] drm: atomic helper: fix W=1 warnings

Message ID 20191008124254.2144-1-benjamin.gaignard@st.com (mailing list archive)
State New, archived
Headers show
Series [v2] drm: atomic helper: fix W=1 warnings | expand

Commit Message

Benjamin GAIGNARD Oct. 8, 2019, 12:42 p.m. UTC
Few for_each macro set variables that are never used later which led
to generate unused-but-set-variable warnings.
Add (void)(foo) inside the macros to remove these warnings

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
---
 include/drm/drm_atomic.h | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

Comments

Benjamin Gaignard Oct. 21, 2019, 6:56 p.m. UTC | #1
Le mer. 9 oct. 2019 à 09:13, Benjamin Gaignard
<benjamin.gaignard@st.com> a écrit :
>
> Few for_each macro set variables that are never used later which led
> to generate unused-but-set-variable warnings.
> Add (void)(foo) inside the macros to remove these warnings
>

Gentle ping,
Thanks,
Benjamin

> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
> ---
>  include/drm/drm_atomic.h | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index 927e1205d7aa..b6c73fd9f55a 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -693,6 +693,7 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>              (__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))
>
> @@ -714,6 +715,7 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>              (__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))
>
>  /**
> @@ -734,7 +736,9 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>              (__i)++)                                                           \
>                 for_each_if ((__state)->connectors[__i].ptr &&                  \
>                              ((connector) = (__state)->connectors[__i].ptr,     \
> -                            (new_connector_state) = (__state)->connectors[__i].new_state, 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
> @@ -754,7 +758,9 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>              (__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, 1))
>
>  /**
> @@ -793,7 +799,9 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>              (__i)++)                                                   \
>                 for_each_if ((__state)->crtcs[__i].ptr &&               \
>                              ((crtc) = (__state)->crtcs[__i].ptr,       \
> -                            (new_crtc_state) = (__state)->crtcs[__i].new_state, 1))
> +                            (void)(crtc) /* 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_oldnew_plane_in_state - iterate over all planes in an atomic update
> @@ -813,6 +821,7 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>              (__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))
>
> @@ -873,7 +882,9 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>              (__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_oldnew_private_obj_in_state - iterate over all private objects in an atomic update
> --
> 2.15.0
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Daniel Vetter Oct. 22, 2019, 8:37 a.m. UTC | #2
On Tue, Oct 08, 2019 at 02:42:54PM +0200, Benjamin Gaignard wrote:
> Few for_each macro set variables that are never used later which led
> to generate unused-but-set-variable warnings.
> Add (void)(foo) inside the macros to remove these warnings
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>

OCD in me would lean towards annotating all of them, unconditionally, and
be done. But I guess this works too. Either way:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  include/drm/drm_atomic.h | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index 927e1205d7aa..b6c73fd9f55a 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -693,6 +693,7 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	     (__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))
>  
> @@ -714,6 +715,7 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	     (__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))
>  
>  /**
> @@ -734,7 +736,9 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	     (__i)++)								\
>  		for_each_if ((__state)->connectors[__i].ptr &&			\
>  			     ((connector) = (__state)->connectors[__i].ptr,	\
> -			     (new_connector_state) = (__state)->connectors[__i].new_state, 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
> @@ -754,7 +758,9 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	     (__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, 1))
>  
>  /**
> @@ -793,7 +799,9 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	     (__i)++)							\
>  		for_each_if ((__state)->crtcs[__i].ptr &&		\
>  			     ((crtc) = (__state)->crtcs[__i].ptr,	\
> -			     (new_crtc_state) = (__state)->crtcs[__i].new_state, 1))
> +			     (void)(crtc) /* 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_oldnew_plane_in_state - iterate over all planes in an atomic update
> @@ -813,6 +821,7 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	     (__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))
>  
> @@ -873,7 +882,9 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
>  	     (__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_oldnew_private_obj_in_state - iterate over all private objects in an atomic update
> -- 
> 2.15.0
>
Benjamin Gaignard Nov. 7, 2019, 10:10 a.m. UTC | #3
Le mar. 22 oct. 2019 à 10:37, Daniel Vetter <daniel@ffwll.ch> a écrit :
>
> On Tue, Oct 08, 2019 at 02:42:54PM +0200, Benjamin Gaignard wrote:
> > Few for_each macro set variables that are never used later which led
> > to generate unused-but-set-variable warnings.
> > Add (void)(foo) inside the macros to remove these warnings
> >
> > Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
>
> OCD in me would lean towards annotating all of them, unconditionally, and
> be done. But I guess this works too. Either way:
>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Thanks,

Applied to drm-misc-next
Benjamin

> > ---
> >  include/drm/drm_atomic.h | 17 ++++++++++++++---
> >  1 file changed, 14 insertions(+), 3 deletions(-)
> >
> > diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> > index 927e1205d7aa..b6c73fd9f55a 100644
> > --- a/include/drm/drm_atomic.h
> > +++ b/include/drm/drm_atomic.h
> > @@ -693,6 +693,7 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
> >            (__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))
> >
> > @@ -714,6 +715,7 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
> >            (__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))
> >
> >  /**
> > @@ -734,7 +736,9 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
> >            (__i)++)                                                           \
> >               for_each_if ((__state)->connectors[__i].ptr &&                  \
> >                            ((connector) = (__state)->connectors[__i].ptr,     \
> > -                          (new_connector_state) = (__state)->connectors[__i].new_state, 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
> > @@ -754,7 +758,9 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
> >            (__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, 1))
> >
> >  /**
> > @@ -793,7 +799,9 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
> >            (__i)++)                                                   \
> >               for_each_if ((__state)->crtcs[__i].ptr &&               \
> >                            ((crtc) = (__state)->crtcs[__i].ptr,       \
> > -                          (new_crtc_state) = (__state)->crtcs[__i].new_state, 1))
> > +                          (void)(crtc) /* 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_oldnew_plane_in_state - iterate over all planes in an atomic update
> > @@ -813,6 +821,7 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
> >            (__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))
> >
> > @@ -873,7 +882,9 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
> >            (__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_oldnew_private_obj_in_state - iterate over all private objects in an atomic update
> > --
> > 2.15.0
> >
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 927e1205d7aa..b6c73fd9f55a 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -693,6 +693,7 @@  void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
 	     (__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))
 
@@ -714,6 +715,7 @@  void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
 	     (__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))
 
 /**
@@ -734,7 +736,9 @@  void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
 	     (__i)++)								\
 		for_each_if ((__state)->connectors[__i].ptr &&			\
 			     ((connector) = (__state)->connectors[__i].ptr,	\
-			     (new_connector_state) = (__state)->connectors[__i].new_state, 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
@@ -754,7 +758,9 @@  void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
 	     (__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, 1))
 
 /**
@@ -793,7 +799,9 @@  void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
 	     (__i)++)							\
 		for_each_if ((__state)->crtcs[__i].ptr &&		\
 			     ((crtc) = (__state)->crtcs[__i].ptr,	\
-			     (new_crtc_state) = (__state)->crtcs[__i].new_state, 1))
+			     (void)(crtc) /* 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_oldnew_plane_in_state - iterate over all planes in an atomic update
@@ -813,6 +821,7 @@  void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
 	     (__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))
 
@@ -873,7 +882,9 @@  void drm_state_dump(struct drm_device *dev, struct drm_printer *p);
 	     (__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_oldnew_private_obj_in_state - iterate over all private objects in an atomic update