linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] add gcc printf format checks
@ 2008-01-06 13:51 Helge Deller
  2008-01-06 16:05 ` Joe Perches
  0 siblings, 1 reply; 3+ messages in thread
From: Helge Deller @ 2008-01-06 13:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton

[PATCH] add gcc printf format checks

trivial patch which adds some missing printf format checking to 
compat.h and msdos_fs.h
Build-tested and no regressions found.

Signed-off-by: Helge Deller <deller@gmx.de>


diff --git a/include/linux/compat.h b/include/linux/compat.h
index 0e69d2c..ce2038f 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -232,7 +232,7 @@ extern int put_compat_itimerspec(struct compat_itimerspec __user *dst,
 
 asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
 
-extern int compat_printk(const char *fmt, ...);
+extern int compat_printk(const char *fmt, ...) __printf(1,2);
 extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
 
 asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,

diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h
index f950921..651c265 100644
--- a/include/linux/msdos_fs.h
+++ b/include/linux/msdos_fs.h
@@ -419,7 +419,7 @@ extern int fat_fill_super(struct super_block *sb, void *data, int silent,
 extern int fat_flush_inodes(struct super_block *sb, struct inode *i1,
 		            struct inode *i2);
 /* fat/misc.c */
-extern void fat_fs_panic(struct super_block *s, const char *fmt, ...);
+extern void fat_fs_panic(struct super_block *s, const char *fmt, ...) __printf(2,3);
 extern void fat_clusters_flush(struct super_block *sb);
 extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster);
 extern int date_dos2unix(unsigned short time, unsigned short date);


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

* Re: [PATCH] add gcc printf format checks
  2008-01-06 13:51 [PATCH] add gcc printf format checks Helge Deller
@ 2008-01-06 16:05 ` Joe Perches
       [not found]   ` <200801061858.50975.deller@gmx.de>
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2008-01-06 16:05 UTC (permalink / raw)
  To: Helge Deller; +Cc: linux-kernel, Andrew Morton, Mathieu Desnoyers

On Sun, 2008-01-06 at 14:51 +0100, Helge Deller wrote:
> [PATCH] add gcc printf format checks
> diff --git a/include/linux/compat.h b/include/linux/compat.h
> index 0e69d2c..ce2038f 100644
> --- a/include/linux/compat.h
> +++ b/include/linux/compat.h
> @@ -232,7 +232,7 @@ extern int put_compat_itimerspec(struct compat_itimerspec __user *dst,
>  
>  asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
>  
> -extern int compat_printk(const char *fmt, ...);
> +extern int compat_printk(const char *fmt, ...) __printf(1,2);

__attribute__((format(printf, 1, 2))) seems to be the preferred
form. 91 to 1.

I think __printf should be removed from gcc-compiler.h
and the only use in include/linux/marker.h converted.



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

* Re: [PATCH] add gcc printf format checks
       [not found]   ` <200801061858.50975.deller@gmx.de>
@ 2008-01-07 19:14     ` Mathieu Desnoyers
  0 siblings, 0 replies; 3+ messages in thread
From: Mathieu Desnoyers @ 2008-01-07 19:14 UTC (permalink / raw)
  To: Helge Deller; +Cc: Joe Perches, linux-kernel, Andrew Morton, Robert P. J. Day

* Helge Deller (deller@gmx.de) wrote:
> On Sunday 06 January 2008, Joe Perches wrote:
> > __attribute__((format(printf, 1, 2))) seems to be the preferred
> > form. 91 to 1.
> > 
> > I think __printf should be removed from gcc-compiler.h
> > and the only use in include/linux/marker.h converted.
> 
> Personally I would prefer to convert every user over to the smaller __printf() version.
> Nevertheless, below is an updated patch which does what you propose.
> 
> =======================================
> 
> [PATCH] add gcc printf format checks and drop __printf() define
> 
> Trivial patch which adds some missing printf format checking to 
> compat.h and msdos_fs.h. Additionally, it converts the one and
> only user of the __printf macro to __attribute__ (printf).
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> 
> 
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index fe23792..3579ac8 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -49,7 +49,6 @@
>   */
>  #define __pure				__attribute__((pure))
>  #define __aligned(x)			__attribute__((aligned(x)))
> -#define __printf(a,b)			__attribute__((format(printf,a,b)))
>  #define  noinline			__attribute__((noinline))
>  #define __attribute_const__		__attribute__((__const__))
>  #define __maybe_unused			__attribute__((unused))
> 
> diff --git a/include/linux/marker.h b/include/linux/marker.h
> index 5f36cf9..0fb3f0e 100644
> --- a/include/linux/marker.h
> +++ b/include/linux/marker.h
> @@ -100,7 +100,8 @@ static inline void marker_update_probe_range(struct marker *begin,
>  #define MARK_NOARGS " "
>  
>  /* To be used for string format validity checking with gcc */
> -static inline void __printf(1, 2) __mark_check_format(const char *fmt, ...)
> +static inline void __attribute__((format(printf,1,2)))
> +		   __mark_check_format(const char *fmt, ...)

If the markers are the only user of this macro, it makes sense to change
them and remove the macro. I have no strong opinion about this, but it
is technically ok.

Acked-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>


>  {
>  }
>  
> diff --git a/include/linux/compat.h b/include/linux/compat.h
> index 0e69d2c..6d465ad 100644
> --- a/include/linux/compat.h
> +++ b/include/linux/compat.h
> @@ -232,7 +232,7 @@ extern int put_compat_itimerspec(struct compat_itimerspec __user *dst,
>  
>  asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
>  
> -extern int compat_printk(const char *fmt, ...);
> +extern int compat_printk(const char *fmt, ...) __attribute__ ((format(printf,1,2)));
>  extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
>  
>  asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
> 
> diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h
> index f950921..dd2b6bb 100644
> --- a/include/linux/msdos_fs.h
> +++ b/include/linux/msdos_fs.h
> @@ -419,7 +419,8 @@ extern int fat_fill_super(struct super_block *sb, void *data, int silent,
>  extern int fat_flush_inodes(struct super_block *sb, struct inode *i1,
>  		            struct inode *i2);
>  /* fat/misc.c */
> -extern void fat_fs_panic(struct super_block *s, const char *fmt, ...);
> +extern void fat_fs_panic(struct super_block *s, const char *fmt, ...)
> +		__attribute__ ((format(printf,2,3)));
>  extern void fat_clusters_flush(struct super_block *sb);
>  extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster);
>  extern int date_dos2unix(unsigned short time, unsigned short date);

-- 
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

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

end of thread, other threads:[~2008-01-07 19:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-06 13:51 [PATCH] add gcc printf format checks Helge Deller
2008-01-06 16:05 ` Joe Perches
     [not found]   ` <200801061858.50975.deller@gmx.de>
2008-01-07 19:14     ` Mathieu Desnoyers

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