diff mbox series

drm/connector: Fix warning in debug message

Message ID 20190624084016.12937-1-maxime.ripard@bootlin.com (mailing list archive)
State New, archived
Headers show
Series drm/connector: Fix warning in debug message | expand

Commit Message

Maxime Ripard June 24, 2019, 8:40 a.m. UTC
The commit 3aeeb13d8996 ("drm/modes: Support modes names on the command
line") added name support to the DRM modes, and added that name to the
debug message.

However, that code tests for whether or not the name variable is NULL and
only prints it if it's not. Except that that variable is an array, so it
will never be NULL.

The original intent was to print it only when the name has been specified.
Just printing the array directly will achieve the same thing since the
drm_cmdline_mode structure that holds it is itself contained in
drm_connector, that is allocated with its whole content zero'd.

That means that if the name is not declared, the array will be all zeros,
which will not print anything.

Cc: Nick Desaulniers <ndesaulniers@google.com>
Reported-by: kbuild test robot <lkp@intel.com>
Fixes: 3aeeb13d8996 ("drm/modes: Support modes names on the command line")
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 drivers/gpu/drm/drm_connector.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Daniel Vetter June 24, 2019, 8:44 a.m. UTC | #1
On Mon, Jun 24, 2019 at 10:40:16AM +0200, Maxime Ripard wrote:
> The commit 3aeeb13d8996 ("drm/modes: Support modes names on the command
> line") added name support to the DRM modes, and added that name to the
> debug message.
> 
> However, that code tests for whether or not the name variable is NULL and
> only prints it if it's not. Except that that variable is an array, so it
> will never be NULL.
> 
> The original intent was to print it only when the name has been specified.
> Just printing the array directly will achieve the same thing since the
> drm_cmdline_mode structure that holds it is itself contained in
> drm_connector, that is allocated with its whole content zero'd.
> 
> That means that if the name is not declared, the array will be all zeros,
> which will not print anything.
> 
> Cc: Nick Desaulniers <ndesaulniers@google.com>
> Reported-by: kbuild test robot <lkp@intel.com>
> Fixes: 3aeeb13d8996 ("drm/modes: Support modes names on the command line")
> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> ---
>  drivers/gpu/drm/drm_connector.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 3afed5677946..068d4b05f1be 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -140,8 +140,7 @@ static void drm_connector_get_cmdline_mode(struct drm_connector *connector)
>  	}
>  
>  	DRM_DEBUG_KMS("cmdline mode for connector %s %s %dx%d@%dHz%s%s%s\n",
> -		      connector->name,
> -		      mode->name ? mode->name : "",
> +		      connector->name, mode->name,
>  		      mode->xres, mode->yres,
>  		      mode->refresh_specified ? mode->refresh : 60,
>  		      mode->rb ? " reduced blanking" : "",
> -- 
> 2.21.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Maxime Ripard June 24, 2019, 1:41 p.m. UTC | #2
On Mon, Jun 24, 2019 at 10:44:33AM +0200, Daniel Vetter wrote:
> On Mon, Jun 24, 2019 at 10:40:16AM +0200, Maxime Ripard wrote:
> > The commit 3aeeb13d8996 ("drm/modes: Support modes names on the command
> > line") added name support to the DRM modes, and added that name to the
> > debug message.
> >
> > However, that code tests for whether or not the name variable is NULL and
> > only prints it if it's not. Except that that variable is an array, so it
> > will never be NULL.
> >
> > The original intent was to print it only when the name has been specified.
> > Just printing the array directly will achieve the same thing since the
> > drm_cmdline_mode structure that holds it is itself contained in
> > drm_connector, that is allocated with its whole content zero'd.
> >
> > That means that if the name is not declared, the array will be all zeros,
> > which will not print anything.
> >
> > Cc: Nick Desaulniers <ndesaulniers@google.com>
> > Reported-by: kbuild test robot <lkp@intel.com>
> > Fixes: 3aeeb13d8996 ("drm/modes: Support modes names on the command line")
> > Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Applied,

Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 3afed5677946..068d4b05f1be 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -140,8 +140,7 @@  static void drm_connector_get_cmdline_mode(struct drm_connector *connector)
 	}
 
 	DRM_DEBUG_KMS("cmdline mode for connector %s %s %dx%d@%dHz%s%s%s\n",
-		      connector->name,
-		      mode->name ? mode->name : "",
+		      connector->name, mode->name,
 		      mode->xres, mode->yres,
 		      mode->refresh_specified ? mode->refresh : 60,
 		      mode->rb ? " reduced blanking" : "",