diff options
author | Karel Zak | 2019-04-16 15:14:13 +0200 |
---|---|---|
committer | Karel Zak | 2019-04-16 15:14:13 +0200 |
commit | 2c308875a7fa1aaa44892c368f6b37bcfcb8879a (patch) | |
tree | 157ea7afca59059676dbcc25133dd196d1e45fb8 /disk-utils | |
parent | include/c: add print_version() macro (diff) | |
download | kernel-qcow2-util-linux-2c308875a7fa1aaa44892c368f6b37bcfcb8879a.tar.gz kernel-qcow2-util-linux-2c308875a7fa1aaa44892c368f6b37bcfcb8879a.tar.xz kernel-qcow2-util-linux-2c308875a7fa1aaa44892c368f6b37bcfcb8879a.zip |
misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils')
-rw-r--r-- | disk-utils/addpart.c | 3 | ||||
-rw-r--r-- | disk-utils/blockdev.c | 8 | ||||
-rw-r--r-- | disk-utils/cfdisk.c | 5 | ||||
-rw-r--r-- | disk-utils/delpart.c | 3 | ||||
-rw-r--r-- | disk-utils/fdformat.c | 5 | ||||
-rw-r--r-- | disk-utils/fdisk.c | 5 | ||||
-rw-r--r-- | disk-utils/fsck.c | 8 | ||||
-rw-r--r-- | disk-utils/fsck.cramfs.c | 5 | ||||
-rw-r--r-- | disk-utils/fsck.minix.c | 5 | ||||
-rw-r--r-- | disk-utils/isosize.c | 5 | ||||
-rw-r--r-- | disk-utils/mkfs.bfs.c | 2 | ||||
-rw-r--r-- | disk-utils/mkfs.c | 2 | ||||
-rw-r--r-- | disk-utils/mkfs.cramfs.c | 7 | ||||
-rw-r--r-- | disk-utils/mkfs.minix.c | 5 | ||||
-rw-r--r-- | disk-utils/mkswap.c | 5 | ||||
-rw-r--r-- | disk-utils/partx.c | 5 | ||||
-rw-r--r-- | disk-utils/raw.c | 5 | ||||
-rw-r--r-- | disk-utils/resizepart.c | 5 | ||||
-rw-r--r-- | disk-utils/sfdisk.c | 6 | ||||
-rw-r--r-- | disk-utils/swaplabel.c | 5 |
20 files changed, 39 insertions, 60 deletions
diff --git a/disk-utils/addpart.c b/disk-utils/addpart.c index 018c99585..33abb36ca 100644 --- a/disk-utils/addpart.c +++ b/disk-utils/addpart.c @@ -41,8 +41,7 @@ int main(int argc, char **argv) while ((c = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1) switch (c) { case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'h': usage(); default: diff --git a/disk-utils/blockdev.c b/disk-utils/blockdev.c index 5122460f0..f1067c815 100644 --- a/disk-utils/blockdev.c +++ b/disk-utils/blockdev.c @@ -238,7 +238,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); if (argc < 2) { warnx(_("not enough arguments")); @@ -246,10 +246,8 @@ int main(int argc, char **argv) } /* -V not together with commands */ - if (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")) { - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; - } + if (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")) + print_version(EXIT_SUCCESS); if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) usage(); diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c index ff1bc44c1..376809974 100644 --- a/disk-utils/cfdisk.c +++ b/disk-utils/cfdisk.c @@ -2667,7 +2667,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while((c = getopt_long(argc, argv, "L::hVz", longopts, NULL)) != -1) { switch(c) { @@ -2681,8 +2681,7 @@ int main(int argc, char *argv[]) _("unsupported color mode")); break; case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'z': cf->zero_start = 1; break; diff --git a/disk-utils/delpart.c b/disk-utils/delpart.c index dc069970d..7ee0c525f 100644 --- a/disk-utils/delpart.c +++ b/disk-utils/delpart.c @@ -41,8 +41,7 @@ int main(int argc, char **argv) while ((c = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1) switch (c) { case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'h': usage(); default: diff --git a/disk-utils/fdformat.c b/disk-utils/fdformat.c index f461c82e1..c10776f76 100644 --- a/disk-utils/fdformat.c +++ b/disk-utils/fdformat.c @@ -186,7 +186,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((ch = getopt_long(argc, argv, "f:t:r:nVh", longopts, NULL)) != -1) switch (ch) { @@ -204,8 +204,7 @@ int main(int argc, char **argv) verify = 0; break; case 'V': - printf(UTIL_LINUX_VERSION); - exit(EXIT_SUCCESS); + print_version(EXIT_SUCCESS); case 'h': usage(); default: diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index 3e8ebf4a3..c27485af2 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -891,7 +891,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); fdisk_init_debug(0); scols_init_debug(0); @@ -990,8 +990,7 @@ int main(int argc, char **argv) break; case 'V': /* preferred for util-linux */ case 'v': /* for backward compatibility only */ - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'w': wipemode = wipemode_from_string(optarg); if (wipemode < 0) diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c index 3afc88600..be25f9c95 100644 --- a/disk-utils/fsck.c +++ b/disk-utils/fsck.c @@ -1450,10 +1450,8 @@ static void parse_argv(int argc, char *argv[]) /* the only two longopts to satisfy UL standards */ if (!opts_for_fsck && !strcmp(arg, "--help")) usage(); - if (!opts_for_fsck && !strcmp(arg, "--version")) { - printf(UTIL_LINUX_VERSION); - exit(FSCK_EX_OK); - } + if (!opts_for_fsck && !strcmp(arg, "--version")) + print_version(FSCK_EX_OK); if ((arg[0] == '/' && !opts_for_fsck) || strchr(arg, '=')) { if (num_devices >= MAX_DEVICES) @@ -1621,7 +1619,7 @@ int main(int argc, char *argv[]) setlocale(LC_CTYPE, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); strutils_set_exitcode(FSCK_EX_USAGE); mnt_init_debug(0); /* init libmount debug mask */ diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c index ee9c20ab2..e1b964b64 100644 --- a/disk-utils/fsck.cramfs.c +++ b/disk-utils/fsck.cramfs.c @@ -660,7 +660,7 @@ int main(int argc, char **argv) setlocale(LC_CTYPE, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); strutils_set_exitcode(FSCK_EX_USAGE); @@ -674,8 +674,7 @@ int main(int argc, char **argv) usage(); break; case 'V': - printf(UTIL_LINUX_VERSION); - return FSCK_EX_OK; + print_version(FSCK_EX_OK); case 'x': opt_extract = 1; if(optarg) diff --git a/disk-utils/fsck.minix.c b/disk-utils/fsck.minix.c index b978684a8..246f254f3 100644 --- a/disk-utils/fsck.minix.c +++ b/disk-utils/fsck.minix.c @@ -1291,7 +1291,7 @@ main(int argc, char **argv) { setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); strutils_set_exitcode(FSCK_EX_USAGE); @@ -1326,8 +1326,7 @@ main(int argc, char **argv) { force = 1; break; case 'V': - printf(UTIL_LINUX_VERSION); - return FSCK_EX_OK; + print_version(FSCK_EX_OK); case 'h': usage(); default: diff --git a/disk-utils/isosize.c b/disk-utils/isosize.c index 85a549a18..3c8d40f3c 100644 --- a/disk-utils/isosize.c +++ b/disk-utils/isosize.c @@ -177,7 +177,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((opt = getopt_long(argc, argv, "d:xVh", longopts, NULL)) != -1) { switch (opt) { @@ -190,8 +190,7 @@ int main(int argc, char **argv) xflag = 1; break; case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'h': usage(); default: diff --git a/disk-utils/mkfs.bfs.c b/disk-utils/mkfs.bfs.c index 77f253f1e..54d261b29 100644 --- a/disk-utils/mkfs.bfs.c +++ b/disk-utils/mkfs.bfs.c @@ -121,7 +121,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); if (argc < 2) { warnx(_("not enough arguments")); diff --git a/disk-utils/mkfs.c b/disk-utils/mkfs.c index fbd575e7e..8ba28c2f5 100644 --- a/disk-utils/mkfs.c +++ b/disk-utils/mkfs.c @@ -80,7 +80,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); if (argc == 2 && !strcmp(argv[1], "-V")) print_version(EXIT_SUCCESS); diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c index bf07f8c67..71320a0a9 100644 --- a/disk-utils/mkfs.cramfs.c +++ b/disk-utils/mkfs.cramfs.c @@ -714,14 +714,14 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); if (argc > 1) { /* first arg may be one of our standard longopts */ if (!strcmp(argv[1], "--help")) usage(); if (!strcmp(argv[1], "--version")) { - printf(UTIL_LINUX_VERSION); + print_version(EXIT_SUCCESS); exit(MKFS_EX_OK); } } @@ -770,8 +770,7 @@ int main(int argc, char **argv) /* old option, ignored */ break; case 'V': - printf(UTIL_LINUX_VERSION); - exit(MKFS_EX_OK); + print_version(MKFS_EX_OK); case 'v': verbose = 1; break; diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c index 8e6811f49..ed03f4a42 100644 --- a/disk-utils/mkfs.minix.c +++ b/disk-utils/mkfs.minix.c @@ -758,7 +758,7 @@ int main(int argc, char ** argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); strutils_set_exitcode(MKFS_EX_USAGE); @@ -792,8 +792,7 @@ int main(int argc, char ** argv) listfile = optarg; break; case 'V': - printf(UTIL_LINUX_VERSION); - return MKFS_EX_OK; + print_version(MKFS_EX_OK); case 'h': usage(); default: diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index 28a139d45..659ebf0d7 100644 --- a/disk-utils/mkswap.c +++ b/disk-utils/mkswap.c @@ -369,7 +369,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while((c = getopt_long(argc, argv, "cfp:L:v:U:Vh", longopts, NULL)) != -1) { switch (c) { @@ -400,8 +400,7 @@ int main(int argc, char **argv) #endif break; case 'V': - printf(UTIL_LINUX_VERSION); - exit(EXIT_SUCCESS); + print_version(EXIT_SUCCESS); case 'h': usage(); default: diff --git a/disk-utils/partx.c b/disk-utils/partx.c index e10efa96a..949278eb7 100644 --- a/disk-utils/partx.c +++ b/disk-utils/partx.c @@ -832,7 +832,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((c = getopt_long(argc, argv, "abdglrsuvn:t:o:PS:hV", long_opts, NULL)) != -1) { @@ -901,8 +901,7 @@ int main(int argc, char **argv) case 'h': usage(); case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); default: errtryhelp(EXIT_FAILURE); } diff --git a/disk-utils/raw.c b/disk-utils/raw.c index 8abcbb747..b44a581a2 100644 --- a/disk-utils/raw.c +++ b/disk-utils/raw.c @@ -108,7 +108,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((c = getopt_long(argc, argv, "qaVh", longopts, NULL)) != -1) switch (c) { @@ -119,8 +119,7 @@ int main(int argc, char *argv[]) do_query_all = 1; break; case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'h': usage(); default: diff --git a/disk-utils/resizepart.c b/disk-utils/resizepart.c index 527517f24..b2738271e 100644 --- a/disk-utils/resizepart.c +++ b/disk-utils/resizepart.c @@ -80,13 +80,12 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((c = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1) switch (c) { case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'h': usage(); default: diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index 2427cef5b..8166137c5 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -1994,7 +1994,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((c = getopt_long(argc, argv, "aAbcdfFgGhJlLo:O:nN:qrsTu:vVX:Y:w:W:", longopts, &longidx)) != -1) { @@ -2079,9 +2079,7 @@ int main(int argc, char *argv[]) errx(EXIT_FAILURE, _("unsupported unit '%c'"), *optarg); break; case 'v': - printf(_("%s from %s\n"), program_invocation_short_name, - PACKAGE_STRING); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'V': sf->verify = 1; break; diff --git a/disk-utils/swaplabel.c b/disk-utils/swaplabel.c index ccc226a02..e6ba7d66d 100644 --- a/disk-utils/swaplabel.c +++ b/disk-utils/swaplabel.c @@ -152,7 +152,7 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - atexit(close_stdout); + close_stdout_atexit(); while ((c = getopt_long(argc, argv, "hVL:U:", longopts, NULL)) != -1) { switch (c) { @@ -160,8 +160,7 @@ int main(int argc, char *argv[]) usage(); break; case 'V': - printf(UTIL_LINUX_VERSION); - return EXIT_SUCCESS; + print_version(EXIT_SUCCESS); case 'L': label = optarg; break; |