libfsimage, pygrub, python: cleanup
PATCH 1/1 libfsimage, pygrub, python: cleanup
Hi!
Attached patch makes functions static which have no prototypes in libfsimage, pygrub and in python.
It also adds prototypes to exported symbols.
Signature · 12 lines
AMD Saxony, Dresden, Germany Operating System Research Center Legal Information: AMD Saxony Limited Liability Company & Co. KG Sitz (Geschäftsanschrift): Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland Registergericht Dresden: HRA 4896 vertretungsberechtigter Komplementär: AMD Saxony LLC (Sitz Wilmington, Delaware, USA) Geschäftsführer der AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy
tools/libfsimage/ext2fs/fsys_ext2fs.c +6 -3
@@ -281,7 +281,7 @@ struct ext2_dir_entry#define S_ISDIR (m) (((m) & S_IFMT) == S_IFDIR)/* check filesystem types and read superblock into memory buffer */ -int +static int ext2fs_mount (fsi_file_t *ffi,const char *options) {int retval =1 ;
@@ -419,7 +419,7 @@ ext2fs_block_map (fsi_file_t *ffi, int l }/* preconditions: all preconds of ext2fs_block_map */ -int +static int ext2fs_read (fsi_file_t *ffi,char *buf,int len) {int logical_block;
@@ -526,7 +526,7 @@ int ext2_is_fast_symlink (fsi_file_t *ff* inode of the file we were trying to look up * side effects: messes up GROUP_DESC buffer area */ -int +static int ext2fs_dir (fsi_file_t *ffi,char *dirname) {int current_ino =EXT2_ROOT_INO ;/* start at the root */
@@ -818,6 +818,9 @@ ext2fs_dir (fsi_file_t *ffi, char *dirna }fsi_plugin_ops_t * +fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name); + +fsi_plugin_ops_t *fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name) {static fsig_plugin_ops_t ops = {
tools/libfsimage/fat/fsys_fat.c +6 -3
@@ -54,7 +54,7 @@ struct fat_superblock#define log2 grub_log2 -int +static int fat_mount (fsi_file_t *ffi,const char *options) {struct fat_bpb bpb;
@@ -179,7 +179,7 @@ fat_mount (fsi_file_t *ffi, const char *return 1 ; } -int +static int fat_read (fsi_file_t *ffi,char *buf,int len) {int logical_clust;
@@ -273,7 +273,7 @@ fat_read (fsi_file_t *ffi, char *buf, inreturn errnum ?0 : ret; } -int +static int fat_dir (fsi_file_t *ffi,char *dirname) {char *rest, ch, dir_buf[FAT_DIRENTRY_LENGTH ];
@@ -471,6 +471,9 @@ fat_dir (fsi_file_t *ffi, char *dirname) }fsi_plugin_ops_t * +fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name); + +fsi_plugin_ops_t *fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name) {static fsig_plugin_ops_t ops = {
tools/libfsimage/iso9660/fsys_iso9660.c +6 -3
@@ -101,7 +101,7 @@ iso9660_devread (fsi_file_t *ffi, int sereturn devread (ffi, sector, byte_offset, byte_len, buf); } -int +static int iso9660_mount (fsi_file_t *ffi,const char *options) {unsigned int sector;
@@ -141,7 +141,7 @@ iso9660_mount (fsi_file_t *ffi, const chreturn 0 ; } -int +static int iso9660_dir (fsi_file_t *ffi,char *dirname) {struct iso_directory_record *idr;
@@ -413,7 +413,7 @@ iso9660_dir (fsi_file_t *ffi, char *dirnreturn 1 ; } -int +static int iso9660_read (fsi_file_t *ffi,char *buf,int len) {int sector, blkoffset, size, ret;
@@ -449,6 +449,9 @@ iso9660_read (fsi_file_t *ffi, char *buf }fsi_plugin_ops_t * +fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name); + +fsi_plugin_ops_t *fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name) {static fsig_plugin_ops_t ops = {
tools/libfsimage/reiserfs/fsys_reiserfs.c +9 -3
@@ -555,7 +555,7 @@ journal_init (fsi_file_t *ffi) }/* check filesystem types and read superblock into memory buffer */ -int +static int reiserfs_mount (fsi_file_t *ffi,const char *options) {struct reiserfs_super_block super;
@@ -872,7 +872,7 @@ search_stat (fsi_file_t *ffi, __u32 dir_return 0 ; } -int +static int reiserfs_read (fsi_file_t *ffi,char *buf,int len) {unsigned int blocksize;
@@ -980,7 +980,7 @@ reiserfs_read (fsi_file_t *ffi, char *bu* of the file we were trying to look up, filepos is 0 and filemax is * the size of the file. */ -int +static int reiserfs_dir (fsi_file_t *ffi,char *dirname) {struct reiserfs_de_head *de_head;
@@ -1202,6 +1202,9 @@ reiserfs_dir (fsi_file_t *ffi, char *dir }int +reiserfs_embed (fsi_file_t *ffi,int *start_sector,int needed_sectors); + +int reiserfs_embed (fsi_file_t *ffi,int *start_sector,int needed_sectors) {struct reiserfs_super_block super;
@@ -1227,6 +1230,9 @@ reiserfs_embed (fsi_file_t *ffi, int *st }fsi_plugin_ops_t * +fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name); + +fsi_plugin_ops_t *fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name) {static fsig_plugin_ops_t ops = {
tools/libfsimage/ufs/fsys_ufs.c +9 -3
@@ -44,7 +44,7 @@ static grub_daddr32_t sbmap(fsi_file_t *static grub_daddr32_t sbmap (fsi_file_t *,grub_daddr32_t );/* read superblock and check fs magic */ -int +static int ufs_mount (fsi_file_t *ffi,const char *options) { if (/*! IS_PC_SLICE_TYPE_SOLARIS(current_slice) || */
@@ -62,7 +62,7 @@ ufs_mount(fsi_file_t *ffi, const char *o* The entry point should really be named ufs_open(char *pathname). * For now, keep it consistent with the rest of fsys modules. */ -int +static int ufs_dir (fsi_file_t *ffi,char *dirname) {grub_ino_t inode =ROOTINO ;/* start from root */
@@ -102,7 +102,7 @@ ufs_dir(fsi_file_t *ffi, char *dirname)/* * This is the high-level read function. */ -int +static int ufs_read (fsi_file_t *ffi,char *buf,int len) {int off, size, ret =0 , ok;
@@ -135,6 +135,9 @@ ufs_read(fsi_file_t *ffi, char *buf, intreturn (ret); } + +int +ufs_embed (int *start_sector,int needed_sectors);int ufs_embed (int *start_sector,int needed_sectors)
@@ -264,6 +267,9 @@ dlook(fsi_file_t *ffi, grub_ino_t dir_in }fsi_plugin_ops_t * +fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name); + +fsi_plugin_ops_t *fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name) {static fsig_plugin_ops_t ops = {
tools/libfsimage/zfs/fsys_zfs.c +9 -3
@@ -1199,7 +1199,7 @@ check_pool_label(fsi_file_t *ffi, int la* 1 - success * 0 - failure */ -int +static int zfs_mount (fsi_file_t *ffi,const char *options) {char *stack;
@@ -1284,7 +1284,7 @@ zfs_mount(fsi_file_t *ffi, const char *o* 1 - success * 0 - failure */ -int +static int zfs_open (fsi_file_t *ffi,char *filename) {char *stack;
@@ -1377,7 +1377,7 @@ zfs_open(fsi_file_t *ffi, char *filename* len - the length successfully read in to the buffer * 0 - failure */ -int +static int zfs_read (fsi_file_t *ffi,char *buf,int len) {char *stack;
@@ -1437,10 +1437,16 @@ zfs_read(fsi_file_t *ffi, char *buf, int* No-Op */ int +zfs_embed (int *start_sector,int needed_sectors); + +int zfs_embed (int *start_sector,int needed_sectors) {return (1 ); } + +fsi_plugin_ops_t * +fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name);fsi_plugin_ops_t *fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name)
tools/pygrub/src/fsimage/fsimage.c +3 -2
@@ -316,8 +316,9 @@ static struct PyMethodDef fsimage_module { NULL, NULL, 0, NULL } }; -PyMODINIT_FUNC -initfsimage (void ) +PyMODINIT_FUNC initfsimage (void ); + +PyMODINIT_FUNC initfsimage (void ) {Py_InitModule ("fsimage" , fsimage_module_methods); }
tools/python/ptsname/ptsname.c +2 -0
@@ -38,6 +38,8 @@ static PyMethodDef ptsname_methods[] = { { NULL } }; +PyMODINIT_FUNC initptsname (void ); +PyMODINIT_FUNC initptsname (void ) {Py_InitModule ("ptsname" , ptsname_methods);
tools/python/xen/lowlevel/acm/acm.c +3 -1
@@ -40,7 +40,7 @@ static PyObject *acm_error_obj;static PyObject *acm_error_obj;/* generic shared function */ -void *__getssid (int domid,uint32_t *buflen) +static void *__getssid (int domid,uint32_t *buflen) {struct acm_getssid getssid;int xc_handle;
@@ -355,6 +355,8 @@ static PyMethodDef acmMethods[] = { };/* inits */ +PyMODINIT_FUNC initacm (void ); +PyMODINIT_FUNC initacm (void ) {PyObject *m =Py_InitModule ("acm" , acmMethods);
tools/python/xen/lowlevel/flask/flask.c +2 -0
@@ -124,6 +124,8 @@ static PyMethodDef pyflask_methods[] = { { NULL, NULL, 0, NULL } }; +PyMODINIT_FUNC initflask (void ); +PyMODINIT_FUNC initflask (void ) {Py_InitModule ("flask" , pyflask_methods);
tools/python/xen/lowlevel/xc/xc.c +2 -0
@@ -2000,6 +2000,8 @@ static PyTypeObject PyXcType = {static PyMethodDef xc_methods[] = { {NULL } }; +PyMODINIT_FUNC initxc (void ); +PyMODINIT_FUNC initxc (void ) {PyObject *m;
tools/python/xen/lowlevel/xs/xs.c +2 -0
@@ -959,6 +959,8 @@ static PyTypeObject xshandle_type = {static PyMethodDef xs_methods[] = { {NULL } }; +PyMODINIT_FUNC initxs (void ); +PyMODINIT_FUNC initxs (void ) {PyObject * m;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
tools/libfsimage/ext2fs/fsys_ext2fs.c ext2fs_dir (fsi_file_t *ffi, char *dirna · line 824
Quoted 5 lines · Christoph Egger
fsi_plugin_ops_t*tools/libfsimage/ext2fs/fsys_ext2fs.c +3
-0+fsi_init_plugin(int version, fsi_plugin_t *fp, const char **name); + +fsi_plugin_ops_t *fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name)
Huh? If some GCC option is insisting on this, it's a stupid option and shouldn't be enabled.
regards
john
John Levon writes ("Re: [Xen-devel] [PATCH][TOOLS] libfsimage, pygrub, python: cleanup"):
Quoted 9 lines · [someone]
tools/libfsimage/ext2fs/fsys_ext2fs.c ext2fs_dir (fsi_file_t *ffi, char *dirna · line 824
Quoted 5 lines
fsi_plugin_ops_t*tools/libfsimage/ext2fs/fsys_ext2fs.c +3
-0+fsi_init_plugin(int version, fsi_plugin_t *fp, const char **name); + +fsi_plugin_ops_t *fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name)Huh? If some GCC option is insisting on this, it's a stupid option and shouldn't be enabled.
This is the result of (a) -Wmissing-prototypes, which is sensible and (b) the submitter missing the point.
The purpose of -Wmissing-prototypes is to spot this situation:
a.h: double function(void);
b.c: #include "a.h"
double some_caller(void) { return function(); } a.c: int function(void) { return 1; }
The result of this is undefined behaviour, and neither the compiler nor the linker will spot it. If you pass -Wmissing-prototypes, then the compiler will complain in a.c that there was no prototype for function in scope.
This is supposed to clue you in to the missing #include. You are supposed to change a.c to this
a.c: #include "a.h"
int function(void) { return 1; }and now the compiler will tell you that your definition and declaration of function do not match.
However if you don't understand this, you may do what the submitter of this patch did, which is to change a.c to read like this:
a.c: int function(void);
int function(void) { return 1; }This completely defeats the point of -Wmissing-prototypes; I think it's just wrong.
Ian.
Quoted 1 line · On Friday 18 July 2008 16:10:13 Ian Jackson wrote:
John Levon writes ("Re: [Xen-devel] [PATCH][TOOLS] libfsimage, pygrub,
python: cleanup"):
Quoted 36 lines
Quoted 9 lines · [someone]
tools/libfsimage/ext2fs/fsys_ext2fs.c ext2fs_dir (fsi_file_t *ffi, char *dirna · line 824
Quoted 5 lines
fsi_plugin_ops_t*tools/libfsimage/ext2fs/fsys_ext2fs.c +3
-0+fsi_init_plugin(int version, fsi_plugin_t *fp, const char **name); + +fsi_plugin_ops_t *fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name)Huh? If some GCC option is insisting on this, it's a stupid option and shouldn't be enabled.
This is the result of (a) -Wmissing-prototypes, which is sensible and (b) the submitter missing the point.
The purpose of -Wmissing-prototypes is to spot this situation:
a.h: double function(void);
b.c: #include "a.h"double some_caller(void) { return function(); }
a.c: int function(void) { return 1; }The result of this is undefined behaviour, and neither the compiler nor the linker will spot it. If you pass -Wmissing-prototypes, then the compiler will complain in
a.cthat there was no prototype for function in scope.This is supposed to clue you in to the missing #include. You are supposed to change
a.cto this
a.c: #include "a.h"int function(void) { return 1; }and now the compiler will tell you that your definition and declaration of function do not match.
Quoted 8 lines
However if you don't understand this, you may do what the submitter of this patch did, which is to change
a.cto read like this:a.c: int function(void); int function(void) { return 1; }This completely defeats the point of -Wmissing-prototypes; I think it's just wrong.
When the submitter understands this, but misses a header where to put the prototype into, then he tends to do so as a quick work around. However, the submitter fully agrees, this belongs into a new header. He is just asking what is the right directory and how to name the new header filename.
Christoph
Signature · 12 lines
AMD Saxony, Dresden, Germany Operating System Research Center Legal Information: AMD Saxony Limited Liability Company & Co. KG Sitz (Geschäftsanschrift): Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland Registergericht Dresden: HRA 4896 vertretungsberechtigter Komplementär: AMD Saxony LLC (Sitz Wilmington, Delaware, USA) Geschäftsführer der AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy
Quoted 7 lines · Ian Jackson
Quoted 5 lines
tools/libfsimage/ext2fs/fsys_ext2fs.c ext2fs_dir (fsi_file_t *ffi, char *dirna · line 824
Quoted 5 lines
fsi_plugin_ops_t*tools/libfsimage/ext2fs/fsys_ext2fs.c +3
-0+fsi_init_plugin(int version, fsi_plugin_t *fp, const char **name); + +fsi_plugin_ops_t *fsi_init_plugin (int version,fsi_plugin_t *fp,const char **name)The purpose of -Wmissing-prototypes is to spot this situation:
Indeed.
Quoted 8 lines
However if you don't understand this, you may do what the submitter of this patch did, which is to change
a.cto read like this:a.c: int function(void); int function(void) { return 1; }This completely defeats the point of -Wmissing-prototypes; I think it's just wrong.
It doesn't even make sense for the compiler to warn about the above though. It's not called anywhere (that the compiler can detect:
certainly not in that C file).
regards
john
Quoted 5 lines · Christoph Egger
When the submitter understands this, but misses a header where to put the prototype into, then he tends to do so as a quick work around. However, the submitter fully agrees, this belongs into a new header. He is just asking what is the right directory and how to name the new header filename.
I think the convention is to call all new headers "xen.h", and have it include some subset of the other xen.hs in a confusing fashion.
J