static size_t blksize = 0;
-
-/* Input status of 0 to print help and exit without an error. */
-static void __attribute__((__noreturn__)) usage(int status)
+static void __attribute__((__noreturn__)) usage(void)
{
- FILE *out = status ? stderr : stdout;
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out,
fputs(USAGE_VERSION, out);
fputs(USAGE_SEPARATOR, out);
- exit(status);
+ exit(FSCK_EX_OK);
}
static int get_superblock_endianness(uint32_t magic)
case 'y':
break;
case 'h':
- usage(FSCK_EX_OK);
+ usage();
break;
case 'V':
printf(UTIL_LINUX_VERSION);
errtryhelp(FSCK_EX_USAGE);
}
- if ((argc - optind) != 1)
- usage(FSCK_EX_USAGE);
+ if ((argc - optind) != 1){
+ warnx(_("bad usage"));
+ errtryhelp(FSCK_EX_USAGE);
+ }
filename = argv[optind];
test_super(&start, &length);
static int query(int minor_raw, const char *raw_name, int quiet);
static int bind(int minor_raw, int block_major, int block_minor);
-static void __attribute__ ((__noreturn__)) usage(int err)
+static void __attribute__((__noreturn__)) usage(void)
{
- FILE *out = err == EXIT_SUCCESS ? stdout : stderr;
-
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out,
_(" %1$s %2$srawN <major> <minor>\n"
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("raw(8)"));
- exit(err);
+ exit(EXIT_SUCCESS);
}
static long strtol_octal_or_err(const char *str, const char *errmesg)
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(EXIT_SUCCESS);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
open_raw_ctl();
if (do_query_all) {
- if (optind < argc)
- usage(EXIT_FAILURE);
+ if (optind < argc) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
for (i = 1; i < RAW_NR_MINORS; i++)
query(i, NULL, 1);
exit(EXIT_SUCCESS);
* It's a bind or a single query. Either way we need a raw device.
*/
- if (optind >= argc)
- usage(EXIT_FAILURE);
+ if (optind >= argc) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
raw_name = argv[optind++];
/*
* causes udev to *remove* /dev/rawctl
*/
rc = sscanf(raw_name, _PATH_RAWDEVDIR "raw%d", &raw_minor);
- if (rc != 1)
- usage(EXIT_FAILURE);
-
+ if (rc != 1) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
if (raw_minor == 0)
errx(EXIT_RAW_ACCESS,
_("Device '%s' is the control raw device "
break;
default:
- usage(EXIT_FAILURE);
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
}
return bind(raw_minor, block_major, block_minor);
}
static void __attribute__((__noreturn__))
-usage (const int status)
+usage(void)
{
if (su_mode == RUNUSER_MODE) {
fputs(USAGE_HEADER, stdout);
fputs(USAGE_HELP, stdout);
fputs(USAGE_VERSION, stdout);
printf(USAGE_MAN_TAIL(su_mode == SU_MODE ? "su(1)" : "runuser(1)"));
- exit (status);
+ exit(EXIT_SUCCESS);
}
static
break;
case 'u':
- if (su_mode != RUNUSER_MODE)
- usage (EXIT_FAILURE);
+ if (su_mode != RUNUSER_MODE) {
+ warnx(_("invalid option -- 'u'"));
+ errtryhelp(EXIT_FAILURE);
+ }
runuser_user = optarg;
break;
case 'h':
- usage(0);
+ usage();
case 'V':
printf(UTIL_LINUX_VERSION);
#define FINDFS_NOT_FOUND 1 /* label or uuid cannot be found */
#define FINDFS_USAGE_ERROR 2 /* user did something unexpected */
-static void __attribute__((__noreturn__)) usage(int rc)
+static void __attribute__((__noreturn__)) usage(void)
{
- FILE *out = rc ? stderr : stdout;
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] {LABEL,UUID,PARTUUID,PARTLABEL}=<value>\n"),
program_invocation_short_name);
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("findfs(8)"));
- exit(rc);
+ exit(FINDFS_SUCCESS);
}
int main(int argc, char **argv)
textdomain(PACKAGE);
atexit(close_stdout);
- if (argc != 2)
+ if (argc != 2) {
/* we return '2' for backward compatibility
* with version from e2fsprogs */
- usage(FINDFS_USAGE_ERROR);
+ warnx(_("bad usage"));
+ errtryhelp(FINDFS_USAGE_ERROR);
+ }
while ((c = getopt_long(argc, argv, "Vh", longopts, NULL)) != -1)
switch (c) {
printf(UTIL_LINUX_VERSION);
return FINDFS_SUCCESS;
case 'h':
- usage(FINDFS_SUCCESS);
+ usage();
default:
errtryhelp(FINDFS_USAGE_ERROR);
}
return 0;
}
-static void usage(int rc)
+static void __attribute__((__noreturn__)) usage(void)
{
const char *p = program_invocation_short_name;
- FILE *out = rc == EXIT_FAILURE ? stderr : stdout;
+ FILE *out = stdout;
if (!*p)
p = "namei";
" -v, --vertical vertical align of modes and owners\n"), out);
fprintf(out, USAGE_MAN_TAIL("namei(1)"));
- exit(rc);
+ exit(EXIT_SUCCESS);
}
static const struct option longopts[] =
while ((c = getopt_long(argc, argv, "hVlmnovx", longopts, NULL)) != -1) {
switch(c) {
case 'h':
- usage(EXIT_SUCCESS);
+ usage();
break;
case 'V':
printf(UTIL_LINUX_VERSION);
if (optind == argc) {
warnx(_("pathname argument is missing"));
- usage(EXIT_FAILURE);
+ errtryhelp(EXIT_FAILURE);
}
ucache = new_idcache();
verbose : 1; /* verbose output */
};
-static void __attribute__((__noreturn__)) show_usage(int rc)
+static void __attribute__((__noreturn__)) usage(void)
{
- FILE *out = rc == EXIT_SUCCESS ? stdout : stderr;
+ FILE *out = stdout;
fputs(_("Show or change the real-time scheduling attributes of a process.\n"), out);
fputs(USAGE_SEPARATOR, out);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("chrt(1)"));
- exit(rc);
+ exit(EXIT_SUCCESS);
}
static const char *get_policy_name(int policy)
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- show_usage(EXIT_SUCCESS);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
}
if (((ctl->pid > -1) && argc - optind < 1) ||
- ((ctl->pid == -1) && argc - optind < 2))
- show_usage(EXIT_FAILURE);
+ ((ctl->pid == -1) && argc - optind < 2)) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+}
if ((ctl->pid > -1) && (ctl->verbose || argc - optind == 1)) {
show_sched_info(ctl);
}
-static void __attribute__ ((__noreturn__)) usage(int exitcode)
+static void __attribute__((__noreturn__)) usage(void)
{
- FILE *out = exitcode == EXIT_SUCCESS ? stdout : stderr;
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] <ldisc> <device>\n"), program_invocation_short_name);
print_table(out, ld_iflags);
fprintf(out, USAGE_MAN_TAIL("ldattach(8)"));
- exit(exitcode);
+ exit(EXIT_SUCCESS);
}
static int my_cfsetspeed(struct termios *ts, int speed)
/* parse options */
if (argc == 0)
- usage(EXIT_SUCCESS);
+ errx(EXIT_FAILURE, _("bad usage"));
+
while ((optc =
getopt_long(argc, argv, "dhV78neo12s:i:c:p:", opttbl,
NULL)) >= 0) {
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(EXIT_SUCCESS);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
}
- if (argc - optind != 2)
- usage(EXIT_FAILURE);
-
+ if (argc - optind != 2) {
+ warnx(_("not enough arguments"));
+ errtryhelp(EXIT_FAILURE);
+ }
/* parse line discipline specification */
ldisc = lookup_table(ld_discs, argv[optind]);
if (ldisc < 0)