misc: consolidate version printing and close_stdout()

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2019-04-16 15:14:13 +02:00
parent 68224d108d
commit 2c308875a7
116 changed files with 391 additions and 466 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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();

View File

@ -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;

View File

@ -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:

View File

@ -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:

View File

@ -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)

View File

@ -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 */

View File

@ -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)

View File

@ -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:

View File

@ -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:

View File

@ -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"));

View File

@ -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);

View File

@ -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;

View File

@ -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:

View File

@ -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:

View File

@ -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);
}

View File

@ -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:

View File

@ -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:

View File

@ -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;

View File

@ -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;

View File

@ -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"
*/

View File

@ -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 */

View File

@ -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) {

View File

@ -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]);

View File

@ -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;

View File

@ -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:

View File

@ -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> "

View File

@ -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

View File

@ -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:

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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:

View File

@ -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);

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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);
}

View File

@ -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."));
}

View File

@ -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:

View File

@ -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);

View File

@ -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);
}

View File

@ -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:

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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:

View File

@ -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);
}

View File

@ -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:

View File

@ -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:

View File

@ -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);
}

View File

@ -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:

View File

@ -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:

View File

@ -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);
}

View File

@ -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:

View File

@ -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:

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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:

View File

@ -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:

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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:

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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:

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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:

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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:

View File

@ -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);
}

View File

@ -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:

View File

@ -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)) {

View File

@ -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:

View File

@ -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:

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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:

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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:

Some files were not shown because too many files have changed in this diff Show More