public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix spurious gcc warnings
@ 2008-11-12 11:47 Christoph Hellwig
  2008-11-21 18:05 ` Eric Sandeen
  2008-11-21 23:09 ` Josef 'Jeff' Sipek
  0 siblings, 2 replies; 4+ messages in thread
From: Christoph Hellwig @ 2008-11-12 11:47 UTC (permalink / raw)
  To: xfs

Some recent gcc warnings don't like passing string variables to
printf-like functions without using at least a "%s" format string.
Chaneg the two occurances of that in xfs to please gcc.


Signed-off-by: Christoph Hellwig <hch@lst.de>

fs/xfs/linux-2.6/xfs_stats.c: In function "xfs_read_xfssta":
fs/xfs/linux-2.6/xfs_stats.c:64: warning: format not a string literal and no format arguments
fs/xfs/linux-2.6/xfs_super.c: In function "init_xfs_fs":
fs/xfs/linux-2.6/xfs_super.c:1833: warning: format not a string literal and no format arguments

Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_stats.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_stats.c	2008-11-12 11:12:49.000000000 +0100
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_stats.c	2008-11-12 11:13:05.000000000 +0100
@@ -61,7 +61,7 @@ xfs_read_xfsstats(
 
 	/* Loop over all stats groups */
 	for (i=j=len = 0; i < ARRAY_SIZE(xstats); i++) {
-		len += sprintf(buffer + len, xstats[i].desc);
+		len += sprintf(buffer + len, "%s", xstats[i].desc);
 		/* inner loop does each group */
 		while (j < xstats[i].endpoint) {
 			val = 0;
Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.c	2008-11-12 11:13:11.000000000 +0100
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c	2008-11-12 11:13:43.000000000 +0100
@@ -1827,10 +1827,9 @@ STATIC int __init
 init_xfs_fs(void)
 {
 	int			error;
-	static char		message[] __initdata = KERN_INFO \
-		XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled\n";
 
-	printk(message);
+	printk(KERN_INFO XFS_VERSION_STRING " with "
+			 XFS_BUILD_OPTIONS " enabled\n");
 
 	ktrace_init(64);
 	vn_init();

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

* Re: [PATCH] fix spurious gcc warnings
  2008-11-12 11:47 [PATCH] fix spurious gcc warnings Christoph Hellwig
@ 2008-11-21 18:05 ` Eric Sandeen
  2008-11-21 23:09 ` Josef 'Jeff' Sipek
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Sandeen @ 2008-11-21 18:05 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

Christoph Hellwig wrote:
> Some recent gcc warnings don't like passing string variables to
> printf-like functions without using at least a "%s" format string.
> Chaneg the two occurances of that in xfs to please gcc.

Looks fine to me (might re-spell "Chaneg" though ;) )

-Eric

> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> fs/xfs/linux-2.6/xfs_stats.c: In function "xfs_read_xfssta":
> fs/xfs/linux-2.6/xfs_stats.c:64: warning: format not a string literal and no format arguments
> fs/xfs/linux-2.6/xfs_super.c: In function "init_xfs_fs":
> fs/xfs/linux-2.6/xfs_super.c:1833: warning: format not a string literal and no format arguments
> 
> Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_stats.c
> ===================================================================
> --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_stats.c	2008-11-12 11:12:49.000000000 +0100
> +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_stats.c	2008-11-12 11:13:05.000000000 +0100
> @@ -61,7 +61,7 @@ xfs_read_xfsstats(
>  
>  	/* Loop over all stats groups */
>  	for (i=j=len = 0; i < ARRAY_SIZE(xstats); i++) {
> -		len += sprintf(buffer + len, xstats[i].desc);
> +		len += sprintf(buffer + len, "%s", xstats[i].desc);
>  		/* inner loop does each group */
>  		while (j < xstats[i].endpoint) {
>  			val = 0;
> Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c
> ===================================================================
> --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_super.c	2008-11-12 11:13:11.000000000 +0100
> +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_super.c	2008-11-12 11:13:43.000000000 +0100
> @@ -1827,10 +1827,9 @@ STATIC int __init
>  init_xfs_fs(void)
>  {
>  	int			error;
> -	static char		message[] __initdata = KERN_INFO \
> -		XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled\n";
>  
> -	printk(message);
> +	printk(KERN_INFO XFS_VERSION_STRING " with "
> +			 XFS_BUILD_OPTIONS " enabled\n");
>  
>  	ktrace_init(64);
>  	vn_init();
> 
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH] fix spurious gcc warnings
  2008-11-12 11:47 [PATCH] fix spurious gcc warnings Christoph Hellwig
  2008-11-21 18:05 ` Eric Sandeen
@ 2008-11-21 23:09 ` Josef 'Jeff' Sipek
  2008-11-21 23:12   ` Christoph Hellwig
  1 sibling, 1 reply; 4+ messages in thread
From: Josef 'Jeff' Sipek @ 2008-11-21 23:09 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: xfs

On Wed, Nov 12, 2008 at 06:47:38AM -0500, Christoph Hellwig wrote:
> Some recent gcc warnings don't like passing string variables to
> printf-like functions without using at least a "%s" format string.
> Chaneg the two occurances of that in xfs to please gcc.
> 
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> fs/xfs/linux-2.6/xfs_stats.c: In function "xfs_read_xfssta":
> fs/xfs/linux-2.6/xfs_stats.c:64: warning: format not a string literal and no format arguments
> fs/xfs/linux-2.6/xfs_super.c: In function "init_xfs_fs":
> fs/xfs/linux-2.6/xfs_super.c:1833: warning: format not a string literal and no format arguments
> 
> Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_stats.c
> ===================================================================
> --- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_stats.c	2008-11-12 11:12:49.000000000 +0100
> +++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_stats.c	2008-11-12 11:13:05.000000000 +0100
> @@ -61,7 +61,7 @@ xfs_read_xfsstats(
>  
>  	/* Loop over all stats groups */
>  	for (i=j=len = 0; i < ARRAY_SIZE(xstats); i++) {
> -		len += sprintf(buffer + len, xstats[i].desc);
> +		len += sprintf(buffer + len, "%s", xstats[i].desc);

Why not use strcpy here?

Josef 'Jeff' Sipek.

--
Real Programmers consider "what you see is what you get" to be just as bad a
concept in Text Editors as it is in women. No, the Real Programmer wants a
"you asked for it, you got it" text editor -- complicated, cryptic,
powerful, unforgiving, dangerous.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: [PATCH] fix spurious gcc warnings
  2008-11-21 23:09 ` Josef 'Jeff' Sipek
@ 2008-11-21 23:12   ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2008-11-21 23:12 UTC (permalink / raw)
  To: Josef 'Jeff' Sipek; +Cc: Christoph Hellwig, xfs

On Fri, Nov 21, 2008 at 06:09:48PM -0500, Josef 'Jeff' Sipek wrote:
> >  	for (i=j=len = 0; i < ARRAY_SIZE(xstats); i++) {
> > -		len += sprintf(buffer + len, xstats[i].desc);
> > +		len += sprintf(buffer + len, "%s", xstats[i].desc);
> 
> Why not use strcpy here?

I applies the principle of minimal change.  strcpy would work, too and
be a tidbit more efficient.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2008-11-21 23:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-12 11:47 [PATCH] fix spurious gcc warnings Christoph Hellwig
2008-11-21 18:05 ` Eric Sandeen
2008-11-21 23:09 ` Josef 'Jeff' Sipek
2008-11-21 23:12   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox