gfs2-utils: Clean up leftover prog_name globals
PATCH 1/1 gfs2-utils: Clean up leftover prog_name globals
Since commit a37669 "libgfs2: Move prog_name out of the library" libgfs2 no longer requires an external prog_name in each tool which uses it. This patch rids prog_name from those tools which still provide it.
--- gfs2/convert/gfs2_convert.c | 1 - gfs2/edit/hexedit.h | 1 - gfs2/fsck/main.c | 1 - gfs2/mkfs/gfs2_mkfs.h | 2 -- gfs2/mkfs/main.c | 5 +---- gfs2/mkfs/main_jadd.c | 6 +++--- gfs2/mkfs/main_mkfs.c | 10 ++++------ gfs2/mount/mount.gfs2.c | 9 +++------ gfs2/mount/mtab.c | 1 - gfs2/mount/util.c | 1 - gfs2/mount/util.h | 5 ++--- gfs2/quota/gfs2_quota.h | 2 -- gfs2/quota/main.c | 10 +++------- gfs2/tool/gfs2_tool.h | 1 - gfs2/tool/main.c | 3 --- group/gfs_control/main.c | 10 ++++------ 16 files changed, 20 insertions(+), 48 deletions(-)
gfs2/convert/gfs2_convert.c +0 -1
@@ -131,7 +131,6 @@ int seconds;struct timeval tv;uint64_t dirs_fixed;uint64_t dirents_fixed; -const char *prog_name ="gfs2_convert" ;/* needed by libgfs2 */ struct gfs1_jindex *sd_jindex =NULL ;/* gfs1 journal index in memory */ int gfs2_inptrs;uint64_t gfs2_heightsize[GFS2_MAX_META_HEIGHT ];
gfs2/edit/hexedit.h +0 -1
@@ -42,7 +42,6 @@ enum dsp_mode { HEX_MODE = 0, GFS2_MODE = 1, EXTENDED_MODE = 2 };#define GFS_LOG_DESC_Q (402)/* quota */ #define GFS_LOG_DESC_LAST (500)/* final in a logged transaction */ -extern char *prog_name;extern uint64_t block;extern int blockhist;extern int edit_mode;
gfs2/fsck/main.c +0 -1
@@ -26,7 +26,6 @@ int errors_found = 0, errors_corrected = 0;const char *pass ="" ;uint64_t last_data_block;uint64_t first_data_block; -const char *prog_name ="gfs2_fsck" ;/* needed by libgfs2 */ /* This function is for libgfs2's sake. */ void print_it (const char *label,const char *fmt,const char *fmt2, ...)
gfs2/mkfs/gfs2_mkfs.h +0 -2
@@ -64,6 +64,4 @@ void main_shrink(int argc, char *argv[]);#define FS_FL_USER_VISIBLE 0x0003DFFF/* User visible flags */ #define FS_FL_USER_MODIFIABLE 0x000380FF/* User modifiable flags */ -extern char *prog_name; -#endif /* __GFS2_MKFS_DOT_H__ */
gfs2/mkfs/main.c +1 -4
@@ -17,8 +17,6 @@#include "libgfs2.h" #include "gfs2_mkfs.h" -char *prog_name; -/** * main - do everything * @argc:
@@ -35,10 +33,9 @@ main(int argc, char *argv[])setlocale (LC_ALL ,"" );textdomain ("gfs2-utils" ); - prog_name = argv[0 ];srandom (time (NULL ) ^getpid ()); - p =strdup (prog_name); + p =strdup (argv[0 ]); whoami =basename (p);if (!strcmp (whoami,"gfs2_jadd" ))
gfs2/mkfs/main_jadd.c +3 -3
@@ -63,10 +63,10 @@ rename2system(struct gfs2_sbd *sdp, const char *new_dir, const char *new_name)/** * print_usage - print out usage information -* +* @prog_name: The name of this program */ -static void print_usage (void ) +static void print_usage (const char *prog_name) { printf( _("Usage:\n\n" "%s [options] /path/to/filesystem\n\n"
@@ -104,7 +104,7 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp) sdp->debug = TRUE;break ;case 'h' : -print_usage (); +print_usage (argv[0 ]);exit (0 );break ;case 'J' :
gfs2/mkfs/main_mkfs.c +4 -6
@@ -21,8 +21,6 @@#include "gfs2_mkfs.h" #include "libvolume_id.h" -char *prog_name; -/** * This function is for libgfs2's sake. */
@@ -38,11 +36,11 @@ void print_it(const char *label, const char *fmt, const char *fmt2, ...)/** * print_usage - print out usage information -* +* @prog_name: The name of this program */ static void -print_usage (void ) +print_usage (const char *prog_name) { printf( _("Usage:\n\n" "%s [options] <device> [ block-count ]\n\n"
@@ -96,7 +94,7 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)break ;case 'h' : -print_usage (); +print_usage (argv[0 ]);exit (0 );break ;
@@ -523,7 +521,7 @@ void main_mkfs(int argc, char *argv[]) sdp->orig_fssize >>=GFS2_BASIC_BLOCK_SHIFT ;if (sdp->orig_fssize > sdp->device.length) {fprintf (stderr,_ ("%s: Specified block count is bigger " -"than the actual device.\n" ), prog_name); +"than the actual device.\n" ), argv[0 ]);die (_ ("Device Size is %.2f GB (%" PRIu64" blocks)\n" ), real_device_size / ((float )(1 <<30 )), real_device_size / sdp->bsize);
gfs2/mount/mount.gfs2.c +3 -6
@@ -1,6 +1,5 @@#include "util.h" -const char *prog_name;const char *fsname;int verbose, fake_mount =0 , no_mtab =0 ;static sigset_t old_sigset;
@@ -165,12 +164,10 @@ int main(int argc, char **argv)memset (&mo,0 ,sizeof (mo));memset (&sb,0 ,sizeof (sb)); - prog_name = argv[0 ]; +if (!strstr (argv[0 ],"gfs" )) +die ("invalid mount helper name \"%s\"\n" , argv[0 ]); -if (!strstr (prog_name,"gfs" )) -die ("invalid mount helper name \"%s\"\n" , prog_name); - - fsname = (strstr (prog_name,"gfs2" )) ?"gfs2" :"gfs" ; + fsname = (strstr (argv[0 ],"gfs2" )) ?"gfs2" :"gfs" ;strcpy (mo.type, fsname);if (argc <2 ) {
gfs2/mount/mtab.c +0 -1
@@ -1,6 +1,5 @@#include "util.h" -extern char *prog_name;extern char *fsname;extern int verbose;static int ignoring_mtab;
gfs2/mount/util.c +0 -1
@@ -43,7 +43,6 @@#endif /* __BYTE_ORDER == __LITTLE_ENDIAN */ -extern char *prog_name;extern char *fsname;extern int verbose;
gfs2/mount/util.h +2 -3
@@ -23,20 +23,19 @@ #define die(fmt, args...) \ do { \ - fprintf(stderr, "%s: ", prog_name); \ fprintf(stderr, fmt, ##args); \ exit(EXIT_FAILURE); \ } while (0) #define warn(fmt, args...) \ do { \ - fprintf(stderr, "%s: " fmt "\n", prog_name, ##args); \ + fprintf(stderr, fmt "\n", ##args); \ } while (0) #define log_debug(fmt, args...) \ do { \ if (verbose) \ - printf("%s: " fmt "\n", prog_name, ##args); \ + printf(fmt "\n", ##args); \ } while (0)#define do_read (fd, buff, len) \
gfs2/quota/gfs2_quota.h +0 -2
@@ -58,8 +58,6 @@ struct commandline { };typedef struct commandline commandline_t ; -extern char *prog_name; -/* main.c */ void do_get_super (int fd,struct gfs2_sb *sb);
gfs2/quota/main.c +3 -7
@@ -29,8 +29,6 @@#define OPTION_STRING ("bdf:g:hkl:mnsu:V") -char *prog_name; -/** * This function is for libgfs2's sake. */
@@ -46,11 +44,11 @@ void print_it(const char *label, const char *fmt, const char *fmt2, ...)/** * print_usage - print usage info to the user -* +* @prog_name: The name of this program */ static void -print_usage (void ) +print_usage (const char *prog_name) {printf ("Usage:\n" );printf ("\n" );
@@ -153,7 +151,7 @@ decode_arguments(int argc, char *argv[], commandline_t *comline)break ;case 'h' : -print_usage (); +print_usage (argv[0 ]);exit (EXIT_SUCCESS );break ;
@@ -1032,8 +1030,6 @@ main(int argc, char *argv[])struct gfs2_sbd sbd, *sdp = &sbd;commandline_t comline; - prog_name = argv[0 ]; -memset (sdp,0 ,sizeof (struct gfs2_sbd ));memset (&comline,0 ,sizeof (commandline_t));
gfs2/tool/gfs2_tool.h +0 -1
@@ -6,7 +6,6 @@#define OUTPUT_K 1#define OUTPUT_HUMAN 2 -extern char *prog_name;extern char *action;extern int override;extern int expert;
gfs2/tool/main.c +0 -3
@@ -19,7 +19,6 @@#include "gfs2_tool.h" #include "libgfs2.h" -char *prog_name;char *action =NULL ;int override = FALSE;int expert = FALSE;
@@ -157,8 +156,6 @@ static void decode_arguments(int argc, char *argv[])int main (int argc,char *argv[]) { - prog_name = argv[0 ]; -setlocale (LC_ALL ,"" );textdomain ("gfs2-utils" );
group/gfs_control/main.c +4 -6
@@ -23,7 +23,6 @@#define OP_LEAVE 5#define OP_JOINLEAVE 6 -static char *prog_name;static char *fsname;static int operation;static int opt_ind;
@@ -36,7 +35,7 @@ struct gfsc_mountgroup mgs[MAX_MG];struct gfsc_node nodes[MAX_NODES ]; -static void print_usage (void ) +static void print_usage (const char *prog_name) {printf ("Usage:\n" );printf ("\n" );
@@ -64,13 +63,13 @@ static void decode_arguments(int argc, char **argv)break ;case 'h' : -print_usage (); +print_usage (argv[0 ]);exit (EXIT_SUCCESS );break ;case 'V' :printf ("%s %s (built %s %s)\n" , - prog_name,RELEASE_VERSION , __DATE__, __TIME__); + argv[0 ],RELEASE_VERSION , __DATE__, __TIME__);/* printf("%s\n", REDHAT_COPYRIGHT); */ exit (EXIT_SUCCESS );break ;
@@ -124,7 +123,7 @@ static void decode_arguments(int argc, char **argv) }if (!operation || !opt_ind) { -print_usage (); +print_usage (argv[0 ]);exit (EXIT_FAILURE ); }
@@ -439,7 +438,6 @@ static void do_dump(void)int main (int argc,char **argv) { - prog_name = argv[0 ];decode_arguments (argc, argv);switch (operation) {
Signature · 1 line
1.6.2.4
PATCH 1/1 gfs2-utils: Clean up leftover prog_name globals
Quoted 15 lines · Andrew Price
Since commit a37669 "libgfs2: Move
prog_nameout of the library" libgfs2 no longer requires an externalprog_namein each tool which uses it. This patch ridsprog_namefrom those tools which still provide it.Signed-off-by Andrew Price <[email protected]>--- gfs2/convert/gfs2_convert.c | 1 - gfs2/edit/hexedit.h | 1 - gfs2/fsck/main.c | 1 - gfs2/mkfs/gfs2_mkfs.h | 2 -- gfs2/mkfs/main.c | 5 +---- gfs2/mkfs/main_jadd.c | 6 +++--- gfs2/mkfs/main_mkfs.c | 10 ++++------ gfs2/mount/mount.gfs2.c | 9 +++------ gfs2/mount/mtab.c | 1 -
Quoted 9 lines
gfs2/mount/util.c | 1 - gfs2/mount/util.h | 5 ++--- gfs2/quota/gfs2_quota.h | 2 -- gfs2/quota/main.c | 10 +++------- gfs2/tool/gfs2_tool.h | 1 - gfs2/tool/main.c | 3 --- group/gfs_control/main.c | 10 ++++------ 16 files changed, 20 insertions(+), 48 deletions(-)
Looks good to me.
Please push it to master and STABLE3.
Thanks
Fabio
PATCH 1/1 gfs2-utils: Clean up leftover prog_name globals
In reply to Andrew PriceHi,
Looks good to me,
Steve.
Quoted 389 lines · Andrew Price
Since commit a37669 "libgfs2: Move
prog_nameout of the library" libgfs2 no longer requires an externalprog_namein each tool which uses it. This patch ridsprog_namefrom those tools which still provide it.Signed-off-by Andrew Price <[email protected]>--- gfs2/convert/gfs2_convert.c | 1 - gfs2/edit/hexedit.h | 1 - gfs2/fsck/main.c | 1 - gfs2/mkfs/gfs2_mkfs.h | 2 -- gfs2/mkfs/main.c | 5 +---- gfs2/mkfs/main_jadd.c | 6 +++--- gfs2/mkfs/main_mkfs.c | 10 ++++------ gfs2/mount/mount.gfs2.c | 9 +++------ gfs2/mount/mtab.c | 1 - gfs2/mount/util.c | 1 - gfs2/mount/util.h | 5 ++--- gfs2/quota/gfs2_quota.h | 2 -- gfs2/quota/main.c | 10 +++------- gfs2/tool/gfs2_tool.h | 1 - gfs2/tool/main.c | 3 --- group/gfs_control/main.c | 10 ++++------ 16 files changed, 20 insertions(+), 48 deletions(-)gfs2/convert/gfs2_convert.c +0
-1@@ -131,7 +131,6 @@ int seconds;struct timeval tv;uint64_t dirs_fixed;uint64_t dirents_fixed; -const char *prog_name ="gfs2_convert" ;/* needed by libgfs2 */ struct gfs1_jindex *sd_jindex =NULL ;/* gfs1 journal index in memory */ int gfs2_inptrs;uint64_t gfs2_heightsize[GFS2_MAX_META_HEIGHT ];gfs2/edit/hexedit.h +0
-1@@ -42,7 +42,6 @@ enum dsp_mode { HEX_MODE = 0, GFS2_MODE = 1, EXTENDED_MODE = 2 };#define GFS_LOG_DESC_Q (402)/* quota */ #define GFS_LOG_DESC_LAST (500)/* final in a logged transaction */ -extern char *prog_name;extern uint64_t block;extern int blockhist;extern int edit_mode;gfs2/fsck/main.c +0
-1@@ -26,7 +26,6 @@ int errors_found = 0, errors_corrected = 0;const char *pass ="" ;uint64_t last_data_block;uint64_t first_data_block; -const char *prog_name ="gfs2_fsck" ;/* needed by libgfs2 */ /* This function is for libgfs2's sake. */ void print_it (const char *label,const char *fmt,const char *fmt2, ...)gfs2/mkfs/gfs2_mkfs.h +0
-2@@ -64,6 +64,4 @@ void main_shrink(int argc, char *argv[]);#define FS_FL_USER_VISIBLE 0x0003DFFF/* User visible flags */ #define FS_FL_USER_MODIFIABLE 0x000380FF/* User modifiable flags */ -extern char *prog_name; -#endif /* __GFS2_MKFS_DOT_H__ */ gfs2/mkfs/main.c +1
-4@@ -17,8 +17,6 @@#include "libgfs2.h" #include "gfs2_mkfs.h" -char *prog_name; -/** * main - do everything * @argc: @@ -35,10 +33,9 @@ main(int argc, char *argv[])setlocale (LC_ALL ,"" );textdomain ("gfs2-utils" ); - prog_name = argv[0 ];srandom (time (NULL ) ^getpid ()); - p =strdup (prog_name); + p =strdup (argv[0 ]); whoami =basename (p);if (!strcmp (whoami,"gfs2_jadd" ))gfs2/mkfs/main_jadd.c +3
-3@@ -63,10 +63,10 @@ rename2system(struct gfs2_sbd *sdp, const char *new_dir, const char *new_name)/** * print_usage - print out usage information -* +* @prog_name: The name of this program */ -static void print_usage (void ) +static void print_usage (const char *prog_name) { printf( _("Usage:\n\n" "%s [options] /path/to/filesystem\n\n"@@ -104,7 +104,7 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp) sdp->debug = TRUE;break ;case 'h' : -print_usage (); +print_usage (argv[0 ]);exit (0 );break ;case 'J' :gfs2/mkfs/main_mkfs.c +4
-6@@ -21,8 +21,6 @@#include "gfs2_mkfs.h" #include "libvolume_id.h" -char *prog_name; -/** * This function is for libgfs2's sake. */ @@ -38,11 +36,11 @@ void print_it(const char *label, const char *fmt, const char *fmt2, ...)/** * print_usage - print out usage information -* +* @prog_name: The name of this program */ static void -print_usage (void ) +print_usage (const char *prog_name) { printf( _("Usage:\n\n" "%s [options] <device> [ block-count ]\n\n"@@ -96,7 +94,7 @@ static void decode_arguments(int argc, char *argv[], struct gfs2_sbd *sdp)break ;case 'h' : -print_usage (); +print_usage (argv[0 ]);exit (0 );break ;@@ -523,7 +521,7 @@ void main_mkfs(int argc, char *argv[]) sdp->orig_fssize >>=GFS2_BASIC_BLOCK_SHIFT ;if (sdp->orig_fssize > sdp->device.length) {fprintf (stderr,_ ("%s: Specified block count is bigger " -"than the actual device.\n" ), prog_name); +"than the actual device.\n" ), argv[0 ]);die (_ ("Device Size is %.2f GB (%" PRIu64" blocks)\n" ), real_device_size / ((float )(1 <<30 )), real_device_size / sdp->bsize);gfs2/mount/mount.gfs2.c +3
-6@@ -1,6 +1,5 @@#include "util.h" -const char *prog_name;const char *fsname;int verbose, fake_mount =0 , no_mtab =0 ;static sigset_t old_sigset;@@ -165,12 +164,10 @@ int main(int argc, char **argv)memset (&mo,0 ,sizeof (mo));memset (&sb,0 ,sizeof (sb)); - prog_name = argv[0 ]; +if (!strstr (argv[0 ],"gfs" )) +die ("invalid mount helper name \"%s\"\n" , argv[0 ]); -if (!strstr (prog_name,"gfs" )) -die ("invalid mount helper name \"%s\"\n" , prog_name); - - fsname = (strstr (prog_name,"gfs2" )) ?"gfs2" :"gfs" ; + fsname = (strstr (argv[0 ],"gfs2" )) ?"gfs2" :"gfs" ;strcpy (mo.type, fsname);if (argc <2 ) {gfs2/mount/mtab.c +0
-1@@ -1,6 +1,5 @@#include "util.h" -extern char *prog_name;extern char *fsname;extern int verbose;static int ignoring_mtab;gfs2/mount/util.c +0
-1@@ -43,7 +43,6 @@#endif /* __BYTE_ORDER == __LITTLE_ENDIAN */ -extern char *prog_name;extern char *fsname;extern int verbose;gfs2/mount/util.h +2
-3@@ -23,20 +23,19 @@ #define die(fmt, args...) \ do { \ - fprintf(stderr, "%s: ", prog_name); \ fprintf(stderr, fmt, ##args); \ exit(EXIT_FAILURE); \ } while (0) #define warn(fmt, args...) \ do { \ - fprintf(stderr, "%s: " fmt "\n", prog_name, ##args); \ + fprintf(stderr, fmt "\n", ##args); \ } while (0) #define log_debug(fmt, args...) \ do { \ if (verbose) \ - printf("%s: " fmt "\n", prog_name, ##args); \ + printf(fmt "\n", ##args); \ } while (0)#define do_read (fd, buff, len) \gfs2/quota/gfs2_quota.h +0
-2@@ -58,8 +58,6 @@ struct commandline { };typedef struct commandline commandline_t ; -extern char *prog_name; -/* main.c */ void do_get_super (int fd,struct gfs2_sb *sb);gfs2/quota/main.c +3
-7@@ -29,8 +29,6 @@#define OPTION_STRING ("bdf:g:hkl:mnsu:V") -char *prog_name; -/** * This function is for libgfs2's sake. */ @@ -46,11 +44,11 @@ void print_it(const char *label, const char *fmt, const char *fmt2, ...)/** * print_usage - print usage info to the user -* +* @prog_name: The name of this program */ static void -print_usage (void ) +print_usage (const char *prog_name) {printf ("Usage:\n" );printf ("\n" );@@ -153,7 +151,7 @@ decode_arguments(int argc, char *argv[], commandline_t *comline)break ;case 'h' : -print_usage (); +print_usage (argv[0 ]);exit (EXIT_SUCCESS );break ;@@ -1032,8 +1030,6 @@ main(int argc, char *argv[])struct gfs2_sbd sbd, *sdp = &sbd;commandline_t comline; - prog_name = argv[0 ]; -memset (sdp,0 ,sizeof (struct gfs2_sbd ));memset (&comline,0 ,sizeof (commandline_t));gfs2/tool/gfs2_tool.h +0
-1@@ -6,7 +6,6 @@#define OUTPUT_K 1#define OUTPUT_HUMAN 2 -extern char *prog_name;extern char *action;extern int override;extern int expert;gfs2/tool/main.c +0
-3@@ -19,7 +19,6 @@#include "gfs2_tool.h" #include "libgfs2.h" -char *prog_name;char *action =NULL ;int override = FALSE;int expert = FALSE;@@ -157,8 +156,6 @@ static void decode_arguments(int argc, char *argv[])int main (int argc,char *argv[]) { - prog_name = argv[0 ]; -setlocale (LC_ALL ,"" );textdomain ("gfs2-utils" );group/gfs_control/main.c +4
-6@@ -23,7 +23,6 @@#define OP_LEAVE 5#define OP_JOINLEAVE 6 -static char *prog_name;static char *fsname;static int operation;static int opt_ind;@@ -36,7 +35,7 @@ struct gfsc_mountgroup mgs[MAX_MG];struct gfsc_node nodes[MAX_NODES ]; -static void print_usage (void ) +static void print_usage (const char *prog_name) {printf ("Usage:\n" );printf ("\n" );@@ -64,13 +63,13 @@ static void decode_arguments(int argc, char **argv)break ;case 'h' : -print_usage (); +print_usage (argv[0 ]);exit (EXIT_SUCCESS );break ;case 'V' :printf ("%s %s (built %s %s)\n" , - prog_name,RELEASE_VERSION , __DATE__, __TIME__); + argv[0 ],RELEASE_VERSION , __DATE__, __TIME__);/* printf("%s\n", REDHAT_COPYRIGHT); */ exit (EXIT_SUCCESS );break ;@@ -124,7 +123,7 @@ static void decode_arguments(int argc, char **argv) }if (!operation || !opt_ind) { -print_usage (); +print_usage (argv[0 ]);exit (EXIT_FAILURE ); }@@ -439,7 +438,6 @@ static void do_dump(void)int main (int argc,char **argv) { - prog_name = argv[0 ];decode_arguments (argc, argv);switch (operation) {