#include "partx.h"
#include "strutils.h"
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s <disk device> <partition number> <start> <length>\n"),
program_invocation_short_name);
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("addpart(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
- if (argc != 5)
- usage(stderr);
+ if (argc != 5) {
+ warnx(_("not enough arguments"));
+ errtryhelp(EXIT_FAILURE);
+ }
if ((fd = open(argv[1], O_RDONLY)) < 0)
err(EXIT_FAILURE, _("cannot open %s"), argv[1]);
#include "partx.h"
#include "strutils.h"
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s <disk device> <partition number>\n"),
program_invocation_short_name);
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("delpart(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
- if (argc != 3)
- usage(stderr);
+ if (argc != 3) {
+ warnx(_("not enough arguments"));
+ errtryhelp(EXIT_FAILURE);
+ }
if ((fd = open(argv[1], O_RDONLY)) < 0)
printf(_("done\n"));
}
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] <device>\n"),
program_invocation_short_name);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("fdformat(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
printf(UTIL_LINUX_VERSION);
exit(EXIT_SUCCESS);
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
argc -= optind;
argv += optind;
- if (argc < 1)
- usage(stderr);
+ if (argc < 1) {
+ warnx(_("no device specified"));
+ errtryhelp(EXIT_FAILURE);
+ }
if (stat(argv[0], &st) < 0)
err(EXIT_FAILURE, _("stat of %s failed"), argv[0]);
if (!S_ISBLK(st.st_mode))
fdisk_get_collision(cxt));
}
-static void __attribute__ ((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
+
fputs(USAGE_HEADER, out);
fprintf(out,
list_available_columns(out);
fprintf(out, USAGE_MAN_TAIL("fdisk(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
size_t sz = strtou32_or_err(optarg,
_("invalid sector size argument"));
if (sz != 512 && sz != 1024 && sz != 2048 && sz != 4096)
- usage(stderr);
+ errx(EXIT_FAILURE, _("invalid sector size argument"));
fdisk_save_user_sector_size(cxt, sz, sz);
break;
}
fdisk_dos_enable_compatible(lb, TRUE);
else if (strcmp(p, "nondos") == 0)
fdisk_dos_enable_compatible(lb, FALSE);
- else {
- warnx(_("unknown compatibility mode '%s'"), p);
- usage(stderr);
- }
+ else
+ errx(EXIT_FAILURE, _("unknown compatibility mode '%s'"), p);
}
/* use default if no optarg specified */
break;
if (optarg && *optarg == '=')
optarg++;
if (fdisk_set_unit(cxt, optarg) != 0)
- usage(stderr);
+ errx(EXIT_FAILURE, _("unsupported unit"));
break;
case 'V': /* preferred for util-linux */
case 'v': /* for backward compatibility only */
errx(EXIT_FAILURE, _("unsupported wipe mode"));
break;
case 'h':
- usage(stdout);
+ usage();
case OPT_BYTES:
fdisk_set_size_unit(cxt, FDISK_SIZEUNIT_BYTES);
break;
case ACT_SHOWSIZE:
/* deprecated */
- if (argc - optind <= 0)
- usage(stderr);
-
+ if (argc - optind <= 0) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
for (i = optind; i < argc; i++) {
uintmax_t blks = get_dev_blocks(argv[i]);
break;
case ACT_FDISK:
- if (argc-optind != 1)
- usage(stderr);
+ if (argc-optind != 1) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
/* Here starts interactive mode, use fdisk_{warn,info,..} functions */
color_scheme_enable("welcome", UL_COLOR_GREEN);
}
static void __attribute__((__noreturn__))
-usage(FILE *out) {
+usage(void) {
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] <device>\n"), program_invocation_short_name);
fputs(USAGE_SEPARATOR, out);
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("fsck.minix(8)"));
- leave(out == stderr ? FSCK_EX_USAGE : FSCK_EX_OK);
+ exit(FSCK_EX_OK);
}
static void die(const char *fmt, ...)
printf(UTIL_LINUX_VERSION);
return FSCK_EX_OK;
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(FSCK_EX_USAGE);
}
argv += optind;
if (0 < argc) {
device_name = argv[0];
- } else
- usage(stderr);
-
+ } else {
+ warnx(_("no device specified"));
+ errtryhelp(FSCK_EX_USAGE);
+ }
check_mount(); /* trying to check a mounted filesystem? */
if (repair && !automatic && (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO)))
die(_("need terminal for interactive repairs"));
close(fd);
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out,
_(" %s [options] <iso9660_image_file>\n"),
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("isosize(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
ct = argc - optind;
- if (ct <= 0)
- usage(stderr);
+ if (ct <= 0) {
+ warnx(_("no device specified"));
+ errtryhelp(EXIT_FAILURE);
+ }
for (j = optind; j < argc; j++)
isosize(ct, argv[j], xflag, divisor);
char d_name[BFS_NAMELEN];
};
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fprintf(out,
_("Usage: %s [options] device [block-count]\n"),
program_invocation_short_name);
" -h, --help display this help and exit\n\n"));
fprintf(out, USAGE_MAN_TAIL("mkfs.bfs(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
static void __attribute__ ((__noreturn__)) print_version(void)
textdomain(PACKAGE);
atexit(close_stdout);
- if (argc < 2)
- usage(stderr);
-
+ if (argc < 2) {
+ warnx(_("not enough arguments"));
+ errtryhelp(EXIT_FAILURE);
+ }
if (argc == 2 && !strcmp(argv[1], "-V"))
print_version();
case VERSION_OPTION:
print_version();
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
}
- if (optind == argc)
- usage(stderr);
+ if (optind == argc) {
+ warnx(_("no device specified"));
+ errtryhelp(EXIT_FAILURE);
+ }
device = argv[optind++];
if (optind == argc - 1)
user_specified_total_blocks =
strtou64_or_err(argv[optind], _("invalid block-count"));
- else if (optind != argc)
- usage(stderr);
+ else if (optind != argc) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
if (blkdev_get_sectors(fd, &total_blocks) == -1) {
if (!user_specified_total_blocks)
#define DEFAULT_FSTYPE "ext2"
#endif
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] [-t <type>] [fs-options] <device> [<size>]\n"),
program_invocation_short_name);
fprintf(out, USAGE_MAN_TAIL("mkfs(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
static void __attribute__ ((__noreturn__)) print_version(void)
fstype = optarg;
break;
case 'h':
- usage(stdout);
+ usage();
case VERSION_OPTION:
print_version();
default:
more = 1;
break; /* start of specific arguments */
}
- if (optind == argc)
- usage(stderr);
+ if (optind == argc) {
+ warnx(_("no device specified"));
+ errtryhelp(EXIT_FAILURE);
+ }
/* If -t wasn't specified, use the default */
if (fstype == NULL)
#define mark_zone(x) (setbit(zone_map,(x)-get_first_zone()+1))
#define unmark_zone(x) (clrbit(zone_map,(x)-get_first_zone()+1))
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] /dev/name [blocks]\n"), program_invocation_short_name);
fputs(USAGE_OPTIONS, out);
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("mkfs.minix(8)"));
- exit(out == stderr ? MKFS_EX_USAGE : MKFS_EX_OK);
+ exit(MKFS_EX_OK);
}
#ifdef TEST_SCRIPT
printf(UTIL_LINUX_VERSION);
return MKFS_EX_OK;
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(MKFS_EX_USAGE);
}
ctl.fs_blocks = strtoul_or_err(argv[0], _("failed to parse number of blocks"));
if (!ctl.device_name) {
- usage(stderr);
+ warnx(_("no device specified"));
+ errtryhelp(MKFS_EX_USAGE);
}
check_user_instructions(&ctl);
if (is_mounted(ctl.device_name))
}
}
-static void __attribute__ ((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fprintf(out,
_("\nUsage:\n"
" %s [options] device [size]\n"),
" -V, --version output version information and exit\n"
" -h, --help display this help and exit\n\n"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
static void page_bad(struct mkswap_control *ctl, unsigned int page)
printf(UTIL_LINUX_VERSION);
exit(EXIT_SUCCESS);
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
block_count = argv[optind++];
if (optind != argc) {
warnx(_("only one device argument is currently supported"));
- usage(stderr);
+ errtryhelp(EXIT_FAILURE);
}
#ifdef HAVE_LIBUUID
if (!ctl.devname) {
warnx(_("error: Nowhere to set up swap on?"));
- usage(stderr);
+ errtryhelp(EXIT_FAILURE);
}
if (block_count) {
/* this silly user specified the number of blocks explicitly */
return ls;
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
size_t i;
fputs(USAGE_HEADER, out);
fprintf(out, USAGE_MAN_TAIL("partx(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
return EXIT_SUCCESS;
}
case 'h':
- usage(stdout);
+ usage();
case 'V':
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
device = NULL;
part_devno = 0;
}
- } else
- usage(stderr);
-
+ } else {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
if (device && (upper || lower))
errx(EXIT_FAILURE, _("--nr and <partition> are mutually exclusive"));
#include "strutils.h"
#include "closestream.h"
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s <disk device> <partition number> <length>\n"),
program_invocation_short_name);
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("resizepart(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
static int get_partition_start(int fd, int partno, uint64_t *start)
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
- if (argc != 4)
- usage(stderr);
+ if (argc != 4) {
+ warnx(_("not enough arguments"));
+ errtryhelp(EXIT_FAILURE);
+ }
wholedisk = argv[1];
partno = strtou32_or_err(argv[2], _("invalid partition number argument"));
return -1;
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] <device>\n"),
program_invocation_short_name);
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("swaplabel(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char *argv[])
while ((c = getopt_long(argc, argv, "hVL:U:", longopts, NULL)) != -1) {
switch (c) {
case 'h':
- usage(stdout);
+ usage();
break;
case 'V':
printf(UTIL_LINUX_VERSION);
}
}
- if (optind == argc)
- usage(stderr);
-
+ if (optind == argc) {
+ warnx(_("no device specified"));
+ errtryhelp(EXIT_FAILURE);
+ }
devname = argv[optind];
pr = get_swap_prober(devname);
if (pr) {
}
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fprintf(out,
"\n %s [options] <column-data-file> ...\n\n", program_invocation_short_name);
fputs(" -h, --help this help\n", out);
fputs("\n", out);
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char *argv[])
scols_table_set_termwidth(tb, strtou32_or_err(optarg, "failed to parse terminal width"));
break;
case 'h':
- usage(stdout);
+ usage();
default:
- usage(stderr);
+ errtryhelp(EXIT_FAILURE);
}
}
/* we do not accept gecos field sizes longer than MAX_FIELD_SIZE */
#define MAX_FIELD_SIZE 256
-static void __attribute__((__noreturn__)) usage(FILE *fp)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *fp = stdout;
fputs(USAGE_HEADER, fp);
fprintf(fp, _(" %s [options] [<username>]\n"), program_invocation_short_name);
fputs(_(" -u, --help display this help and exit\n"), fp);
fputs(_(" -v, --version output version information and exit\n"), fp);
fprintf(fp, USAGE_MAN_TAIL("chfn(1)"));
- exit(fp == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
/*
printf(UTIL_LINUX_VERSION);
exit(EXIT_SUCCESS);
case 'u':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
/* done parsing arguments. check for a username. */
if (optind < argc) {
- if (optind + 1 < argc)
- usage(stderr);
+ if (optind + 1 < argc) {
+ warnx(_("cannot handle multiple usernames"));
+ errtryhelp(EXIT_FAILURE);
+ }
ctl->username = argv[optind];
}
return;
/* global due readline completion */
static char **global_shells;
-static void __attribute__((__noreturn__)) usage (FILE *fp)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *fp = stdout;
fputs(USAGE_HEADER, fp);
fprintf(fp, _(" %s [options] [<username>]\n"), program_invocation_short_name);
fputs(_(" -u, --help display this help and exit\n"), fp);
fputs(_(" -v, --version output version information and exit\n"), fp);
fprintf(fp, USAGE_MAN_TAIL("chsh(1)"));
- exit(fp == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
/*
exit(EXIT_SUCCESS);
case 'u': /* deprecated */
case 'h':
- usage(stdout);
+ usage();
case 'l':
init_shells();
print_shells();
}
/* done parsing arguments. check for a username. */
if (optind < argc) {
- if (optind + 1 < argc)
- usage(stderr);
+ if (optind + 1 < argc) {
+ errx(EXIT_FAILURE, _("cannot handle multiple usernames"));
+ }
pinfo->username = argv[optind];
}
}
static int week_to_day(const struct cal_control *ctl);
static int center_str(const char *src, char *dest, size_t dest_size, size_t width);
static void center(const char *str, size_t len, int separate);
-static void __attribute__((__noreturn__)) usage(FILE *out);
+static void __attribute__((__noreturn__)) usage(void);
int main(int argc, char **argv)
{
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
ctl.req.month = local_time->tm_mon + 1;
break;
default:
- usage(stderr);
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
}
if (0 < ctl.req.week) {
}
}
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] [[[day] month] year]\n"), program_invocation_short_name);
fprintf(out, _(" %s [options] <timestamp|monthname>\n"), program_invocation_short_name);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("cal(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
static char *linear_search (char *, char *);
static int look (char *, char *);
static void print_from (char *, char *);
-static void __attribute__ ((__noreturn__)) usage(FILE * out);
+static void __attribute__((__noreturn__)) usage(void);
int
main(int argc, char *argv[])
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
string = *argv;
break;
default:
- usage(stderr);
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
}
if (termchar != '\0' && (p = strchr(string, termchar)) != NULL)
return ((i > 0) ? LESS : (i < 0) ? GREATER : EQUAL);
}
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] <string> [<file>...]\n"), program_invocation_short_name);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("look(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
return ret;
}
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out,
_(" %s [options] <expression> <replacement> <file>...\n"),
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("rename(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
if (argc < 3) {
warnx(_("not enough arguments"));
- usage(stderr);
+ errtryhelp(EXIT_FAILURE);
}
from = argv[0];
static void __attribute__((__noreturn__))
-usage(FILE *out)
+usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out,
_(" %s [options] <device>\n"), program_invocation_short_name);
fprintf(out, USAGE_MAN_TAIL("wipefs(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
flags |= WP_FL_FORCE;
break;
case 'h':
- usage(stdout);
+ usage();
break;
case 'n':
flags |= WP_FL_NOACT;
}
}
- if (optind == argc)
- usage(stderr);
+ if (optind == argc) {
+ warnx(_("no device specified"));
+ errtryhelp(EXIT_FAILURE);
+
+ }
if ((flags & WP_FL_BACKUP) && !((flags & WP_FL_ALL) || has_offset))
warnx(_("The --backup option is meaningless in this context"));
err(EXIT_FAILURE, _("ioprio_set failed"));
}
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %1$s [options] -p <pid>...\n"
" %1$s [options] -P <pgid>...\n"
fprintf(out, USAGE_MAN_TAIL("ionice(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
ioprio_setid(0, ioclass, data, IOPRIO_WHO_PROCESS);
execvp(argv[optind], &argv[optind]);
err(EXIT_FAILURE, _("failed to execute %s"), argv[optind]);
- } else
- usage(stderr);
-
+ } else {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
return EXIT_SUCCESS;
}
get_only:1; /* print the mask, but not modify */
};
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fprintf(out,
_("Usage: %s [options] [mask | cpu-list] [pid|cmd [args...]]\n\n"),
program_invocation_short_name);
fprintf(out, USAGE_MAN_TAIL("taskset(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
static void print_affinity(struct taskset *ts, int isnew)
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(stdout);
+ usage();
break;
default:
errtryhelp(EXIT_FAILURE);
}
if ((!pid && argc - optind < 2)
- || (pid && (argc - optind < 1 || argc - optind > 2)))
- usage(stderr);
+ || (pid && (argc - optind < 1 || argc - optind > 2))) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
ncpus = get_max_number_of_cpus();
if (ncpus <= 0)
}
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out,
_(" %s [options] <device>\n"), program_invocation_short_name);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("blkdiscard(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
while ((c = getopt_long(argc, argv, "hVsvo:l:p:z", longopts, NULL)) != -1) {
switch(c) {
case 'h':
- usage(stdout);
+ usage();
break;
case 'V':
printf(UTIL_LINUX_VERSION);
if (optind != argc) {
warnx(_("unexpected number of arguments"));
- usage(stderr);
+ errtryhelp(EXIT_FAILURE);
}
fd = open(path, O_WRONLY);
errx(EXIT_FAILURE, _("failed to parse CPU list: %s"), cpu_string);
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fprintf(out, _(
"\nUsage:\n"
" %s [options]\n"), program_invocation_short_name);
" -r, --rescan trigger rescan of cpus\n"
" -V, --version output version information and exit\n"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char *argv[])
cpu_parse(argv[optind - 1], cpu_set, setsize);
break;
case 'h':
- usage(stdout);
+ usage();
case 'p':
if (strcmp("horizontal", argv[optind - 1]) == 0)
cmd = CMD_CPU_DISPATCH_HORIZONTAL;
}
}
- if ((argc == 1) || (argc != optind))
- usage(stderr);
+ if ((argc == 1) || (argc != optind)) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
switch (cmd) {
case CMD_CPU_ENABLE:
errx(EXIT_FAILURE, _("Invalid range: %s"), param);
}
-static void __attribute__((__noreturn__)) chmem_usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] [SIZE|RANGE|BLOCKRANGE]\n"), program_invocation_short_name);
fprintf(out, USAGE_MAN_TAIL("chmem(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
desc->use_blocks = 1;
break;
case 'h':
- chmem_usage(stdout);
+ usage();
break;
case 'v':
desc->verbose = 1;
}
}
- if ((argc == 1) || (argc != optind + 1) || (cmd == CMD_NONE))
- chmem_usage(stderr);
+ if ((argc == 1) || (argc != optind + 1) || (cmd == CMD_NONE)) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
parse_parameter(desc, argv[optind]);
return id >= 0 ? 0 : -1;
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
size_t i;
fputs(USAGE_HEADER, out);
_(level_names[i].help));
fputs(USAGE_SEPARATOR, out);
fprintf(out, USAGE_MAN_TAIL("dmesg(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
/*
ctl.pager = 1;
break;
case 'h':
- usage(stdout);
+ usage();
break;
case 'k':
ctl.fltr_fac = 1;
}
}
- if (argc != optind)
- usage(stderr);
+ if (argc != optind) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
if ((is_timefmt(&ctl, RELTIME) ||
is_timefmt(&ctl, CTIME) ||
UNFREEZE
};
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
- fprintf(out, USAGE_HEADER);
+ FILE *out = stdout;
+ fputs(USAGE_HEADER, out);
fprintf(out,
_(" %s [options] <mountpoint>\n"), program_invocation_short_name);
fputs(USAGE_OPTIONS, out);
fputs(_(" -f, --freeze freeze the filesystem\n"), out);
fputs(_(" -u, --unfreeze unfreeze the filesystem\n"), out);
- fprintf(out, USAGE_SEPARATOR);
- fprintf(out, USAGE_HELP);
- fprintf(out, USAGE_VERSION);
+ fputs(USAGE_SEPARATOR, out);
+ fputs(USAGE_HELP, out);
+ fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("fsfreeze(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
switch(c) {
case 'h':
- usage(stdout);
+ usage();
break;
case 'f':
action = FREEZE;
if (optind != argc) {
warnx(_("unexpected number of arguments"));
- usage(stderr);
+ errtryhelp(EXIT_FAILURE);
}
fd = open(path, O_RDONLY);
return EXIT_SUCCESS;
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out,
_(" %s [options] <mount point>\n"), program_invocation_short_name);
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("fstrim(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
all = 1;
break;
case 'h':
- usage(stdout);
+ usage();
break;
case 'V':
printf(UTIL_LINUX_VERSION);
if (optind != argc) {
warnx(_("unexpected number of arguments"));
- usage(stderr);
+ errtryhelp(EXIT_FAILURE);
}
if (all)
return semget(key, nsems, permission | IPC_CREAT);
}
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options]\n"), program_invocation_short_name);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("ipcmk(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
permission = strtoul(optarg, NULL, 8);
break;
case 'h':
- usage(stdout);
+ usage();
break;
case 'V':
printf(UTIL_LINUX_VERSION);
}
}
- if(!ask_shm && !ask_msg && !ask_sem)
- usage(stderr);
-
+ if(!ask_shm && !ask_msg && !ask_sem) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
if (ask_shm) {
int shmid;
if (-1 == (shmid = create_shm(size, permission)))
static int verbose = 0;
/* print the usage */
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %1$s [options]\n"
" %1$s shm|msg|sem <id>...\n"), program_invocation_short_name);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("ipcrm(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
static int remove_id(int type, int iskey, int id)
if (argc < 3) {
warnx(_("not enough arguments"));
- usage(stderr);
+ errtryhelp(EXIT_FAILURE);
}
if (remove_arg_list(type, argc - 2, &argv[2]))
verbose = 1;
break;
case 'h':
- usage(stdout);
+ usage();
case 'V':
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
return rc;
}
-static void usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
size_t i;
fputs(USAGE_HEADER, out);
fprintf(out, USAGE_MAN_TAIL("losetup(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
static void warn_size(const char *filename, uint64_t size)
act = A_FIND_FREE;
break;
case 'h':
- usage(stdout);
+ usage();
break;
case 'J':
json = 1;
loopcxt_get_device(&lc));
break;
default:
- usage(stderr);
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
break;
}
scols_unref_table(tb);
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
size_t i;
fputs(USAGE_HEADER, out);
fprintf(out, USAGE_MAN_TAIL("lscpu(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char *argv[])
cpu_modifier_specified = 1;
break;
case 'h':
- usage(stdout);
+ usage();
case 'J':
mod->json = 1;
break;
return EXIT_FAILURE;
}
- if (argc != optind)
- usage(stderr);
+ if (argc != optind) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
/* set default cpu display mode if none was specified */
if (!mod->online && !mod->offline) {
lsmem->have_nodes = 1;
}
-static void __attribute__((__noreturn__)) lsmem_usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
unsigned int i;
fputs(USAGE_HEADER, out);
lsmem->bytes = 1;
break;
case 'h':
- lsmem_usage(stdout);
+ usage();
break;
case 'J':
lsmem->json = 1;
}
}
- if (argc != optind)
- lsmem_usage(stderr);
+ if (argc != optind) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
if (lsmem->want_table + lsmem->want_summary == 0)
errx(EXIT_FAILURE, _("options --{raw,json,pairs} and --summary=only are mutually exclusive"));
return mflags & MS_REMOUNT;
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(
" %1$s [-lhV]\n"
fprintf(out, USAGE_MAN_TAIL("mount(8)"));
- exit(out == stderr ? MNT_EX_USAGE : MNT_EX_SUCCESS);
+ exit(MNT_EX_SUCCESS);
}
int main(int argc, char **argv)
mnt_context_enable_fork(cxt, TRUE);
break;
case 'h':
- usage(stdout);
+ usage();
break;
case 'i':
mnt_context_disable_helpers(cxt, TRUE);
!mnt_context_get_target(cxt) &&
!argc &&
!all) {
- if (oper || mnt_context_get_options(cxt))
- usage(stderr);
+ if (oper || mnt_context_get_options(cxt)) {
+ warnx(_("bad usage"));
+ errtryhelp(MNT_EX_USAGE);
+ }
print_all(cxt, types, show_labels);
goto done;
}
if (mnt_context_is_restricted(cxt) && types)
exit_non_root("types");
- if (oper && (types || all || mnt_context_get_source(cxt)))
- usage(stderr);
+ if (oper && (types || all || mnt_context_get_source(cxt))) {
+ warnx(_("bad usage"));
+ errtryhelp(MNT_EX_USAGE);
+ }
if (types && (all || strchr(types, ',') ||
strncmp(types, "no", 2) == 0))
mnt_context_set_source(cxt, argv[0]);
mnt_context_set_target(cxt, argv[1]);
- } else
- usage(stderr);
+ } else {
+ warnx(_("bad usage"));
+ errtryhelp(MNT_EX_USAGE);
+ }
if (mnt_context_is_restricted(cxt))
sanitize_paths(cxt);
return 0;
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out,
_(" %1$s [-qd] /path/to/directory\n"
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("mountpoint(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
ctl.dev_devno = 1;
break;
case 'h':
- usage(stdout);
+ usage();
break;
case 'V':
printf(UTIL_LINUX_VERSION);
}
}
- if (optind + 1 != argc)
- usage(stderr);
+ if (optind + 1 != argc) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
ctl.path = argv[optind];
#define pivot_root(new_root,put_old) syscall(SYS_pivot_root,new_root,put_old)
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
- fprintf(out, USAGE_HEADER);
+ FILE *out = stdout;
+ fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] new_root put_old\n"),
program_invocation_short_name);
fputs(USAGE_SEPARATOR, out);
fputs(_("Change the root filesystem.\n"), out);
- fprintf(out, USAGE_OPTIONS);
- fprintf(out, USAGE_HELP);
- fprintf(out, USAGE_VERSION);
+ fputs(USAGE_OPTIONS, out);
+ fputs(USAGE_HELP, out);
+ fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("pivot_root(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
- if (argc != 3)
- usage(stderr);
-
+ if (argc != 3) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
if (pivot_root(argv[1], argv[2]) < 0)
err(EXIT_FAILURE, _("failed to change root from `%s' to `%s'"),
argv[1], argv[2]);
#include "nls.h"
#include "closestream.h"
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(
" %s [options] <program> [arguments ...]\n"),
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("setsid(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
status = 1;
break;
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
- if (argc - optind < 1)
- usage(stderr);
+ if (argc - optind < 1) {
+ warnx(_("no command specified"));
+ errtryhelp(EXIT_FAILURE);
+ }
if (getpgrp() == getpid()) {
pid = fork();
return special ? do_swapoff(special, quiet, CANONIC) : cannot_find(value);
}
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] [<spec>]\n"), program_invocation_short_name);
" <file> name of file to be used\n"), out);
fprintf(out, USAGE_MAN_TAIL("swapoff(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
static int swapoff_all(void)
++all;
break;
case 'h': /* help */
- usage(stdout);
+ usage();
break;
case 'v': /* be chatty */
++verbose;
}
argv += optind;
- if (!all && !numof_labels() && !numof_uuids() && *argv == NULL)
- usage(stderr);
+ if (!all && !numof_labels() && !numof_uuids() && *argv == NULL) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
mnt_init_debug(0);
mntcache = mnt_new_cache();
}
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
size_t i;
+
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] [<spec>]\n"), program_invocation_short_name);
fprintf(out, " %-5s %s\n", infos[i].name, _(infos[i].help));
fprintf(out, USAGE_MAN_TAIL("swapon(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char *argv[])
ctl.all = 1;
break;
case 'h': /* help */
- usage(stdout);
+ usage();
break;
case 'o':
options = optarg;
return status;
}
- if (ctl.props.no_fail && !ctl.all)
- usage(stderr);
+ if (ctl.props.no_fail && !ctl.all) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
if (ctl.all)
status |= swapon_all(&ctl);
return 0;
}
-static void __attribute__((__noreturn__)) usage(FILE *output)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *output = stdout;
fputs(USAGE_HEADER, output);
fprintf(output, _(" %s [options] <newrootdir> <init> <args to init>\n"),
program_invocation_short_name);
fputs(USAGE_VERSION, output);
fprintf(output, USAGE_MAN_TAIL("switch_root(8)"));
- exit(output == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char *argv[])
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
- if (argc < 3)
- usage(stderr);
+ if (argc < 3) {
+ warnx(_("not enough arguments"));
+ errtryhelp(EXIT_FAILURE);
+ }
newroot = argv[1];
init = argv[2];
initargs = &argv[2];
- if (!*newroot || !*init)
- usage(stderr);
+ if (!*newroot || !*init) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
if (switchroot(newroot))
errx(EXIT_FAILURE, _("failed. Sorry."));
struct command *next;
};
-static void __attribute__((__noreturn__)) print_usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] <device>\n"), program_invocation_short_name);
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("tunelp(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
strutils_set_exitcode(EXIT_LP_BADVAL);
- if (argc < 2)
- print_usage(stderr);
+ if (argc < 2) {
+ warnx(_("not enough arguments"));
+ errtryhelp(EXIT_FAILURE);
+ }
cmdst = cmds = xmalloc(sizeof(struct command));
cmds->next = NULL;
while ((c = getopt_long(argc, argv, "t:c:w:a:i:ho:C:sq:rT:vV", longopts, NULL)) != -1) {
switch (c) {
case 'h':
- print_usage(stdout);
+ usage();
break;
case 'i':
cmds->op = LPSETIRQ;
}
}
- if (optind != argc - 1)
- print_usage(stderr);
+ if (optind != argc - 1) {
+ warnx(_("no device specified"));
+ errtryhelp(EXIT_FAILURE);
+ }
filename = xstrdup(argv[optind]);
fd = open(filename, O_WRONLY | O_NONBLOCK, 0);
if (!S_ISCHR(statbuf.st_mode)) {
warnx(_("%s not an lp device"), filename);
- print_usage(stderr);
+ errtryhelp(EXIT_FAILURE);
}
/* Allow for binaries compiled under a new kernel to work on
* the old ones The irq argument to ioctl isn't touched by
fputs(")\n", stdout);
exit(MNT_EX_SUCCESS);
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(
" %1$s [-hV]\n"
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("umount(8)"));
- exit(out == stderr ? MNT_EX_USAGE : MNT_EX_SUCCESS);
+ exit(MNT_EX_SUCCESS);
}
static void __attribute__((__noreturn__)) exit_non_root(const char *option)
mnt_context_enable_force(cxt, TRUE);
break;
case 'h':
- usage(stdout);
+ usage();
break;
case 'i':
mnt_context_disable_helpers(cxt, TRUE);
rc = umount_all(cxt);
} else if (argc < 1) {
- usage(stderr);
+ warnx(_("bad usage"));
+ errtryhelp(MNT_EX_USAGE);
} else if (alltargets) {
while (argc--)
#define IS_NOT_ALLOWED 1 /* Receiving messages is not allowed. */
#define MESG_EXIT_FAILURE 2 /* An error occurred. */
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
/* TRANSLATORS: this program uses for y and n rpmatch(3),
* which means they can be translated. */
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("mesg(1)"));
- exit(out == stderr ? MESG_EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char *argv[])
printf(UTIL_LINUX_VERSION);
exit(EXIT_SUCCESS);
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
break;
case RPMATCH_INVALID:
warnx(_("invalid argument: %s"), argv[0]);
- usage(stderr);
+ errtryhelp(EXIT_FAILURE);
default:
abort();
}
return strtos32_or_err(arg, _("argument error"));
}
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out,
_(" %s [options]\n"), program_invocation_short_name);
fputs(_(" --version show version information and exit\n"), out);
fputs(_(" --help display this help and exit\n"), out);
fprintf(out, USAGE_MAN_TAIL("setterm(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
static int __attribute__((__pure__)) set_opt_flag(int opt)
printf(UTIL_LINUX_VERSION);
exit(EXIT_SUCCESS);
case OPT_HELP:
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
textdomain(PACKAGE);
atexit(close_stdout);
- if (argc < 2)
- usage(stderr);
-
+ if (argc < 2) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
parse_option(&ctl, argc, argv);
init_terminal(&ctl);
perform_sequence(&ctl);
if (putwchar(ch) == WEOF) \
wrerr();
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fprintf(out, _(
"\nUsage:\n"
" %s [options]\n"), program_invocation_short_name);
program_invocation_short_name);
fprintf(out, USAGE_MAN_TAIL("col(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
static void __attribute__((__noreturn__)) wrerr(void)
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'H':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
- if (optind != argc)
- usage(stderr);
+ if (optind != argc) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
adjust = cur_col = extra_lines = warned = 0;
cur_line = max_line = nflushd_lines = this_line = 0;