summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2019-04-16 15:14:13 +0200
committerKarel Zak2019-04-16 15:14:13 +0200
commit2c308875a7fa1aaa44892c368f6b37bcfcb8879a (patch)
tree157ea7afca59059676dbcc25133dd196d1e45fb8
parentinclude/c: add print_version() macro (diff)
downloadkernel-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>
-rw-r--r--Documentation/boilerplate.c5
-rw-r--r--disk-utils/addpart.c3
-rw-r--r--disk-utils/blockdev.c8
-rw-r--r--disk-utils/cfdisk.c5
-rw-r--r--disk-utils/delpart.c3
-rw-r--r--disk-utils/fdformat.c5
-rw-r--r--disk-utils/fdisk.c5
-rw-r--r--disk-utils/fsck.c8
-rw-r--r--disk-utils/fsck.cramfs.c5
-rw-r--r--disk-utils/fsck.minix.c5
-rw-r--r--disk-utils/isosize.c5
-rw-r--r--disk-utils/mkfs.bfs.c2
-rw-r--r--disk-utils/mkfs.c2
-rw-r--r--disk-utils/mkfs.cramfs.c7
-rw-r--r--disk-utils/mkfs.minix.c5
-rw-r--r--disk-utils/mkswap.c5
-rw-r--r--disk-utils/partx.c5
-rw-r--r--disk-utils/raw.c5
-rw-r--r--disk-utils/resizepart.c5
-rw-r--r--disk-utils/sfdisk.c6
-rw-r--r--disk-utils/swaplabel.c5
-rw-r--r--include/c.h5
-rw-r--r--login-utils/chfn.c6
-rw-r--r--login-utils/chsh.c5
-rw-r--r--login-utils/islocal.c2
-rw-r--r--login-utils/last.c5
-rw-r--r--login-utils/login.c3
-rw-r--r--login-utils/logindefs.c2
-rw-r--r--login-utils/lslogins.c5
-rw-r--r--login-utils/newgrp.c5
-rw-r--r--login-utils/nologin.c4
-rw-r--r--login-utils/su-common.c6
-rw-r--r--login-utils/sulogin.c8
-rw-r--r--login-utils/utmpdump.c6
-rw-r--r--login-utils/vipw.c5
-rw-r--r--misc-utils/blkid.c2
-rw-r--r--misc-utils/cal.c5
-rw-r--r--misc-utils/fincore.c5
-rw-r--r--misc-utils/findfs.c5
-rw-r--r--misc-utils/findmnt.c13
-rw-r--r--misc-utils/getopt.c10
-rw-r--r--misc-utils/hardlink.c5
-rw-r--r--misc-utils/kill.c8
-rw-r--r--misc-utils/logger.c12
-rw-r--r--misc-utils/look.c5
-rw-r--r--misc-utils/lsblk.c16
-rw-r--r--misc-utils/lslocks.c12
-rw-r--r--misc-utils/mcookie.c6
-rw-r--r--misc-utils/namei.c13
-rw-r--r--misc-utils/rename.c6
-rw-r--r--misc-utils/uuidd.c6
-rw-r--r--misc-utils/uuidgen.c8
-rw-r--r--misc-utils/uuidparse.c6
-rw-r--r--misc-utils/whereis.c12
-rw-r--r--misc-utils/wipefs.c11
-rw-r--r--schedutils/chrt.c6
-rw-r--r--schedutils/ionice.c6
-rw-r--r--schedutils/taskset.c7
-rw-r--r--sys-utils/blkdiscard.c13
-rw-r--r--sys-utils/blkzone.c11
-rw-r--r--sys-utils/chcpu.c10
-rw-r--r--sys-utils/chmem.c13
-rw-r--r--sys-utils/choom.c6
-rw-r--r--sys-utils/ctrlaltdel.c5
-rw-r--r--sys-utils/dmesg.c13
-rw-r--r--sys-utils/eject.c12
-rw-r--r--sys-utils/fallocate.c11
-rw-r--r--sys-utils/flock.c6
-rw-r--r--sys-utils/fsfreeze.c9
-rw-r--r--sys-utils/fstrim.c14
-rw-r--r--sys-utils/hwclock.c6
-rw-r--r--sys-utils/ipcmk.c7
-rw-r--r--sys-utils/ipcrm.c6
-rw-r--r--sys-utils/ipcs.c6
-rw-r--r--sys-utils/ldattach.c4
-rw-r--r--sys-utils/losetup.c11
-rw-r--r--sys-utils/lscpu.c10
-rw-r--r--sys-utils/lsipc.c4
-rw-r--r--sys-utils/lsmem.c15
-rw-r--r--sys-utils/lsns.c12
-rw-r--r--sys-utils/mount.c15
-rw-r--r--sys-utils/mountpoint.c7
-rw-r--r--sys-utils/nsenter.c11
-rw-r--r--sys-utils/pivot_root.c5
-rw-r--r--sys-utils/prlimit.c13
-rw-r--r--sys-utils/readprofile.c6
-rw-r--r--sys-utils/renice.c8
-rw-r--r--sys-utils/rfkill.c6
-rw-r--r--sys-utils/rtcwake.c6
-rw-r--r--sys-utils/setarch.c13
-rw-r--r--sys-utils/setpriv.c6
-rw-r--r--sys-utils/setsid.c8
-rw-r--r--sys-utils/swapoff.c13
-rw-r--r--sys-utils/swapon.c13
-rw-r--r--sys-utils/switch_root.c5
-rw-r--r--sys-utils/tunelp.c11
-rw-r--r--sys-utils/umount.c15
-rw-r--r--sys-utils/unshare.c12
-rw-r--r--sys-utils/wdctl.c12
-rw-r--r--sys-utils/zramctl.c6
-rw-r--r--term-utils/mesg.c6
-rw-r--r--term-utils/script.c8
-rw-r--r--term-utils/scriptreplay.c6
-rw-r--r--term-utils/setterm.c6
-rw-r--r--term-utils/wall.c6
-rw-r--r--term-utils/write.c5
-rw-r--r--text-utils/col.c6
-rw-r--r--text-utils/colcrt.c6
-rw-r--r--text-utils/colrm.c3
-rw-r--r--text-utils/column.c13
-rw-r--r--text-utils/hexdump.c7
-rw-r--r--text-utils/line.c5
-rw-r--r--text-utils/more.c10
-rw-r--r--text-utils/pg.c8
-rw-r--r--text-utils/rev.c5
-rw-r--r--text-utils/ul.c6
116 files changed, 391 insertions, 466 deletions
diff --git a/Documentation/boilerplate.c b/Documentation/boilerplate.c
index a92f7f097..535e85c38 100644
--- a/Documentation/boilerplate.c
+++ b/Documentation/boilerplate.c
@@ -84,7 +84,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, "nr:zelfVh", longopts, NULL)) != -1)
switch (c) {
@@ -98,8 +98,7 @@ int main(int argc, char **argv)
case 'f':
break;
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
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;
diff --git a/include/c.h b/include/c.h
index fb6835253..fc69b910b 100644
--- a/include/c.h
+++ b/include/c.h
@@ -351,6 +351,11 @@ static inline int xusleep(useconds_t usec)
#define UTIL_LINUX_VERSION _("%s from %s\n"), program_invocation_short_name, PACKAGE_STRING
+#define print_version(eval) __extension__ ({ \
+ printf(UTIL_LINUX_VERSION); \
+ exit(eval); \
+})
+
/*
* scanf modifiers for "strings allocation"
*/
diff --git a/login-utils/chfn.c b/login-utils/chfn.c
index c5312fa0c..a2e6e099e 100644
--- a/login-utils/chfn.c
+++ b/login-utils/chfn.c
@@ -176,8 +176,7 @@ static void parse_argv(struct chfn_control *ctl, int argc, char **argv)
status += check_gecos_string(_("Home Phone"), optarg);
break;
case 'v':
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
+ print_version(EXIT_SUCCESS);
case 'u':
usage();
default:
@@ -412,7 +411,8 @@ int main(int argc, char **argv)
setlocale(LC_ALL, ""); /* both for messages and for iscntrl() below */
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
+
uid = getuid();
/* check /etc/login.defs CHFN_RESTRICT */
diff --git a/login-utils/chsh.c b/login-utils/chsh.c
index c267c7272..9b2761157 100644
--- a/login-utils/chsh.c
+++ b/login-utils/chsh.c
@@ -166,8 +166,7 @@ static void parse_argv(int argc, char **argv, struct sinfo *pinfo)
while ((c = getopt_long(argc, argv, "s:lhuv", long_options, NULL)) != -1) {
switch (c) {
case 'v':
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
+ print_version(EXIT_SUCCESS);
case 'u': /* deprecated */
case 'h':
usage();
@@ -264,7 +263,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
parse_argv(argc, argv, &info);
if (!info.username) {
diff --git a/login-utils/islocal.c b/login-utils/islocal.c
index 7c4e775c1..469bc5629 100644
--- a/login-utils/islocal.c
+++ b/login-utils/islocal.c
@@ -91,7 +91,7 @@ int is_local(const char *user)
#ifdef TEST_PROGRAM
int main(int argc, char *argv[])
{
- atexit(close_stdout);
+ close_stdout_atexit();
if (argc <= 2) {
fprintf(stderr, _("Usage: %s <passwordfile> <username>...\n"),
argv[0]);
diff --git a/login-utils/last.c b/login-utils/last.c
index 303adeacd..2f7d9d48f 100644
--- a/login-utils/last.c
+++ b/login-utils/last.c
@@ -939,7 +939,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
/*
* Which file do we want to read?
*/
@@ -954,8 +954,7 @@ int main(int argc, char **argv)
usage(&ctl);
break;
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'R':
ctl.showhost = 0;
break;
diff --git a/login-utils/login.c b/login-utils/login.c
index ab819f16f..a2d2725a6 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -1196,8 +1196,7 @@ int main(int argc, char **argv)
break;
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case HELP_OPTION:
usage();
default:
diff --git a/login-utils/logindefs.c b/login-utils/logindefs.c
index 07a977660..2b505d255 100644
--- a/login-utils/logindefs.c
+++ b/login-utils/logindefs.c
@@ -403,7 +403,7 @@ int get_hushlogin_status(struct passwd *pwd, int force_check)
int main(int argc, char *argv[])
{
char *name, *type;
- atexit(close_stdout);
+ close_stdout_atexit();
if (argc <= 1)
errx(EXIT_FAILURE, "usage: %s <filename> "
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index c913cf2d8..efb20a4f7 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -1425,7 +1425,7 @@ int main(int argc, char *argv[])
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
ctl->time_mode = TIME_SHORT;
@@ -1528,8 +1528,7 @@ int main(int argc, char *argv[])
ctl->time_mode = parse_time_mode(optarg);
break;
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'Z':
{
#ifdef HAVE_LIBSELINUX
diff --git a/login-utils/newgrp.c b/login-utils/newgrp.c
index 453883148..5e4b4caa0 100644
--- a/login-utils/newgrp.c
+++ b/login-utils/newgrp.c
@@ -196,13 +196,12 @@ 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, "Vh", longopts, NULL)) != -1)
switch (ch) {
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/login-utils/nologin.c b/login-utils/nologin.c
index b0b6a721c..14a091715 100644
--- a/login-utils/nologin.c
+++ b/login-utils/nologin.c
@@ -54,10 +54,8 @@ int main(int argc, char *argv[])
switch (c) {
case 'h':
usage();
- break;
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_FAILURE;
+ print_version(EXIT_FAILURE); /* yes FAILURE! */
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/login-utils/su-common.c b/login-utils/su-common.c
index 94289898d..86beab99c 100644
--- a/login-utils/su-common.c
+++ b/login-utils/su-common.c
@@ -1321,7 +1321,7 @@ int su_main(int argc, char **argv, int mode)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
su_init_debug();
su->conv.appdata_ptr = (void *) su;
@@ -1392,9 +1392,7 @@ int su_main(int argc, char **argv, int mode)
usage(mode);
case 'V':
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
-
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/login-utils/sulogin.c b/login-utils/sulogin.c
index 5f09bd48e..549870d22 100644
--- a/login-utils/sulogin.c
+++ b/login-utils/sulogin.c
@@ -815,6 +815,8 @@ static void usage(void)
fputs(USAGE_SEPARATOR, out);
printf(USAGE_HELP_OPTIONS(26));
printf(USAGE_MAN_TAIL("sulogin(8)"));
+
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
@@ -853,7 +855,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout); /* XXX */
+ close_stdout_atexit();
/*
* See if we have a timeout flag.
@@ -870,11 +872,9 @@ int main(int argc, char **argv)
opt_e = 1;
break;
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
- return EXIT_SUCCESS;
default:
/* Do not exit! getopt prints a warning. */
break;
diff --git a/login-utils/utmpdump.c b/login-utils/utmpdump.c
index 5cc87834a..f1a3607dc 100644
--- a/login-utils/utmpdump.c
+++ b/login-utils/utmpdump.c
@@ -334,7 +334,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, "fro:hV", longopts, NULL)) != -1) {
switch (c) {
@@ -355,10 +355,8 @@ int main(int argc, char **argv)
case 'h':
usage();
- break;
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/login-utils/vipw.c b/login-utils/vipw.c
index 2502fcb4e..2b35036e6 100644
--- a/login-utils/vipw.c
+++ b/login-utils/vipw.c
@@ -325,7 +325,7 @@ int main(int argc, char *argv[])
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
if (!strcmp(program_invocation_short_name, "vigr")) {
program = VIGR;
@@ -338,8 +338,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/misc-utils/blkid.c b/misc-utils/blkid.c
index c03e1bb8d..2b13f71c0 100644
--- a/misc-utils/blkid.c
+++ b/misc-utils/blkid.c
@@ -686,7 +686,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
strutils_set_exitcode(BLKID_EXIT_OTHER);
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index bbb22505e..c7e8d9511 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -332,7 +332,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
term = getenv("TERM");
if (term) {
@@ -435,8 +435,7 @@ int main(int argc, char **argv)
ctl.reform_year = ISO;
break;
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/misc-utils/fincore.c b/misc-utils/fincore.c
index 6bad2c040..0fb1a759a 100644
--- a/misc-utils/fincore.c
+++ b/misc-utils/fincore.c
@@ -310,7 +310,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, "bno:JrVh", longopts, NULL)) != -1) {
switch (c) {
@@ -330,8 +330,7 @@ int main(int argc, char ** argv)
ctl.raw = 1;
break;
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/misc-utils/findfs.c b/misc-utils/findfs.c
index a437bda84..0997e1b49 100644
--- a/misc-utils/findfs.c
+++ b/misc-utils/findfs.c
@@ -50,7 +50,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
if (argc != 2) {
/* we return '2' for backward compatibility
@@ -62,8 +62,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 FINDFS_SUCCESS;
+ print_version(FINDFS_SUCCESS);
case 'h':
usage();
default:
diff --git a/misc-utils/findmnt.c b/misc-utils/findmnt.c
index 331460bd1..eea772f0e 100644
--- a/misc-utils/findmnt.c
+++ b/misc-utils/findmnt.c
@@ -1348,7 +1348,7 @@ int main(int argc, char *argv[])
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
/* default output format */
flags |= FL_TREE;
@@ -1391,9 +1391,6 @@ int main(int argc, char *argv[])
case 'e':
flags |= FL_EVALUATE;
break;
- case 'h':
- usage();
- break;
case 'i':
flags |= FL_INVERT;
break;
@@ -1490,9 +1487,6 @@ int main(int argc, char *argv[])
case 'w':
timeout = strtos32_or_err(optarg, _("invalid timeout argument"));
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'x':
verify = 1;
break;
@@ -1508,6 +1502,11 @@ int main(int argc, char *argv[])
case FINDMNT_OPT_REAL:
flags |= FL_REAL;
break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/misc-utils/getopt.c b/misc-utils/getopt.c
index 9b4f35279..3fa158eb3 100644
--- a/misc-utils/getopt.c
+++ b/misc-utils/getopt.c
@@ -379,7 +379,7 @@ int main(int argc, char *argv[])
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
if (getenv("GETOPT_COMPATIBLE"))
ctl.compatible = 1;
@@ -413,8 +413,6 @@ int main(int argc, char *argv[])
case 'a':
getopt_long_fp = getopt_long_only;
break;
- case 'h':
- usage();
case 'o':
free(ctl.optstr);
ctl.optstr = xstrdup(optarg);
@@ -441,12 +439,14 @@ int main(int argc, char *argv[])
case 'u':
ctl.quote = 0;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case '?':
case ':':
parse_error(NULL);
+ case 'h':
+ usage();
default:
parse_error(_("internal error, contact the author."));
}
diff --git a/misc-utils/hardlink.c b/misc-utils/hardlink.c
index f7cfc961b..2a1e216a2 100644
--- a/misc-utils/hardlink.c
+++ b/misc-utils/hardlink.c
@@ -413,7 +413,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, "cnvfx:Vh", longopts, NULL)) != -1) {
switch (ch) {
@@ -438,8 +438,7 @@ int main(int argc, char **argv)
#endif
break;
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/misc-utils/kill.c b/misc-utils/kill.c
index 726768bd1..1ac61cf5a 100644
--- a/misc-utils/kill.c
+++ b/misc-utils/kill.c
@@ -213,10 +213,8 @@ static char **parse_arguments(int argc, char **argv, struct kill_control *ctl)
break;
}
if (!strcmp(arg, "-v") || !strcmp(arg, "-V") ||
- !strcmp(arg, "--version")) {
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
- }
+ !strcmp(arg, "--version"))
+ print_version(EXIT_SUCCESS);
if (!strcmp(arg, "-h") || !strcmp(arg, "--help"))
usage();
if (!strcmp(arg, "--verbose")) {
@@ -343,7 +341,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
argv = parse_arguments(argc, argv, &ctl);
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index d6cee8287..a99a0c96c 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -1155,7 +1155,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
INIT_LIST_HEAD(&ctl.user_sds);
INIT_LIST_HEAD(&ctl.reserved_sds);
@@ -1212,11 +1212,6 @@ int main(int argc, char **argv)
case 'P':
ctl.port = optarg;
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
- case 'h':
- usage();
case OPT_OCTET_COUNT:
ctl.octet_count = 1;
break;
@@ -1263,6 +1258,11 @@ int main(int argc, char **argv)
errx(EXIT_FAILURE, _("invalid structured data parameter: '%s'"), optarg);
add_structured_data_param(get_user_structured_data(&ctl), optarg);
break;
+
+ case 'V':
+ print_version(EXIT_SUCCESS);
+ case 'h':
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/misc-utils/look.c b/misc-utils/look.c
index d2699bfdd..d3f0622c3 100644
--- a/misc-utils/look.c
+++ b/misc-utils/look.c
@@ -100,7 +100,7 @@ main(int argc, char *argv[])
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
setlocale(LC_ALL, "");
@@ -127,8 +127,7 @@ main(int argc, char *argv[])
termchar = *optarg;
break;
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
index 915a062ba..c8683854c 100644
--- a/misc-utils/lsblk.c
+++ b/misc-utils/lsblk.c
@@ -1814,7 +1814,7 @@ int main(int argc, char *argv[])
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
lsblk = &_ls;
@@ -1849,9 +1849,6 @@ int main(int argc, char *argv[])
case 'e':
parse_excludes(optarg);
break;
- case 'h':
- usage();
- break;
case 'J':
lsblk->flags |= LSBLK_JSON;
break;
@@ -1939,9 +1936,6 @@ int main(int argc, char *argv[])
case OPT_SYSROOT:
lsblk->sysroot = optarg;
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'E':
lsblk->dedup_id = column_name_to_id(optarg, strlen(optarg));
if (lsblk->dedup_id >= 0)
@@ -1953,7 +1947,13 @@ int main(int argc, char *argv[])
lsblk->sort_id = column_name_to_id(optarg, strlen(optarg));
if (lsblk->sort_id >= 0)
break;
- /* fallthrough */
+ errtryhelp(EXIT_FAILURE);
+ break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c
index f83fb76f2..18922e546 100644
--- a/misc-utils/lslocks.c
+++ b/misc-utils/lslocks.c
@@ -585,7 +585,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,
"biJp:o:nruhV", long_opts, NULL)) != -1) {
@@ -612,11 +612,6 @@ int main(int argc, char *argv[])
for (ncolumns = 0; ncolumns < ARRAY_SIZE(infos); ncolumns++)
columns[ncolumns] = ncolumns;
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
- case 'h':
- usage();
case 'n':
no_headings = 1;
break;
@@ -626,6 +621,11 @@ int main(int argc, char *argv[])
case 'u':
disable_columns_truncate();
break;
+
+ case 'V':
+ print_version(EXIT_SUCCESS);
+ case 'h':
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/misc-utils/mcookie.c b/misc-utils/mcookie.c
index 8598ac345..ea29a8209 100644
--- a/misc-utils/mcookie.c
+++ b/misc-utils/mcookie.c
@@ -147,7 +147,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, "f:m:vVh", longopts, NULL)) != -1) {
switch (c) {
@@ -163,9 +163,9 @@ int main(int argc, char **argv)
ctl.maxsz = strtosize_or_err(optarg,
_("failed to parse length"));
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/misc-utils/namei.c b/misc-utils/namei.c
index 60171f600..9c5f5fa4a 100644
--- a/misc-utils/namei.c
+++ b/misc-utils/namei.c
@@ -372,16 +372,10 @@ 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, "hVlmnovx", longopts, NULL)) != -1) {
switch(c) {
- case 'h':
- usage();
- break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'l':
flags |= (NAMEI_OWNERS | NAMEI_MODES | NAMEI_VERTICAL);
break;
@@ -400,6 +394,11 @@ main(int argc, char **argv)
case 'v':
flags |= NAMEI_VERTICAL;
break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/misc-utils/rename.c b/misc-utils/rename.c
index 1d9315793..a9378af59 100644
--- a/misc-utils/rename.c
+++ b/misc-utils/rename.c
@@ -243,7 +243,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, "vsVhnoi", longopts, NULL)) != -1)
switch (c) {
@@ -264,9 +264,9 @@ int main(int argc, char **argv)
case 's':
do_rename = do_symlink;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c
index 0382bac47..af24efc14 100644
--- a/misc-utils/uuidd.c
+++ b/misc-utils/uuidd.c
@@ -576,7 +576,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, "p:s:T:krtn:PFSdqVh", longopts,
@@ -629,9 +629,9 @@ int main(int argc, char **argv)
uuidd_cxt.timeout = strtou32_or_err(optarg,
_("failed to parse --timeout"));
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/misc-utils/uuidgen.c b/misc-utils/uuidgen.c
index c19706953..fa148abae 100644
--- a/misc-utils/uuidgen.c
+++ b/misc-utils/uuidgen.c
@@ -104,7 +104,7 @@ 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, "rtVhn:N:msx", longopts, NULL)) != -1)
switch (c) {
@@ -114,9 +114,6 @@ main (int argc, char *argv[])
case 'r':
do_type = UUID_TYPE_DCE_RANDOM;
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'n':
namespace = optarg;
break;
@@ -132,8 +129,11 @@ main (int argc, char *argv[])
case 'x':
is_hex = 1;
break;
+
case 'h':
usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/misc-utils/uuidparse.c b/misc-utils/uuidparse.c
index 6a13f2a2b..eae0b71a1 100644
--- a/misc-utils/uuidparse.c
+++ b/misc-utils/uuidparse.c
@@ -304,7 +304,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, "Jno:rVh", longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
@@ -321,9 +321,9 @@ int main(int argc, char **argv)
case 'r':
ctrl.raw = 1;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c
index 2d4c58125..21f381321 100644
--- a/misc-utils/whereis.c
+++ b/misc-utils/whereis.c
@@ -512,7 +512,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
if (argc <= 1) {
warnx(_("not enough arguments"));
@@ -521,10 +521,8 @@ int main(int argc, char **argv)
/* first arg may be one of our standard longopts */
if (!strcmp(argv[1], "--help"))
usage();
- if (!strcmp(argv[1], "--version")) {
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
- }
+ if (!strcmp(argv[1], "--version"))
+ print_version(EXIT_SUCCESS);
}
whereis_init_debug();
@@ -628,9 +626,9 @@ int main(int argc, char **argv)
case 'l':
list_dirlist(ls);
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c
index 13a720e85..78e5ac376 100644
--- a/misc-utils/wipefs.c
+++ b/misc-utils/wipefs.c
@@ -700,7 +700,7 @@ 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, "abfhiJnO:o:pqt:V", longopts, NULL)) != -1) {
@@ -716,9 +716,6 @@ main(int argc, char **argv)
case 'f':
ctl.force = 1;
break;
- case 'h':
- usage();
- break;
case 'J':
ctl.json = 1;
break;
@@ -745,9 +742,11 @@ main(int argc, char **argv)
case 't':
ctl.type_pattern = optarg;
break;
+
+ case 'h':
+ usage();
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index b08c78ed8..cc3a8c2f0 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -434,7 +434,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, "+abdD:fiphmoP:T:rRvV", longopts, NULL)) != -1)
{
@@ -489,9 +489,9 @@ int main(int argc, char **argv)
case 'D':
ctl->deadline = strtou64_or_err(optarg, _("invalid deadline argument"));
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/schedutils/ionice.c b/schedutils/ionice.c
index b4c6a82a2..ae2c73ea5 100644
--- a/schedutils/ionice.c
+++ b/schedutils/ionice.c
@@ -149,7 +149,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, "+n:c:p:P:u:tVh", longopts, NULL)) != EOF)
switch (c) {
@@ -197,9 +197,9 @@ int main(int argc, char **argv)
case 't':
tolerant = 1;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/schedutils/taskset.c b/schedutils/taskset.c
index fe79cd631..56db81792 100644
--- a/schedutils/taskset.c
+++ b/schedutils/taskset.c
@@ -157,7 +157,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
memset(&ts, 0, sizeof(ts));
@@ -173,12 +173,11 @@ int main(int argc, char **argv)
case 'c':
ts.use_list = 1;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
- break;
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/blkdiscard.c b/sys-utils/blkdiscard.c
index c19b67bf4..f9ba5e468 100644
--- a/sys-utils/blkdiscard.c
+++ b/sys-utils/blkdiscard.c
@@ -127,7 +127,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
range[0] = 0;
range[1] = ULLONG_MAX;
@@ -135,12 +135,6 @@ int main(int argc, char **argv)
while ((c = getopt_long(argc, argv, "hVsvo:l:p:z", longopts, NULL)) != -1) {
switch(c) {
- case 'h':
- usage();
- break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'l':
range[1] = strtosize_or_err(optarg,
_("failed to parse length"));
@@ -162,6 +156,11 @@ int main(int argc, char **argv)
case 'z':
act = ACT_ZEROOUT;
break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/blkzone.c b/sys-utils/blkzone.c
index 1dcbdf500..5fd5da7a3 100644
--- a/sys-utils/blkzone.c
+++ b/sys-utils/blkzone.c
@@ -357,7 +357,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
if (argc >= 2 && *argv[1] != '-') {
ctl.command = name_to_command(argv[1]);
@@ -372,9 +372,6 @@ int main(int argc, char **argv)
err_exclusive_options(c, longopts, excl, excl_st);
switch (c) {
- case 'h':
- usage();
- break;
case 'c':
ctl.count = strtou32_or_err(optarg,
_("failed to parse number of zones"));
@@ -390,9 +387,11 @@ int main(int argc, char **argv)
case 'v':
ctl.verbose = 1;
break;
+
+ case 'h':
+ usage();
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/chcpu.c b/sys-utils/chcpu.c
index 4060a4ca4..c4e5bc7e2 100644
--- a/sys-utils/chcpu.c
+++ b/sys-utils/chcpu.c
@@ -288,7 +288,7 @@ int main(int argc, char *argv[])
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
ul_path_init_debug();
sys = ul_new_path(_PATH_SYS_CPU);
@@ -329,8 +329,6 @@ int main(int argc, char *argv[])
cmd = CMD_CPU_DECONFIGURE;
cpu_parse(argv[optind - 1], cpu_set, setsize);
break;
- case 'h':
- usage();
case 'p':
if (strcmp("horizontal", argv[optind - 1]) == 0)
cmd = CMD_CPU_DISPATCH_HORIZONTAL;
@@ -343,9 +341,11 @@ int main(int argc, char *argv[])
case 'r':
cmd = CMD_CPU_RESCAN;
break;
+
+ case 'h':
+ usage();
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/chmem.c b/sys-utils/chmem.c
index 861f6cfd2..b3645be19 100644
--- a/sys-utils/chmem.c
+++ b/sys-utils/chmem.c
@@ -379,7 +379,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
ul_path_init_debug();
desc->sysmem = ul_new_path(_PATH_SYS_MEMORY);
@@ -402,18 +402,17 @@ int main(int argc, char **argv)
case 'b':
desc->use_blocks = 1;
break;
- case 'h':
- usage();
- break;
case 'v':
desc->verbose = 1;
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'z':
zone = xstrdup(optarg);
break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/choom.c b/sys-utils/choom.c
index eff95b6bf..1096ab186 100644
--- a/sys-utils/choom.c
+++ b/sys-utils/choom.c
@@ -94,7 +94,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, "hn:p:V", longopts, NULL)) != -1) {
switch (c) {
@@ -105,9 +105,9 @@ int main(int argc, char **argv)
adj = strtos32_or_err(optarg, _("invalid adjust argument"));
has_adj = 1;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/sys-utils/ctrlaltdel.c b/sys-utils/ctrlaltdel.c
index ea662c486..9ead94621 100644
--- a/sys-utils/ctrlaltdel.c
+++ b/sys-utils/ctrlaltdel.c
@@ -93,13 +93,12 @@ 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, "Vh", longopts, NULL)) != -1)
switch (ch) {
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index ba4e22528..f96e5bdf7 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -1354,7 +1354,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, "CcDdEeF:f:HhkL::l:n:iPprSs:TtuVwx",
longopts, NULL)) != -1) {
@@ -1395,9 +1395,6 @@ int main(int argc, char *argv[])
colormode = UL_COLORMODE_AUTO;
ctl.pager = 1;
break;
- case 'h':
- usage();
- break;
case 'k':
ctl.fltr_fac = 1;
setbit(ctl.facilities, FAC_BASE(LOG_KERN));
@@ -1447,9 +1444,6 @@ int main(int argc, char *argv[])
for (n = 1; (size_t) n < ARRAY_SIZE(facility_names); n++)
setbit(ctl.facilities, n);
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'w':
ctl.follow = 1;
break;
@@ -1459,6 +1453,11 @@ int main(int argc, char *argv[])
case OPT_TIME_FORMAT:
ctl.time_fmt = which_time_format(optarg);
break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/eject.c b/sys-utils/eject.c
index 81cd2bcff..d2e76d2ff 100644
--- a/sys-utils/eject.c
+++ b/sys-utils/eject.c
@@ -222,9 +222,6 @@ static void parse_args(struct eject_control *ctl, int argc, char **argv)
case 'F':
ctl->F_option = 1;
break;
- case 'h':
- usage();
- break;
case 'i':
ctl->i_option = 1;
ctl->i_arg = parse_switch(optarg, _("argument error"),
@@ -263,10 +260,11 @@ static void parse_args(struct eject_control *ctl, int argc, char **argv)
case 'v':
ctl->v_option = 1;
break;
+
+ case 'h':
+ usage();
case 'V':
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
- break;
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
break;
@@ -849,7 +847,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL,"");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
/* parse the command line arguments */
parse_args(&ctl, argc, argv);
diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c
index ba3867cae..04a3eaff5 100644
--- a/sys-utils/fallocate.c
+++ b/sys-utils/fallocate.c
@@ -312,7 +312,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, "hvVncpdizxl:o:", longopts, NULL))
!= -1) {
@@ -320,9 +320,6 @@ int main(int argc, char **argv)
err_exclusive_options(c, longopts, excl, excl_st);
switch(c) {
- case 'h':
- usage();
- break;
case 'c':
mode |= FALLOC_FL_COLLAPSE_RANGE;
break;
@@ -357,9 +354,11 @@ int main(int argc, char **argv)
case 'v':
verbose++;
break;
+
+ case 'h':
+ usage();
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/flock.c b/sys-utils/flock.c
index 57153c8d9..8dddebefd 100644
--- a/sys-utils/flock.c
+++ b/sys-utils/flock.c
@@ -169,7 +169,7 @@ int main(int argc, char *argv[])
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
strutils_set_exitcode(EX_USAGE);
@@ -216,9 +216,9 @@ int main(int argc, char *argv[])
case OPT_VERBOSE:
verbose = 1;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- exit(EX_OK);
+ print_version(EX_OK);
case 'h':
usage();
default:
diff --git a/sys-utils/fsfreeze.c b/sys-utils/fsfreeze.c
index 401ab5c98..4da1a6fa3 100644
--- a/sys-utils/fsfreeze.c
+++ b/sys-utils/fsfreeze.c
@@ -84,18 +84,17 @@ int main(int argc, char **argv)
err_exclusive_options(c, longopts, excl, excl_st);
switch(c) {
- case 'h':
- usage();
- break;
case 'f':
action = FREEZE;
break;
case 'u':
action = UNFREEZE;
break;
+
+ case 'h':
+ usage();
case 'V':
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c
index 830556458..87a9031b7 100644
--- a/sys-utils/fstrim.c
+++ b/sys-utils/fstrim.c
@@ -381,7 +381,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, "Aahl:m:no:Vv", longopts, NULL)) != -1) {
switch(c) {
@@ -394,12 +394,6 @@ int main(int argc, char **argv)
case 'n':
ctl.dryrun = 1;
break;
- case 'h':
- usage();
- break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'l':
ctl.range.len = strtosize_or_err(optarg,
_("failed to parse length"));
@@ -415,9 +409,13 @@ int main(int argc, char **argv)
case 'v':
ctl.verbose = 1;
break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
- break;
}
}
diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
index 5f4c014fc..9512f696e 100644
--- a/sys-utils/hwclock.c
+++ b/sys-utils/hwclock.c
@@ -1259,7 +1259,7 @@ int main(int argc, char **argv)
#endif
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
while ((c = getopt_long(argc, argv,
"hvVDd:alrsuwf:", longopts, NULL)) != -1) {
@@ -1359,9 +1359,9 @@ int main(int argc, char **argv)
ctl.rtc_dev_name = optarg; /* --rtc */
break;
#endif
+
case 'V': /* --version */
- out_version();
- return 0;
+ print_version(EXIT_SUCCESS);
case 'h': /* --help */
usage();
default:
diff --git a/sys-utils/ipcmk.c b/sys-utils/ipcmk.c
index df836525a..8aadffbbb 100644
--- a/sys-utils/ipcmk.c
+++ b/sys-utils/ipcmk.c
@@ -102,7 +102,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, "hM:QS:p:Vh", longopts, NULL)) != -1) {
switch(opt) {
@@ -120,12 +120,11 @@ int main(int argc, char **argv)
case 'p':
permission = strtoul(optarg, NULL, 8);
break;
+
case 'h':
usage();
- break;
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/ipcrm.c b/sys-utils/ipcrm.c
index a9f2d1b9a..5a27b7d20 100644
--- a/sys-utils/ipcrm.c
+++ b/sys-utils/ipcrm.c
@@ -328,7 +328,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
/* check to see if the command is being invoked in the old way if so
* then remove argument list */
@@ -400,11 +400,11 @@ int main(int argc, char **argv)
case 'v':
verbose = 1;
break;
+
case 'h':
usage();
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c
index 73cf28ab1..2d18a13cc 100644
--- a/sys-utils/ipcs.c
+++ b/sys-utils/ipcs.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 ((opt = getopt_long(argc, argv, options, longopts, NULL)) != -1) {
switch (opt) {
@@ -149,11 +149,11 @@ int main (int argc, char **argv)
case 'b':
unit = IPC_UNIT_BYTES;
break;
+
case 'h':
usage();
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/ldattach.c b/sys-utils/ldattach.c
index fb50711eb..3019e5a9f 100644
--- a/sys-utils/ldattach.c
+++ b/sys-utils/ldattach.c
@@ -354,9 +354,9 @@ int main(int argc, char **argv)
case 'i':
parse_iflag(optarg, &set_iflag, &clr_iflag);
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
index 3dbbcdd3e..d862fd8e7 100644
--- a/sys-utils/losetup.c
+++ b/sys-utils/losetup.c
@@ -683,9 +683,6 @@ int main(int argc, char **argv)
case 'f':
act = A_FIND_FREE;
break;
- case 'h':
- usage();
- break;
case 'J':
json = 1;
break;
@@ -730,13 +727,15 @@ int main(int argc, char **argv)
break;
case 'v':
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case OPT_SIZELIMIT: /* --sizelimit */
sizelimit = strtosize_or_err(optarg, _("failed to parse size"));
flags |= LOOPDEV_FL_SIZELIMIT;
break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 774a27b3a..9a5a1aa5b 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -2280,8 +2280,6 @@ int main(int argc, char *argv[])
}
mod->mode = OUTPUT_CACHES;
break;
- case 'h':
- usage();
case 'J':
mod->json = 1;
break;
@@ -2308,12 +2306,14 @@ int main(int argc, char *argv[])
case 'y':
mod->physical = 1;
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case OPT_OUTPUT_ALL:
all = 1;
break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/lsipc.c b/sys-utils/lsipc.c
index e8ada571e..5ba9cd7bf 100644
--- a/sys-utils/lsipc.c
+++ b/sys-utils/lsipc.c
@@ -1232,11 +1232,11 @@ int main(int argc, char *argv[])
case 'c':
show_creat = 1;
break;
+
case 'h':
usage();
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/lsmem.c b/sys-utils/lsmem.c
index 86383360a..a1272ae60 100644
--- a/sys-utils/lsmem.c
+++ b/sys-utils/lsmem.c
@@ -518,7 +518,7 @@ static void __attribute__((__noreturn__)) usage(void)
printf(USAGE_MAN_TAIL("lsmem(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
@@ -563,7 +563,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, "abhJno:PrS:s:V", longopts, NULL)) != -1) {
@@ -576,9 +576,6 @@ int main(int argc, char **argv)
case 'b':
lsmem->bytes = 1;
break;
- case 'h':
- usage();
- break;
case 'J':
lsmem->json = 1;
lsmem->want_summary = 0;
@@ -607,9 +604,6 @@ int main(int argc, char **argv)
case 'S':
splitarg = optarg;
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return 0;
case LSMEM_OPT_SUMARRY:
if (optarg) {
if (strcmp(optarg, "never") == 0)
@@ -623,6 +617,11 @@ int main(int argc, char **argv)
} else
lsmem->want_table = 0;
break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c
index 38ea2e009..c298d6a3c 100644
--- a/sys-utils/lsns.c
+++ b/sys-utils/lsns.c
@@ -960,7 +960,7 @@ int main(int argc, char *argv[])
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
lsns_init_debug();
memset(&ls, 0, sizeof(ls));
@@ -988,14 +988,9 @@ int main(int argc, char *argv[])
for (ncolumns = 0; ncolumns < ARRAY_SIZE(infos); ncolumns++)
columns[ncolumns] = ncolumns;
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'p':
ls.fltr_pid = strtos32_or_err(optarg, _("invalid PID argument"));
break;
- case 'h':
- usage();
case 'n':
ls.no_headings = 1;
break;
@@ -1019,6 +1014,11 @@ int main(int argc, char *argv[])
case 'W':
ls.no_wrap = 1;
break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/mount.c b/sys-utils/mount.c
index b1b43251e..b391347fc 100644
--- a/sys-utils/mount.c
+++ b/sys-utils/mount.c
@@ -655,7 +655,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
strutils_set_exitcode(MNT_EX_USAGE);
@@ -691,9 +691,6 @@ int main(int argc, char **argv)
case 'F':
mnt_context_enable_fork(cxt, TRUE);
break;
- case 'h':
- usage();
- break;
case 'i':
mnt_context_disable_helpers(cxt, TRUE);
break;
@@ -707,9 +704,6 @@ int main(int argc, char **argv)
case 'v':
mnt_context_enable_verbose(cxt, TRUE);
break;
- case 'V':
- mount_print_version();
- break;
case 'w':
append_option(cxt, "rw");
mnt_context_enable_rwonly_mount(cxt, TRUE);
@@ -829,6 +823,13 @@ int main(int argc, char **argv)
case MOUNT_OPT_OPTSRC_FORCE:
optmode |= MNT_OMODE_FORCE;
break;
+
+ case 'h':
+ mnt_free_context(cxt);
+ usage();
+ case 'V':
+ mnt_free_context(cxt);
+ mount_print_version();
default:
errtryhelp(MNT_EX_USAGE);
}
diff --git a/sys-utils/mountpoint.c b/sys-utils/mountpoint.c
index 00a74daf0..985130cba 100644
--- a/sys-utils/mountpoint.c
+++ b/sys-utils/mountpoint.c
@@ -149,7 +149,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
mnt_init_debug(0);
@@ -165,12 +165,11 @@ int main(int argc, char **argv)
case 'x':
ctl.dev_devno = 1;
break;
+
case 'h':
usage();
- break;
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/nsenter.c b/sys-utils/nsenter.c
index fbfcf9831..f294b1257 100644
--- a/sys-utils/nsenter.c
+++ b/sys-utils/nsenter.c
@@ -245,17 +245,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, "+ahVt:m::u::i::n::p::C::U::S:G:r::w::FZ",
longopts, NULL)) != -1) {
switch (c) {
- case 'h':
- usage();
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'a':
do_all = true;
break;
@@ -336,6 +331,10 @@ int main(int argc, char *argv[])
selinux = 1;
break;
#endif
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/pivot_root.c b/sys-utils/pivot_root.c
index ea76d94bf..aef1b12bb 100644
--- a/sys-utils/pivot_root.c
+++ b/sys-utils/pivot_root.c
@@ -55,13 +55,12 @@ 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, "Vh", longopts, NULL)) != -1)
switch (ch) {
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c
index 6f806362d..607849066 100644
--- a/sys-utils/prlimit.c
+++ b/sys-utils/prlimit.c
@@ -516,7 +516,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
INIT_LIST_HEAD(&lims);
@@ -584,8 +584,6 @@ int main(int argc, char **argv)
errx(EXIT_FAILURE, _("option --pid may be specified only once"));
pid = strtos32_or_err(optarg, _("invalid PID argument"));
break;
- case 'h':
- usage();
case 'o':
ncolumns = string_to_idarray(optarg,
columns, ARRAY_SIZE(columns),
@@ -593,10 +591,6 @@ int main(int argc, char **argv)
if (ncolumns < 0)
return EXIT_FAILURE;
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
-
case NOHEADINGS_OPTION:
no_headings = 1;
break;
@@ -606,6 +600,11 @@ int main(int argc, char **argv)
case RAW_OPTION:
raw = 1;
break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/readprofile.c b/sys-utils/readprofile.c
index ca0037529..1d484252a 100644
--- a/sys-utils/readprofile.c
+++ b/sys-utils/readprofile.c
@@ -169,7 +169,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
proFile = defaultpro;
mapFile = defaultmap;
@@ -206,9 +206,9 @@ int main(int argc, char **argv)
case 'v':
optVerbose++;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/sys-utils/renice.c b/sys-utils/renice.c
index 3ae71f9c1..5efecdfd0 100644
--- a/sys-utils/renice.c
+++ b/sys-utils/renice.c
@@ -119,7 +119,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
argc--;
argv++;
@@ -131,10 +131,8 @@ int main(int argc, char **argv)
if (strcmp(*argv, "-v") == 0 ||
strcmp(*argv, "-V") == 0 ||
- strcmp(*argv, "--version") == 0) {
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
- }
+ strcmp(*argv, "--version") == 0)
+ print_version(EXIT_SUCCESS);
}
if (*argv && (strcmp(*argv, "-n") == 0 || strcmp(*argv, "--priority") == 0)) {
diff --git a/sys-utils/rfkill.c b/sys-utils/rfkill.c
index a93e8ba83..b00bf753e 100644
--- a/sys-utils/rfkill.c
+++ b/sys-utils/rfkill.c
@@ -637,7 +637,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, "Jno:rVh", longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
@@ -657,9 +657,9 @@ int main(int argc, char **argv)
case 'r':
ctrl.raw = 1;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c
index 029f00f9b..1058e8af9 100644
--- a/sys-utils/rtcwake.c
+++ b/sys-utils/rtcwake.c
@@ -457,7 +457,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
while ((t = getopt_long(argc, argv, "A:ahd:lm:ns:t:uVv",
long_options, NULL)) != EOF) {
@@ -511,9 +511,9 @@ int main(int argc, char **argv)
case 'v':
ctl.verbose = 1;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c
index fb4c4d333..f84e90b5b 100644
--- a/sys-utils/setarch.c
+++ b/sys-utils/setarch.c
@@ -315,7 +315,7 @@ int main(int argc, char *argv[])
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
if (argc < 1) {
warnx(_("Not enough arguments"));
@@ -343,12 +343,6 @@ int main(int argc, char *argv[])
while ((c = getopt_long(argc, argv, "+hVv3BFILRSTXZ", longopts, NULL)) != -1) {
switch (c) {
- case 'h':
- usage(archwrapper);
- break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'v':
verbose = 1;
break;
@@ -394,8 +388,13 @@ int main(int argc, char *argv[])
} else
warnx(_("unrecognized option '--list'"));
/* fallthrough */
+
default:
errtryhelp(EXIT_FAILURE);
+ case 'h':
+ usage(archwrapper);
+ case 'V':
+ print_version(EXIT_SUCCESS);
}
}
diff --git a/sys-utils/setpriv.c b/sys-utils/setpriv.c
index 828ddc12f..717031d94 100644
--- a/sys-utils/setpriv.c
+++ b/sys-utils/setpriv.c
@@ -837,7 +837,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
memset(&opts, 0, sizeof(opts));
@@ -971,11 +971,11 @@ int main(int argc, char **argv)
case RESET_ENV:
opts.reset_env = 1;
break;
+
case 'h':
usage();
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/setsid.c b/sys-utils/setsid.c
index 8b4f83dd2..5725e8009 100644
--- a/sys-utils/setsid.c
+++ b/sys-utils/setsid.c
@@ -66,13 +66,10 @@ 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, "+Vhcfw", longopts, NULL)) != -1)
switch (ch) {
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'c':
ctty=1;
break;
@@ -82,8 +79,11 @@ int main(int argc, char **argv)
case 'w':
status = 1;
break;
+
case 'h':
usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/swapoff.c b/sys-utils/swapoff.c
index 0a3807fda..a13d4f1e5 100644
--- a/sys-utils/swapoff.c
+++ b/sys-utils/swapoff.c
@@ -197,7 +197,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, "ahvVL:U:",
long_opts, NULL)) != -1) {
@@ -205,21 +205,20 @@ int main(int argc, char *argv[])
case 'a': /* all */
++all;
break;
- case 'h': /* help */
- usage();
- break;
case 'v': /* be chatty */
++verbose;
break;
- case 'V': /* version */
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'L':
add_label(optarg);
break;
case 'U':
add_uuid(optarg);
break;
+
+ case 'h': /* help */
+ usage();
+ case 'V': /* version */
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c
index 357dcb3f7..7e3135c72 100644
--- a/sys-utils/swapon.c
+++ b/sys-utils/swapon.c
@@ -883,7 +883,7 @@ int main(int argc, char *argv[])
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
memset(&ctl, 0, sizeof(struct swapon_ctl));
ctl.props.priority = -1;
@@ -900,9 +900,6 @@ int main(int argc, char *argv[])
case 'a': /* all */
ctl.all = 1;
break;
- case 'h': /* help */
- usage();
- break;
case 'o':
options = optarg;
break;
@@ -966,11 +963,13 @@ int main(int argc, char *argv[])
case BYTES_OPTION:
ctl.bytes = 1;
break;
- case 'V': /* version */
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 0:
break;
+
+ case 'h': /* help */
+ usage();
+ case 'V': /* version */
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c
index a85ce24b9..a42bceca3 100644
--- a/sys-utils/switch_root.c
+++ b/sys-utils/switch_root.c
@@ -225,13 +225,12 @@ int main(int argc, char *argv[])
{NULL, 0, NULL, 0}
};
- 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/sys-utils/tunelp.c b/sys-utils/tunelp.c
index fe261f393..b1e7f75df 100644
--- a/sys-utils/tunelp.c
+++ b/sys-utils/tunelp.c
@@ -144,7 +144,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
strutils_set_exitcode(EXIT_LP_BADVAL);
@@ -159,9 +159,6 @@ int main(int argc, char **argv)
show_irq = 1;
while ((c = getopt_long(argc, argv, "t:c:w:a:i:ho:C:sq:rT:vV", longopts, NULL)) != -1) {
switch (c) {
- case 'h':
- usage();
- break;
case 'i':
cmds->op = LPSETIRQ;
cmds->val = strtol_or_err(optarg, _("argument error"));
@@ -229,10 +226,12 @@ int main(int argc, char **argv)
cmds = cmds->next;
cmds->next = NULL;
break;
+
+ case 'h':
+ usage();
case 'v':
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/umount.c b/sys-utils/umount.c
index 929da8d91..e3734b0ec 100644
--- a/sys-utils/umount.c
+++ b/sys-utils/umount.c
@@ -479,7 +479,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
mnt_init_debug(0);
cxt = mnt_new_context();
@@ -517,9 +517,6 @@ int main(int argc, char **argv)
case 'f':
mnt_context_enable_force(cxt, TRUE);
break;
- case 'h':
- usage();
- break;
case 'i':
mnt_context_disable_helpers(cxt, TRUE);
break;
@@ -548,9 +545,6 @@ int main(int argc, char **argv)
case 'v':
mnt_context_enable_verbose(cxt, TRUE);
break;
- case 'V':
- umount_print_version();
- break;
case 'N':
{
char path[PATH_MAX];
@@ -563,6 +557,13 @@ int main(int argc, char **argv)
err(MNT_EX_SYSERR, _("failed to set target namespace to %s"), pid ? path : optarg);
break;
}
+
+ case 'h':
+ mnt_free_context(cxt);
+ usage();
+ case 'V':
+ mnt_free_context(cxt);
+ umount_print_version();
default:
errtryhelp(MNT_EX_USAGE);
}
diff --git a/sys-utils/unshare.c b/sys-utils/unshare.c
index e9ddb09de..21910a4ee 100644
--- a/sys-utils/unshare.c
+++ b/sys-utils/unshare.c
@@ -335,18 +335,13 @@ 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, "+fhVmuinpCUrR:w:S:G:", longopts, NULL)) != -1) {
switch (c) {
case 'f':
forkit = 1;
break;
- case 'h':
- usage();
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'm':
unshare_flags |= CLONE_NEWNS;
if (optarg)
@@ -420,6 +415,11 @@ int main(int argc, char *argv[])
case 'w':
newdir = optarg;
break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/wdctl.c b/sys-utils/wdctl.c
index 642db85d2..4574e10da 100644
--- a/sys-utils/wdctl.c
+++ b/sys-utils/wdctl.c
@@ -505,7 +505,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,
"d:f:hFnITo:s:OrVx", long_opts, NULL)) != -1) {
@@ -527,11 +527,6 @@ int main(int argc, char *argv[])
if (string_to_bitmask(optarg, (unsigned long *) &wanted, name2bit) != 0)
return EXIT_FAILURE;
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
- case 'h':
- usage();
case 'F':
noflags = 1;
break;
@@ -554,6 +549,11 @@ int main(int argc, char *argv[])
noident = 1;
notimeouts = 1;
break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c
index 69267c860..dedfa345e 100644
--- a/sys-utils/zramctl.c
+++ b/sys-utils/zramctl.c
@@ -616,7 +616,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, "a:bfho:nrs:t:V", longopts, NULL)) != -1) {
@@ -659,9 +659,9 @@ int main(int argc, char **argv)
case 'n':
no_headings = 1;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/term-utils/mesg.c b/term-utils/mesg.c
index 608f3cf61..57d53379f 100644
--- a/term-utils/mesg.c
+++ b/term-utils/mesg.c
@@ -102,16 +102,16 @@ 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, "vVh", longopts, NULL)) != -1)
switch (ch) {
case 'v':
verbose = TRUE;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/term-utils/script.c b/term-utils/script.c
index 7692f91e2..c7bc1d6f2 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -793,7 +793,7 @@ int main(int argc, char **argv)
setlocale(LC_NUMERIC, "C");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
script_init_debug();
@@ -825,13 +825,11 @@ int main(int argc, char **argv)
ctl.tname = optarg;
ctl.timing = 1;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
- break;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
- break;
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/term-utils/scriptreplay.c b/term-utils/scriptreplay.c
index 7b59b6e24..926e56f11 100644
--- a/term-utils/scriptreplay.c
+++ b/term-utils/scriptreplay.c
@@ -151,7 +151,7 @@ main(int argc, char *argv[])
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
while ((ch = getopt_long(argc, argv, "t:s:d:m:Vh", longopts, NULL)) != -1)
switch(ch) {
@@ -169,9 +169,9 @@ main(int argc, char *argv[])
maxdelayopt = TRUE;
maxdelay = getnum(optarg);
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/term-utils/setterm.c b/term-utils/setterm.c
index 0d4b81292..14fbafb10 100644
--- a/term-utils/setterm.c
+++ b/term-utils/setterm.c
@@ -673,9 +673,9 @@ static void parse_option(struct setterm_control *ctl, int ac, char **av)
ctl->opt_bfreq = set_opt_flag(ctl->opt_bfreq);
ctl->opt_bfreq_f = parse_bfreq(av, optarg, &optind);
break;
+
case OPT_VERSION:
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
+ print_version(EXIT_SUCCESS);
case OPT_HELP:
usage();
default:
@@ -1173,7 +1173,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(_("bad usage"));
diff --git a/term-utils/wall.c b/term-utils/wall.c
index ce5363c7e..c606e6347 100644
--- a/term-utils/wall.c
+++ b/term-utils/wall.c
@@ -202,7 +202,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, "nt:g:Vh", longopts, NULL)) != -1) {
switch (ch) {
@@ -220,9 +220,9 @@ int main(int argc, char **argv)
case 'g':
group_buf = init_group_workspace(optarg);
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/term-utils/write.c b/term-utils/write.c
index bd64fc281..3436fbda2 100644
--- a/term-utils/write.c
+++ b/term-utils/write.c
@@ -308,13 +308,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/text-utils/col.c b/text-utils/col.c
index 1ba195e24..5ad38bc97 100644
--- a/text-utils/col.c
+++ b/text-utils/col.c
@@ -190,7 +190,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
max_bufd_lines = 128 * 2;
compress_spaces = 1; /* compress spaces into tabs */
@@ -220,9 +220,9 @@ int main(int argc, char **argv)
case 'x': /* do not compress spaces into tabs */
compress_spaces = 0;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'H':
usage();
default:
diff --git a/text-utils/colcrt.c b/text-utils/colcrt.c
index 6113880e4..798f5bd7b 100644
--- a/text-utils/colcrt.c
+++ b/text-utils/colcrt.c
@@ -239,7 +239,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
/* Take care of lonely hyphen option. */
for (opt = 0; opt < argc; opt++) {
@@ -260,9 +260,9 @@ int main(int argc, char **argv)
case '2':
ctl.half_lines = 1;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/text-utils/colrm.c b/text-utils/colrm.c
index 8bb0ee9cc..d0ef2eb66 100644
--- a/text-utils/colrm.c
+++ b/text-utils/colrm.c
@@ -173,8 +173,7 @@ int main(int argc, char **argv)
NULL)) != -1)
switch (opt) {
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/text-utils/column.c b/text-utils/column.c
index 8961bd38b..78eeddb8e 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -706,7 +706,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
ctl.output_separator = " ";
ctl.input_separator = mbs_to_wcs("\t ");
@@ -731,9 +731,6 @@ int main(int argc, char **argv)
case 'H':
ctl.tab_colhide = optarg;
break;
- case 'h':
- usage();
- break;
case 'i':
ctl.tree_id = optarg;
break;
@@ -776,15 +773,17 @@ int main(int argc, char **argv)
case 't':
ctl.mode = COLUMN_MODE_TABLE;
break;
- case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
case 'W':
ctl.tab_colwrap = optarg;
break;
case 'x':
ctl.mode = COLUMN_MODE_FILLROWS;
break;
+
+ case 'h':
+ usage();
+ case 'V':
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
diff --git a/text-utils/hexdump.c b/text-utils/hexdump.c
index 94c53b8e5..cbd593e5f 100644
--- a/text-utils/hexdump.c
+++ b/text-utils/hexdump.c
@@ -130,12 +130,11 @@ parse_args(int argc, char **argv, struct hexdump *hex)
add_fmt(hex_offt, hex);
add_fmt("\"%07.7_ax \" 8/2 \" %04x \" \"\\n\"", hex);
break;
+
case 'h':
usage();
case 'V':
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
- break;
+ print_version(EXIT_SUCCESS);
default:
errtryhelp(EXIT_FAILURE);
}
@@ -193,7 +192,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
argv += parse_args(argc, argv, hex);
diff --git a/text-utils/line.c b/text-utils/line.c
index 63c001261..e89407618 100644
--- a/text-utils/line.c
+++ b/text-utils/line.c
@@ -54,13 +54,12 @@ 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, "Vh", longopts, NULL)) != -1)
switch (opt) {
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/text-utils/more.c b/text-utils/more.c
index 8d394bc30..6e1ca569c 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -275,7 +275,7 @@ static void arg_parser(struct more_control *ctl, char *s)
case '\t':
break;
case 'V':
- printf(UTIL_LINUX_VERSION);
+ print_version(EXIT_SUCCESS);
exit(EXIT_SUCCESS);
break;
default:
@@ -1920,16 +1920,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);
- exit(EXIT_SUCCESS);
- }
+ if (!strcmp(argv[1], "--version"))
+ print_version(EXIT_SUCCESS);
}
ctl.num_files = argc;
diff --git a/text-utils/pg.c b/text-utils/pg.c
index f441c04f0..7eef9b88b 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -1544,7 +1544,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
if (tcgetattr(STDOUT_FILENO, &otio) == 0) {
ontty = 1;
@@ -1570,7 +1570,7 @@ int main(int argc, char **argv)
}
if (!strcmp(argv[arg], "--version")) {
- printf(UTIL_LINUX_VERSION);
+ print_version(EXIT_SUCCESS);
return EXIT_SUCCESS;
}
@@ -1621,11 +1621,11 @@ int main(int argc, char **argv)
case 's':
sflag = 1;
break;
+
case 'h':
usage();
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
default:
invopt(&argv[arg][i]);
}
diff --git a/text-utils/rev.c b/text-utils/rev.c
index 13a41f633..57624e6fb 100644
--- a/text-utils/rev.c
+++ b/text-utils/rev.c
@@ -113,7 +113,7 @@ int main(int argc, char *argv[])
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);
@@ -121,8 +121,7 @@ int main(int argc, char *argv[])
while ((ch = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1)
switch(ch) {
case 'V':
- printf(UTIL_LINUX_VERSION);
- exit(EXIT_SUCCESS);
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default:
diff --git a/text-utils/ul.c b/text-utils/ul.c
index b5ce4db84..3a9e31bc7 100644
--- a/text-utils/ul.c
+++ b/text-utils/ul.c
@@ -172,7 +172,7 @@ int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);
@@ -191,9 +191,9 @@ int main(int argc, char **argv)
case 'i':
iflag = 1;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default: