Skip to contentSkip to conversation

fs/fat - fix sparse warning

PATCH Ben Dooks 4 participants 5 messages Oct 31, 2005 – Nov 2, 2005 VFAT/FAT/msdos filesystem

lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

move fat_cache_init/fat_cache_destroy to a common header file in fs/fat so that inode.c and cache.c see the same definition, and to stop warnings from sparse about undeclared functions

fs/fat/cache.c +2 -0
diff -urpN -X ../dontdiff linux-2.6.14-git3/fs/fat/cache.c linux-2.6.14-git3-bjd1/fs/fat/cache.c
@@ -12,6 +12,8 @@
 #include <linux/msdos_fs.h>
 #include <linux/buffer_head.h>
 
+#include "cache.h"
+
 /* this must be > 0. */
 #define FAT_MAX_CACHE	8
 
fs/fat/cache.h +8 -0
diff -urpN -X ../dontdiff linux-2.6.14-git3/fs/fat/cache.h linux-2.6.14-git3-bjd1/fs/fat/cache.h
@@ -0,0 +1,8 @@
+/*  linux/fs/fat/cache.h
+ *
+ *  Written 1992,1993 by Werner Almesberger
+ *	header, 2005, Ben Dooks
+*/
+
+extern int __init fat_cache_init(void);
+extern void fat_cache_destroy(void);
fs/fat/inode.c +2 -3
diff -urpN -X ../dontdiff linux-2.6.14-git3/fs/fat/inode.c linux-2.6.14-git3-bjd1/fs/fat/inode.c
@@ -24,6 +24,8 @@
 #include <linux/parser.h>
 #include <asm/unaligned.h>
 
+#include "cache.h"
+
 #ifndef CONFIG_FAT_DEFAULT_IOCHARSET
 /* if user don't select VFAT, this is undefined. */
 #define CONFIG_FAT_DEFAULT_IOCHARSET	""
@@ -1346,9 +1348,6 @@ out_fail:
 
 EXPORT_SYMBOL(fat_fill_super);
 
-int __init fat_cache_init(void);
-void fat_cache_destroy(void);
-
 static int __init init_fat_fs(void)
 {
 	int err;
fs/fat/cache.c +2 -0
diff -urpN -X ../dontdiff linux-2.6.14-git3/fs/fat/cache.c linux-2.6.14-git3-bjd1/fs/fat/cache.c
@@ -12,6 +12,8 @@
 #include <linux/msdos_fs.h>
 #include <linux/buffer_head.h>
 
+#include "cache.h"
+
 /* this must be > 0. */
 #define FAT_MAX_CACHE	8
 
fs/fat/cache.h +8 -0
diff -urpN -X ../dontdiff linux-2.6.14-git3/fs/fat/cache.h linux-2.6.14-git3-bjd1/fs/fat/cache.h
@@ -0,0 +1,8 @@
+/*  linux/fs/fat/cache.h
+ *
+ *  Written 1992,1993 by Werner Almesberger
+ *	header, 2005, Ben Dooks
+*/
+
+extern int __init fat_cache_init(void);
+extern void fat_cache_destroy(void);
fs/fat/inode.c +2 -3
diff -urpN -X ../dontdiff linux-2.6.14-git3/fs/fat/inode.c linux-2.6.14-git3-bjd1/fs/fat/inode.c
@@ -24,6 +24,8 @@
 #include <linux/parser.h>
 #include <asm/unaligned.h>
 
+#include "cache.h"
+
 #ifndef CONFIG_FAT_DEFAULT_IOCHARSET
 /* if user don't select VFAT, this is undefined. */
 #define CONFIG_FAT_DEFAULT_IOCHARSET	""
@@ -1346,9 +1348,6 @@ out_fail:
 
 EXPORT_SYMBOL(fat_fill_super);
 
-int __init fat_cache_init(void);
-void fat_cache_destroy(void);
-
 static int __init init_fat_fs(void)
 {
 	int err;
#1 lore raw

fs/fat/cache.h line 1

Quoted 9 lines · Ben Dooks

move fat_cache_init/fat_cache_destroy to a common header file in fs/fat so that inode.c and cache.c see the same definition, and to stop warnings from sparse about undeclared functions

fs/fat/cache.h +1 -0
@@ -0,0 +1,8 @@
+/*  linux/fs/fat/cache.h

Every editor can show the name of the current file.

fs/fat/cache.h line 5

Quoted 4 lines
fs/fat/cache.h +4 -0
+ *
+ *  Written 1992,1993 by Werner Almesberger
+ *	header, 2005, Ben Dooks
+*/

Too much for two-line file.

fs/fat/cache.h line 8

Quoted 3 lines
fs/fat/cache.h +3 -0
+
+extern int __init fat_cache_init(void);
+extern void fat_cache_destroy(void);

Where did you pick up "extern"? Prototypes in *.c don't have it.

maintainer
#2 lore raw
In reply to Ben Dooks
Quoted 4 lines · Ben Dooks

move fat_cache_init/fat_cache_destroy to a common header file in fs/fat so that inode.c and cache.c see the same definition, and to stop warnings from sparse about undeclared functions

The fs/fat/* has many internal functions, it is in include/linux/msdos_fs.h. Please move those internal functions to one internal header (probably fs/fat/fat.h?).

This seems be just for sparse, please do real cleanup instead.

Signature · 1 line
OGAWA Hirofumi <[email protected]>
#3 lore raw
Quoted 7 lines · OGAWA Hirofumi
Quoted 4 lines · Ben Dooks

move fat_cache_init/fat_cache_destroy to a common header file in fs/fat so that inode.c and cache.c see the same definition, and to stop warnings from sparse about undeclared functions

Quoted 5 lines

The fs/fat/* has many internal functions, it is in include/linux/msdos_fs.h. Please move those internal functions to one internal header (probably fs/fat/fat.h?).

This seems be just for sparse, please do real cleanup instead.

It's not only for sparse.

The -Wmissing-prototypes flag to gcc gives similar warnings, and I'm also cleaning up code for adding this flag to the CFLAGS.

Why?

It sometimes happens that the signature of a function changes and it is forgotten to update all prototypes.

If the prototype is in a header file, gcc tells about the mistake.

If the prototype is in the C file gcc can't help us and it might take some time until someone tracks the source of the nasty runtime problems this might cause.

It's your choice as subsystem maintainer which header file the prototypes should go into - it is only important that both the file with the actual function and all users of this function #include this header.

Quoted 1 line

OGAWA Hirofumi <[email protected]>

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
maintainer
#4 lore raw
Quoted 5 lines · Adrian Bunk

It sometimes happens that the signature of a function changes and it is forgotten to update all prototypes.

If the prototype is in a header file, gcc tells about the mistake.

Quoted 7 lines

If the prototype is in the C file gcc can't help us and it might take some time until someone tracks the source of the nasty runtime problems this might cause.

It's your choice as subsystem maintainer which header file the prototypes should go into - it is only important that both the file with the actual function and all users of this function #include this header.

Sounds reasonable, although that's unlikely, because those are init/exit functions. OK, I'll do this in header cleanup as soon as possible.

Thanks.

Signature · 1 line
OGAWA Hirofumi <[email protected]>