From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] gfs2-utils: Clean up leftover prog_name globals
Date: Fri, 29 May 2009 08:21:34 +0100 [thread overview]
Message-ID: <1243581694.29604.463.camel@localhost.localdomain> (raw)
In-Reply-To: <1243544836-1946-1-git-send-email-andy@andrewprice.me.uk>
Hi,
Looks good to me,
Steve.
On Thu, 2009-05-28 at 22:07 +0100, Andrew Price wrote:
> 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.
>
> Signed-off-by: Andrew Price <andy@andrewprice.me.uk>
> ---
> 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(-)
>
> diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
> index b7c84e3..2f47f94 100644
> --- a/gfs2/convert/gfs2_convert.c
> +++ b/gfs2/convert/gfs2_convert.c
> @@ -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];
> diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
> index 6977edf..11d4aa3 100644
> --- a/gfs2/edit/hexedit.h
> +++ b/gfs2/edit/hexedit.h
> @@ -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;
> diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
> index 109b686..c4bc927 100644
> --- a/gfs2/fsck/main.c
> +++ b/gfs2/fsck/main.c
> @@ -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, ...)
> diff --git a/gfs2/mkfs/gfs2_mkfs.h b/gfs2/mkfs/gfs2_mkfs.h
> index a058b79..14bf4f6 100644
> --- a/gfs2/mkfs/gfs2_mkfs.h
> +++ b/gfs2/mkfs/gfs2_mkfs.h
> @@ -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__ */
> diff --git a/gfs2/mkfs/main.c b/gfs2/mkfs/main.c
> index bd00317..49a22a4 100644
> --- a/gfs2/mkfs/main.c
> +++ b/gfs2/mkfs/main.c
> @@ -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"))
> diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
> index fc21dc9..55e145b 100644
> --- a/gfs2/mkfs/main_jadd.c
> +++ b/gfs2/mkfs/main_jadd.c
> @@ -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':
> diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
> index efbf912..7d10a23 100644
> --- a/gfs2/mkfs/main_mkfs.c
> +++ b/gfs2/mkfs/main_mkfs.c
> @@ -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);
> diff --git a/gfs2/mount/mount.gfs2.c b/gfs2/mount/mount.gfs2.c
> index f84dfde..2442f59 100644
> --- a/gfs2/mount/mount.gfs2.c
> +++ b/gfs2/mount/mount.gfs2.c
> @@ -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) {
> diff --git a/gfs2/mount/mtab.c b/gfs2/mount/mtab.c
> index 9d6dba1..fe5c744 100644
> --- a/gfs2/mount/mtab.c
> +++ b/gfs2/mount/mtab.c
> @@ -1,6 +1,5 @@
> #include "util.h"
>
> -extern char *prog_name;
> extern char *fsname;
> extern int verbose;
> static int ignoring_mtab;
> diff --git a/gfs2/mount/util.c b/gfs2/mount/util.c
> index 805e8a2..5c86027 100644
> --- a/gfs2/mount/util.c
> +++ b/gfs2/mount/util.c
> @@ -43,7 +43,6 @@
>
> #endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
>
> -extern char *prog_name;
> extern char *fsname;
> extern int verbose;
>
> diff --git a/gfs2/mount/util.h b/gfs2/mount/util.h
> index fe0f83d..7b856ac 100644
> --- a/gfs2/mount/util.h
> +++ b/gfs2/mount/util.h
> @@ -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) \
> diff --git a/gfs2/quota/gfs2_quota.h b/gfs2/quota/gfs2_quota.h
> index 27342f8..462246f 100644
> --- a/gfs2/quota/gfs2_quota.h
> +++ b/gfs2/quota/gfs2_quota.h
> @@ -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);
> diff --git a/gfs2/quota/main.c b/gfs2/quota/main.c
> index 5e2e487..a160897 100644
> --- a/gfs2/quota/main.c
> +++ b/gfs2/quota/main.c
> @@ -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));
>
> diff --git a/gfs2/tool/gfs2_tool.h b/gfs2/tool/gfs2_tool.h
> index 11583a0..884856f 100644
> --- a/gfs2/tool/gfs2_tool.h
> +++ b/gfs2/tool/gfs2_tool.h
> @@ -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;
> diff --git a/gfs2/tool/main.c b/gfs2/tool/main.c
> index b1cdded..2da78a4 100644
> --- a/gfs2/tool/main.c
> +++ b/gfs2/tool/main.c
> @@ -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");
>
> diff --git a/group/gfs_control/main.c b/group/gfs_control/main.c
> index a910efc..e754e81 100644
> --- a/group/gfs_control/main.c
> +++ b/group/gfs_control/main.c
> @@ -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) {
prev parent reply other threads:[~2009-05-29 7:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-28 21:07 [Cluster-devel] [PATCH] gfs2-utils: Clean up leftover prog_name globals Andrew Price
2009-05-29 4:39 ` Fabio M. Di Nitto
2009-05-29 7:21 ` Steven Whitehouse [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1243581694.29604.463.camel@localhost.localdomain \
--to=swhiteho@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox