diff options
author | Sami Kerola | 2011-06-29 22:33:47 +0200 |
---|---|---|
committer | Sami Kerola | 2011-06-29 23:13:57 +0200 |
commit | cc4d8d72061648c8f93a83ebba840d26581a7c1b (patch) | |
tree | 9845fe31de0eb037f2150aa2e1288084a05d1532 /disk-utils/blockdev.c | |
parent | blockdev: set options read only (diff) | |
download | kernel-qcow2-util-linux-cc4d8d72061648c8f93a83ebba840d26581a7c1b.tar.gz kernel-qcow2-util-linux-cc4d8d72061648c8f93a83ebba840d26581a7c1b.tar.xz kernel-qcow2-util-linux-cc4d8d72061648c8f93a83ebba840d26581a7c1b.zip |
blockdev: remove progname
Use errx, warnx or program_invocation_short_name instead.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'disk-utils/blockdev.c')
-rw-r--r-- | disk-utils/blockdev.c | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/disk-utils/blockdev.c b/disk-utils/blockdev.c index e082f0080..d1fd24ac0 100644 --- a/disk-utils/blockdev.c +++ b/disk-utils/blockdev.c @@ -15,9 +15,6 @@ #include "nls.h" #include "blkdev.h" -const char *progname; - - struct bdc { long ioc; /* ioctl code */ const char *iocname; /* ioctl name (e.g. BLKROSET) */ @@ -183,9 +180,9 @@ usage(void) { int i; fputc('\n', stderr); fprintf(stderr, _("Usage:\n")); - fprintf(stderr, _(" %s -V\n"), progname); - fprintf(stderr, _(" %s --report [devices]\n"), progname); - fprintf(stderr, _(" %s [-v|-q] commands devices\n"), progname); + fprintf(stderr, _(" %s -V\n"), program_invocation_short_name); + fprintf(stderr, _(" %s --report [devices]\n"), program_invocation_short_name); + fprintf(stderr, _(" %s [-v|-q] commands devices\n"), program_invocation_short_name); fputc('\n', stderr); fprintf(stderr, _("Available commands:\n")); @@ -222,16 +219,11 @@ void report_all_devices(void); int main(int argc, char **argv) { int fd, d, j, k; - char *p; /* egcs-2.91.66 is buggy and says: blockdev.c:93: warning: `d' might be used uninitialized */ d = 0; - progname = argv[0]; - if ((p = strrchr(progname, '/')) != NULL) - progname = p+1; - setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); @@ -241,7 +233,7 @@ main(int argc, char **argv) { /* -V not together with commands */ if (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")) { - printf(_("%s (%s)\n"), progname, PACKAGE_STRING); + printf(_("%s (%s)\n"), program_invocation_short_name, PACKAGE_STRING); exit(0); } @@ -324,8 +316,7 @@ do_commands(int fd, char **argv, int d) { j = find_cmd(argv[i]); if (j == -1) { - fprintf(stderr, _("%s: Unknown command: %s\n"), - progname, argv[i]); + warnx(_("Unknown command: %s"), argv[i]); usage(); } @@ -341,7 +332,7 @@ do_commands(int fd, char **argv, int d) { case ARG_INT: if (bdcms[j].argname) { if (i == d-1) { - fprintf(stderr, _("%s requires an argument\n"), + warnx(_("%s requires an argument"), bdcms[j].name); usage(); } @@ -429,11 +420,8 @@ report_all_devices(void) { int ma, mi, sz; procpt = fopen(PROC_PARTITIONS, "r"); - if (!procpt) { - fprintf(stderr, _("%s: cannot open %s\n"), - progname, PROC_PARTITIONS); - exit(1); - } + if (!procpt) + errx(EXIT_FAILURE, _("cannot open %s"), PROC_PARTITIONS); while (fgets(line, sizeof(line), procpt)) { if (sscanf (line, " %d %d %d %200[^\n ]", @@ -458,8 +446,7 @@ report_device(char *device, int quiet) { fd = open(device, O_RDONLY | O_NONBLOCK); if (fd < 0) { if (!quiet) - fprintf(stderr, _("%s: cannot open %s\n"), - progname, device); + warnx(_("cannot open %s\n"), device); return; } @@ -475,8 +462,7 @@ report_device(char *device, int quiet) { ro ? "ro" : "rw", ra, ssz, bsz, g.start, bytes, device); } else { if (!quiet) - fprintf(stderr, _("%s: ioctl error on %s\n"), - progname, device); + warnx(_("ioctl error on %s"), device); } close(fd); |