linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm: drm_printer: add __printf validation
@ 2017-02-15 23:33 Joe Perches
  2017-02-20 12:17 ` Eric Engestrom
  0 siblings, 1 reply; 8+ messages in thread
From: Joe Perches @ 2017-02-15 23:33 UTC (permalink / raw)
  To: Rob Clark, Daniel Vetter, Jani Nikula, Sean Paul, David Airlie
  Cc: dri-devel, linux-kernel

drm_printf does not currently use the compiler to verify
format and arguments.  Make it do so.

Miscellanea:

o Add appropriate #include files for __printf and struct va_format
o Convert dev_printk to dev_info

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/gpu/drm/drm_print.c | 2 +-
 include/drm/drm_print.h     | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
index 02a107d50706..74c466aca622 100644
--- a/drivers/gpu/drm/drm_print.c
+++ b/drivers/gpu/drm/drm_print.c
@@ -36,7 +36,7 @@ EXPORT_SYMBOL(__drm_printfn_seq_file);
 
 void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf)
 {
-	dev_printk(KERN_INFO, p->arg, "[" DRM_NAME "] %pV", vaf);
+	dev_info(p->arg, "[" DRM_NAME "] %pV", vaf);
 }
 EXPORT_SYMBOL(__drm_printfn_info);
 
diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
index 7d98763c0444..ca4d7c6321f2 100644
--- a/include/drm/drm_print.h
+++ b/include/drm/drm_print.h
@@ -26,6 +26,8 @@
 #ifndef DRM_PRINT_H_
 #define DRM_PRINT_H_
 
+#include <linux/compiler.h>
+#include <linux/printk.h>
 #include <linux/seq_file.h>
 #include <linux/device.h>
 
@@ -75,6 +77,7 @@ void __drm_printfn_seq_file(struct drm_printer *p, struct va_format *vaf);
 void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf);
 void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf);
 
+__printf(2, 3)
 void drm_printf(struct drm_printer *p, const char *f, ...);
 
 
-- 
2.10.0.rc2.1.g053435c

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm: drm_printer: add __printf validation
  2017-02-15 23:33 [PATCH] drm: drm_printer: add __printf validation Joe Perches
@ 2017-02-20 12:17 ` Eric Engestrom
  2017-02-20 17:10   ` Joe Perches
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Engestrom @ 2017-02-20 12:17 UTC (permalink / raw)
  To: Joe Perches
  Cc: Rob Clark, Daniel Vetter, Jani Nikula, Sean Paul, David Airlie,
	linux-kernel, dri-devel

On Wednesday, 2017-02-15 15:33:18 -0800, Joe Perches wrote:
> drm_printf does not currently use the compiler to verify
> format and arguments.  Make it do so.
> 
> Miscellanea:
> 
> o Add appropriate #include files for __printf and struct va_format
> o Convert dev_printk to dev_info

I think these unrelated changes should be in 4 patches:
1 - add annotation to check the format string against the arguments
    (linux/compiler.h should be added here)
2 - add missing linux/printk.h header for struct va_format
    Note that I think a forward declaration is more appropriate here, as
    we only use pointers to this struct in this file, we never try to
    look inside. On the other hand:
3 - drm_print.c needs the header in drm_printf(), but as a separate
    patch
4 - convert dev_printk to dev_info (you need to include linux/device.h
    there)

You can add my r-b on all four patches when you send them to the list :)

Cheers,
  Eric

> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  drivers/gpu/drm/drm_print.c | 2 +-
>  include/drm/drm_print.h     | 3 +++
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
> index 02a107d50706..74c466aca622 100644
> --- a/drivers/gpu/drm/drm_print.c
> +++ b/drivers/gpu/drm/drm_print.c
> @@ -36,7 +36,7 @@ EXPORT_SYMBOL(__drm_printfn_seq_file);
>  
>  void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf)
>  {
> -	dev_printk(KERN_INFO, p->arg, "[" DRM_NAME "] %pV", vaf);
> +	dev_info(p->arg, "[" DRM_NAME "] %pV", vaf);
>  }
>  EXPORT_SYMBOL(__drm_printfn_info);
>  
> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
> index 7d98763c0444..ca4d7c6321f2 100644
> --- a/include/drm/drm_print.h
> +++ b/include/drm/drm_print.h
> @@ -26,6 +26,8 @@
>  #ifndef DRM_PRINT_H_
>  #define DRM_PRINT_H_
>  
> +#include <linux/compiler.h>
> +#include <linux/printk.h>
>  #include <linux/seq_file.h>
>  #include <linux/device.h>
>  
> @@ -75,6 +77,7 @@ void __drm_printfn_seq_file(struct drm_printer *p, struct va_format *vaf);
>  void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf);
>  void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf);
>  
> +__printf(2, 3)
>  void drm_printf(struct drm_printer *p, const char *f, ...);
>  
>  
> -- 
> 2.10.0.rc2.1.g053435c
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm: drm_printer: add __printf validation
  2017-02-20 12:17 ` Eric Engestrom
@ 2017-02-20 17:10   ` Joe Perches
  2017-02-21  8:26     ` Jani Nikula
  0 siblings, 1 reply; 8+ messages in thread
From: Joe Perches @ 2017-02-20 17:10 UTC (permalink / raw)
  To: Eric Engestrom
  Cc: Rob Clark, Daniel Vetter, Jani Nikula, Sean Paul, David Airlie,
	linux-kernel, dri-devel

On Mon, 2017-02-20 at 12:17 +0000, Eric Engestrom wrote:
> On Wednesday, 2017-02-15 15:33:18 -0800, Joe Perches wrote:
> > drm_printf does not currently use the compiler to verify
> > format and arguments.  Make it do so.
> > 
> > Miscellanea:
> > 
> > o Add appropriate #include files for __printf and struct va_format
> > o Convert dev_printk to dev_info
> 
> I think these unrelated changes should be in 4 patches:
> 1 - add annotation to check the format string against the arguments
>     (linux/compiler.h should be added here)
> 2 - add missing linux/printk.h header for struct va_format
>     Note that I think a forward declaration is more appropriate here, as
>     we only use pointers to this struct in this file, we never try to
>     look inside. On the other hand:
> 3 - drm_print.c needs the header in drm_printf(), but as a separate
>     patch
> 4 - convert dev_printk to dev_info (you need to include linux/device.h
>     there)

I am not a big fan of making trivial
patches into a series.

> You can add my r-b on all four patches when you send them to the list :)

If you want to break it up, go ahead.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm: drm_printer: add __printf validation
  2017-02-20 17:10   ` Joe Perches
@ 2017-02-21  8:26     ` Jani Nikula
  2017-02-21  8:32       ` Joe Perches
  0 siblings, 1 reply; 8+ messages in thread
From: Jani Nikula @ 2017-02-21  8:26 UTC (permalink / raw)
  To: Joe Perches, Eric Engestrom
  Cc: Rob Clark, Daniel Vetter, Sean Paul, David Airlie, linux-kernel,
	dri-devel

On Mon, 20 Feb 2017, Joe Perches <joe@perches.com> wrote:
> On Mon, 2017-02-20 at 12:17 +0000, Eric Engestrom wrote:
>> On Wednesday, 2017-02-15 15:33:18 -0800, Joe Perches wrote:
>> > drm_printf does not currently use the compiler to verify
>> > format and arguments.  Make it do so.
>> > 
>> > Miscellanea:
>> > 
>> > o Add appropriate #include files for __printf and struct va_format
>> > o Convert dev_printk to dev_info
>> 
>> I think these unrelated changes should be in 4 patches:
>> 1 - add annotation to check the format string against the arguments
>>     (linux/compiler.h should be added here)
>> 2 - add missing linux/printk.h header for struct va_format
>>     Note that I think a forward declaration is more appropriate here, as
>>     we only use pointers to this struct in this file, we never try to
>>     look inside. On the other hand:
>> 3 - drm_print.c needs the header in drm_printf(), but as a separate
>>     patch
>> 4 - convert dev_printk to dev_info (you need to include linux/device.h
>>     there)
>
> I am not a big fan of making trivial patches into a series.

It's standard procedure in kernel development to split out unrelated
changes into individual patches, regardless of whether you think they
are trivial or not. Four is probably excessive, but you get the idea.

>> You can add my r-b on all four patches when you send them to the list :)
>
> If you want to break it up, go ahead.

You know how this stuff works, please split it up to get the stuff
merged.


BR,
Jani.


-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm: drm_printer: add __printf validation
  2017-02-21  8:26     ` Jani Nikula
@ 2017-02-21  8:32       ` Joe Perches
  2017-02-21  9:02         ` Jani Nikula
  0 siblings, 1 reply; 8+ messages in thread
