[PATCH] drm: drm_printer: add __printf validation
Joe Perches
joe at perches.com
Wed Feb 15 23:33:18 UTC 2017
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 at 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
More information about the dri-devel
mailing list