From: Joe Perches @ 2017-02-21  8:32 UTC (permalink / raw)
  To: Jani Nikula, Eric Engestrom
  Cc: Rob Clark, Daniel Vetter, Sean Paul, David Airlie, linux-kernel,
	dri-devel

On Tue, 2017-02-21 at 10:26 +0200, Jani Nikula wrote:
> You know how this stuff works, please split it up to get the stuff
> merged.

Quite well actually.

Fix it as you think appropriate.
But in any case, fix it.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm: drm_printer: add __printf validation
  2017-02-21  8:32       ` Joe Perches
@ 2017-02-21  9:02         ` Jani Nikula
  2017-02-21  9:18           ` Joe Perches
  0 siblings, 1 reply; 8+ messages in thread
From: Jani Nikula @ 2017-02-21  9:02 UTC (permalink / raw)
  To: Joe Perches, Eric Engestrom
  Cc: Rob Clark, Daniel Vetter, Sean Paul, David Airlie, linux-kernel,
	dri-devel

On Tue, 21 Feb 2017, Joe Perches <joe@perches.com> wrote:
> On Tue, 2017-02-21 at 10:26 +0200, Jani Nikula wrote:
>> You know how this stuff works, please split it up to get the stuff
>> merged.
>
> Quite well actually.
>
> Fix it as you think appropriate.
> But in any case, fix it.

Yes, I'm sure someone will eventually send patches I can apply.

BR,
Jani.

-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm: drm_printer: add __printf validation
  2017-02-21  9:02         ` Jani Nikula
@ 2017-02-21  9:18           ` Joe Perches
  2017-02-26 20:43             ` Daniel Vetter
  0 siblings, 1 reply; 8+ messages in thread
From: Joe Perches @ 2017-02-21  9:18 UTC (permalink / raw)
  To: Jani Nikula, Eric Engestrom
  Cc: Rob Clark, Daniel Vetter, Sean Paul, David Airlie, linux-kernel,
	dri-devel

On Tue, 2017-02-21 at 11:02 +0200, Jani Nikula wrote:
> On Tue, 21 Feb 2017, Joe Perches <joe@perches.com> wrote:
> > On Tue, 2017-02-21 at 10:26 +0200, Jani Nikula wrote:
> > > You know how this stuff works, please split it up to get the stuff
> > > merged.
> > 
> > Quite well actually.
> > 
> > Fix it as you think appropriate.
> > But in any case, fix it.
> 
> Yes, I'm sure someone will eventually send patches I can apply.

As you know it's a defect, you or one
of the other maintainers of that file
should fix it and not wait for what you
consider the ideal patch.

cheers, Joe

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] drm: drm_printer: add __printf validation
  2017-02-21  9:18           ` Joe Perches
@ 2017-02-26 20:43             ` Daniel Vetter
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Vetter @ 2017-02-26 20:43 UTC (permalink / raw)
  To: Joe Perches
  Cc: Jani Nikula, Eric Engestrom, linux-kernel, dri-devel, Daniel Vetter

On Tue, Feb 21, 2017 at 01:18:03AM -0800, Joe Perches wrote:
> On Tue, 2017-02-21 at 11:02 +0200, Jani Nikula wrote:
> > On Tue, 21 Feb 2017, Joe Perches <joe@perches.com> wrote:
> > > On Tue, 2017-02-21 at 10:26 +0200, Jani Nikula wrote:
> > > > You know how this stuff works, please split it up to get the stuff
> > > > merged.
> > > 
> > > Quite well actually.
> > > 
> > > Fix it as you think appropriate.
> > > But in any case, fix it.
> > 
> > Yes, I'm sure someone will eventually send patches I can apply.
> 
> As you know it's a defect, you or one
> of the other maintainers of that file
> should fix it and not wait for what you
> consider the ideal patch.

Yeah, requesting a split-up of this patch seems like a genuine bikeshed.
Merged to drm-misc for 4.12, thanks a lot for your patch.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-02-26 20:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-15 23:33 [PATCH] drm: drm_printer: add __printf validation Joe Perches
2017-02-20 12:17 ` Eric Engestrom
2017-02-20 17:10   ` Joe Perches
2017-02-21  8:26     ` Jani Nikula
2017-02-21  8:32       ` Joe Perches
2017-02-21  9:02         ` Jani Nikula
2017-02-21  9:18           ` Joe Perches
2017-02-26 20:43             ` Daniel Vetter

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).