From 74887031996e79df07dae9711f08d80839b31e62 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 30 Aug 2002 23:04:53 +0000 Subject: Change `error (1, ...' to `error (EXIT_FAILURE, ...'. --- src/chgrp.c | 8 ++++---- src/chmod.c | 9 +++++---- src/chown.c | 6 +++--- src/chroot.c | 7 ++++--- src/cp.c | 3 ++- src/date.c | 6 +++--- src/dd.c | 21 ++++++++++++--------- src/du.c | 6 +++--- src/hostname.c | 6 +++--- src/id.c | 9 +++++---- src/install.c | 14 +++++++------- src/ln.c | 5 +++-- src/mkdir.c | 2 +- src/mkfifo.c | 2 +- src/mknod.c | 16 +++++++++------- src/nice.c | 12 ++++++------ src/pinky.c | 2 +- src/printf.c | 10 +++++----- src/pwd.c | 2 +- src/shred.c | 4 ++-- src/sleep.c | 2 +- src/stty.c | 27 ++++++++++++++------------- src/su.c | 10 +++++----- src/tac-pipe.c | 2 +- src/tail.c | 7 ++++--- src/tee.c | 2 +- src/touch.c | 7 ++++--- src/uname.c | 2 +- src/uptime.c | 4 ++-- src/users.c | 2 +- src/who.c | 2 +- 31 files changed, 115 insertions(+), 102 deletions(-) (limited to 'src') diff --git a/src/chgrp.c b/src/chgrp.c index 3253b0fb5..491433090 100644 --- a/src/chgrp.c +++ b/src/chgrp.c @@ -90,7 +90,7 @@ parse_group (const char *name, gid_t *g) struct group *grp; if (*name == '\0') - error (1, 0, _("cannot change to null group")); + error (EXIT_FAILURE, 0, _("cannot change to null group")); grp = getgrnam (name); if (grp == NULL) @@ -99,14 +99,14 @@ parse_group (const char *name, gid_t *g) unsigned long int tmp_long; if (!ISDIGIT (*name)) - error (1, 0, _("invalid group name %s"), quote (name)); + error (EXIT_FAILURE, 0, _("invalid group name %s"), quote (name)); s_err = xstrtoul (name, NULL, 0, &tmp_long, NULL); if (s_err != LONGINT_OK) STRTOL_FATAL_ERROR (name, _("group number"), s_err); if (tmp_long > MAXGID) - error (1, 0, _("invalid group number %s"), quote (name)); + error (EXIT_FAILURE, 0, _("invalid group number %s"), quote (name)); *g = tmp_long; } @@ -215,7 +215,7 @@ main (int argc, char **argv) { struct stat ref_stats; if (stat (reference_file, &ref_stats)) - error (1, errno, _("failed to get attributes of %s"), + error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), quote (reference_file)); chopt.group_name = gid_to_name (ref_stats.st_gid); diff --git a/src/chmod.c b/src/chmod.c index 852fe47e6..8abbd618b 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -1,5 +1,5 @@ /* chmod -- change permission modes of files - Copyright (C) 89, 90, 91, 1995-2001 Free Software Foundation, Inc. + Copyright (C) 89, 90, 91, 1995-2002 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -318,7 +318,7 @@ main (int argc, char **argv) { static char char_string[2] = {0, 0}; char_string[0] = c; - error (1, 0, _("invalid character %s in mode string %s"), + error (EXIT_FAILURE, 0, _("invalid character %s in mode string %s"), quote_n (0, char_string), quote_n (1, argv[thisind])); } modeind = thisind; @@ -358,11 +358,12 @@ main (int argc, char **argv) : mode_compile (argv[modeind], MODE_MASK_ALL)); if (changes == MODE_INVALID) - error (1, 0, _("invalid mode string: %s"), quote (argv[modeind])); + error (EXIT_FAILURE, 0, + _("invalid mode string: %s"), quote (argv[modeind])); else if (changes == MODE_MEMORY_EXHAUSTED) xalloc_die (); else if (changes == MODE_BAD_REFERENCE) - error (1, errno, _("failed to get attributes of %s"), + error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), quote (reference_file)); for (; optind < argc; ++optind) diff --git a/src/chown.c b/src/chown.c index a95ff017e..5320f7ade 100644 --- a/src/chown.c +++ b/src/chown.c @@ -181,7 +181,7 @@ main (int argc, char **argv) &old_uid, &old_gid, &u_dummy, &g_dummy); if (e) - error (1, 0, "%s: %s", quote (optarg), e); + error (EXIT_FAILURE, 0, "%s: %s", quote (optarg), e); break; } case 'R': @@ -217,7 +217,7 @@ main (int argc, char **argv) struct stat ref_stats; if (stat (reference_file, &ref_stats)) - error (1, errno, _("failed to get attributes of %s"), + error (EXIT_FAILURE, errno, _("failed to get attributes of %s"), quote (reference_file)); uid = ref_stats.st_uid; @@ -230,7 +230,7 @@ main (int argc, char **argv) const char *e = parse_user_spec (argv[optind], &uid, &gid, &chopt.user_name, &chopt.group_name); if (e) - error (1, 0, "%s: %s", quote (argv[optind]), e); + error (EXIT_FAILURE, 0, "%s: %s", quote (argv[optind]), e); /* FIXME: set it to the empty string? */ if (chopt.user_name == NULL) diff --git a/src/chroot.c b/src/chroot.c index 4904c84d6..f63ab2a53 100644 --- a/src/chroot.c +++ b/src/chroot.c @@ -1,5 +1,5 @@ /* chroot -- run command or shell with special root directory - Copyright (C) 95, 96, 1997, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 95, 96, 1997, 1999-2002 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -80,10 +80,11 @@ main (int argc, char **argv) } if (chroot (argv[1])) - error (1, errno, _("cannot change root directory to %s"), argv[1]); + error (EXIT_FAILURE, errno, + _("cannot change root directory to %s"), argv[1]); if (chdir ("/")) - error (1, errno, _("cannot chdir to root directory")); + error (EXIT_FAILURE, errno, _("cannot chdir to root directory")); if (argc == 2) { diff --git a/src/cp.c b/src/cp.c index 676e2fbaa..36a66e059 100644 --- a/src/cp.c +++ b/src/cp.c @@ -968,7 +968,8 @@ main (int argc, char **argv) #ifdef S_ISLNK x.symbolic_link = 1; #else - error (1, 0, _("symbolic links are not supported on this system")); + error (EXIT_FAILURE, 0, + _("symbolic links are not supported on this system")); #endif break; diff --git a/src/date.c b/src/date.c index 0aaed8184..bc0c81a5a 100644 --- a/src/date.c +++ b/src/date.c @@ -244,7 +244,7 @@ batch_convert (const char *input_filename, const char *format) in_stream = fopen (input_filename, "r"); if (in_stream == NULL) { - error (1, errno, "`%s'", input_filename); + error (EXIT_FAILURE, errno, "`%s'", input_filename); } } @@ -444,7 +444,7 @@ argument must be a format string beginning with `+'."), if (reference != NULL) { if (stat (reference, &refstats)) - error (1, errno, "%s", reference); + error (EXIT_FAILURE, errno, "%s", reference); when.tv_sec = refstats.st_mtime; when.tv_nsec = TIMESPEC_NS (refstats.st_mtim); } @@ -459,7 +459,7 @@ argument must be a format string beginning with `+'."), } if (! valid_date) - error (1, 0, _("invalid date `%s'"), datestr); + error (EXIT_FAILURE, 0, _("invalid date `%s'"), datestr); if (set_date) { diff --git a/src/dd.c b/src/dd.c index c394a9499..da3c87d55 100644 --- a/src/dd.c +++ b/src/dd.c @@ -383,9 +383,11 @@ cleanup (void) { print_stats (); if (close (STDIN_FILENO) < 0) - error (1, errno, _("closing input file %s"), quote (input_file)); + error (EXIT_FAILURE, errno, + _("closing input file %s"), quote (input_file)); if (close (STDOUT_FILENO) < 0) - error (1, errno, _("closing output file %s"), quote (output_file)); + error (EXIT_FAILURE, errno, + _("closing output file %s"), quote (output_file)); } static inline void @@ -610,7 +612,7 @@ scanargs (int argc, char **argv) } if (invalid) - error (1, 0, _("invalid number %s"), quote (val)); + error (EXIT_FAILURE, 0, _("invalid number %s"), quote (val)); } } @@ -640,7 +642,7 @@ apply_translations (void) || (MX (C_LCASE | C_UCASE) > 1) || (MX (C_UNBLOCK | C_SYNC) > 1)) { - error (1, 0, _("\ + error (EXIT_FAILURE, 0, _("\ only one conv in {ascii,ebcdic,ibm}, {lcase,ucase}, {block,unblock}, {unblock,sync}")); } #undef MX @@ -1163,7 +1165,7 @@ main (int argc, char **argv) if (input_file != NULL) { if (open_fd (STDIN_FILENO, input_file, O_RDONLY, 0) < 0) - error (1, errno, _("opening %s"), quote (input_file)); + error (EXIT_FAILURE, errno, _("opening %s"), quote (input_file)); } else input_file = _("standard input"); @@ -1181,7 +1183,7 @@ main (int argc, char **argv) if ((! seek_records || open_fd (STDOUT_FILENO, output_file, O_RDWR | opts, perms) < 0) && open_fd (STDOUT_FILENO, output_file, O_WRONLY | opts, perms) < 0) - error (1, errno, _("opening %s"), quote (output_file)); + error (EXIT_FAILURE, errno, _("opening %s"), quote (output_file)); #if HAVE_FTRUNCATE if (seek_records != 0 && !(conversions_mask & C_NOTRUNC)) @@ -1189,10 +1191,10 @@ main (int argc, char **argv) struct stat stdout_stat; off_t o = seek_records * output_blocksize; if (o / output_blocksize != seek_records) - error (1, 0, _("file offset out of range")); + error (EXIT_FAILURE, 0, _("file offset out of range")); if (fstat (STDOUT_FILENO, &stdout_stat) != 0) - error (1, errno, _("cannot fstat %s"), quote (output_file)); + error (EXIT_FAILURE, errno, _("cannot fstat %s"), quote (output_file)); /* Complain only when ftruncate fails on a regular file, a directory, or a shared memory object, as the 2000-08 @@ -1205,7 +1207,8 @@ main (int argc, char **argv) || S_TYPEISSHM (&stdout_stat))) { char buf[LONGEST_HUMAN_READABLE + 1]; - error (1, errno, _("advancing past %s bytes in output file %s"), + error (EXIT_FAILURE, errno, + _("advancing past %s bytes in output file %s"), human_readable (o, buf, 1, 1), quote (output_file)); } diff --git a/src/du.c b/src/du.c index d25cb119f..7e29a96d3 100644 --- a/src/du.c +++ b/src/du.c @@ -385,7 +385,7 @@ pop_dir (struct saved_cwd *cwd, const char *curr_dir_name) } else if (chdir ("..") < 0) { - error (1, errno, _("cannot change to `..' from directory %s"), + error (EXIT_FAILURE, errno, _("cannot change to `..' from directory %s"), quote (curr_dir_name)); } } @@ -618,7 +618,7 @@ main (int argc, char **argv) case MAX_DEPTH_OPTION: /* --max-depth=N */ if (xstrtol (optarg, NULL, 0, &tmp_long, NULL) != LONGINT_OK || tmp_long < 0 || tmp_long > INT_MAX) - error (1, 0, _("invalid maximum depth %s"), quote (optarg)); + error (EXIT_FAILURE, 0, _("invalid maximum depth %s"), quote (optarg)); max_depth_specified = 1; max_depth = (int) tmp_long; @@ -659,7 +659,7 @@ main (int argc, char **argv) case 'X': if (add_exclude_file (add_exclude, exclude, optarg, EXCLUDE_WILDCARDS, '\n')) - error (1, errno, "%s", quote (optarg)); + error (EXIT_FAILURE, errno, "%s", quote (optarg)); break; case EXCLUDE_OPTION: diff --git a/src/hostname.c b/src/hostname.c index fe4aeb682..c004523ca 100644 --- a/src/hostname.c +++ b/src/hostname.c @@ -101,12 +101,12 @@ main (int argc, char **argv) /* Set hostname to argv[1]. */ err = sethostname (argv[1], strlen (argv[1])); if (err != 0) - error (1, errno, _("cannot set hostname to `%s'"), argv[1]); + error (EXIT_FAILURE, errno, _("cannot set hostname to `%s'"), argv[1]); exit (0); } #else if (argc == 2) - error (1, 0, + error (EXIT_FAILURE, 0, _("cannot set hostname; this system lacks the functionality")); #endif @@ -114,7 +114,7 @@ main (int argc, char **argv) { hostname = xgethostname (); if (hostname == NULL) - error (1, errno, _("cannot determine hostname")); + error (EXIT_FAILURE, errno, _("cannot determine hostname")); printf ("%s\n", hostname); } else diff --git a/src/id.c b/src/id.c index a4a2207d7..9f2bd460a 100644 --- a/src/id.c +++ b/src/id.c @@ -1,5 +1,5 @@ /* id -- print real and effective UIDs and GIDs - Copyright (C) 1989-2001 Free Software Foundation, Inc. + Copyright (C) 1989-2002 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -159,10 +159,11 @@ main (int argc, char **argv) } if (just_user + just_group + just_group_list > 1) - error (1, 0, _("cannot print only user and only group")); + error (EXIT_FAILURE, 0, _("cannot print only user and only group")); if (just_user + just_group + just_group_list == 0 && (use_real || use_name)) - error (1, 0, _("cannot print only names or real IDs in default format")); + error (EXIT_FAILURE, 0, + _("cannot print only names or real IDs in default format")); if (argc - optind > 1) usage (1); @@ -171,7 +172,7 @@ main (int argc, char **argv) { struct passwd *pwd = getpwnam (argv[optind]); if (pwd == NULL) - error (1, 0, _("%s: No such user"), argv[optind]); + error (EXIT_FAILURE, 0, _("%s: No such user"), argv[optind]); ruid = euid = pwd->pw_uid; rgid = egid = pwd->pw_gid; } diff --git a/src/install.c b/src/install.c index 0d1bc0942..1afcdcaca 100644 --- a/src/install.c +++ b/src/install.c @@ -269,7 +269,7 @@ main (int argc, char **argv) /* Check for invalid combinations of arguments. */ if (dir_arg && strip_files) - error (1, 0, + error (EXIT_FAILURE, 0, _("the strip option may not be used when installing a directory")); if (backup_suffix_string) @@ -293,7 +293,7 @@ main (int argc, char **argv) { struct mode_change *change = mode_compile (specified_mode, 0); if (change == MODE_INVALID) - error (1, 0, _("invalid mode %s"), quote (specified_mode)); + error (EXIT_FAILURE, 0, _("invalid mode %s"), quote (specified_mode)); else if (change == MODE_MEMORY_EXHAUSTED) xalloc_die (); mode = mode_adjust (0, change); @@ -529,18 +529,18 @@ strip (const char *path) switch (pid) { case -1: - error (1, errno, _("fork system call failed")); + error (EXIT_FAILURE, errno, _("fork system call failed")); break; case 0: /* Child. */ execlp ("strip", "strip", path, NULL); - error (1, errno, _("cannot run strip")); + error (EXIT_FAILURE, errno, _("cannot run strip")); break; default: /* Parent. */ /* Parent process. */ while (pid != wait (&status)) /* Wait for kid to finish. */ /* Do nothing. */ ; if (status) - error (1, 0, _("strip failed")); + error (EXIT_FAILURE, 0, _("strip failed")); break; } } @@ -561,7 +561,7 @@ get_ids (void) long int tmp_long; if (xstrtol (owner_name, NULL, 0, &tmp_long, NULL) != LONGINT_OK || tmp_long < 0 || tmp_long > UID_T_MAX) - error (1, 0, _("invalid user %s"), quote (owner_name)); + error (EXIT_FAILURE, 0, _("invalid user %s"), quote (owner_name)); owner_id = (uid_t) tmp_long; } else @@ -579,7 +579,7 @@ get_ids (void) long int tmp_long; if (xstrtol (group_name, NULL, 0, &tmp_long, NULL) != LONGINT_OK || tmp_long < 0 || tmp_long > GID_T_MAX) - error (1, 0, _("invalid group %s"), quote (group_name)); + error (EXIT_FAILURE, 0, _("invalid group %s"), quote (group_name)); group_id = (gid_t) tmp_long; } else diff --git a/src/ln.c b/src/ln.c index 82c347b74..06589f58c 100644 --- a/src/ln.c +++ b/src/ln.c @@ -460,7 +460,8 @@ main (int argc, char **argv) #ifdef S_ISLNK symbolic_link = 1; #else - error (1, 0, _("symbolic links are not supported on this system")); + error (EXIT_FAILURE, 0, + _("symbolic links are not supported on this system")); #endif break; case TARGET_DIRECTORY_OPTION: @@ -537,7 +538,7 @@ main (int argc, char **argv) : n_files - 2); if (!target_directory_specified && !dest_is_dir) - error (1, 0, + error (EXIT_FAILURE, 0, _("when making multiple links, last argument must be a directory")); for (i = 0; i <= last_file_idx; ++i) errors += do_link (file[i], target_directory); diff --git a/src/mkdir.c b/src/mkdir.c index 75e44fd22..877fd9812 100644 --- a/src/mkdir.c +++ b/src/mkdir.c @@ -137,7 +137,7 @@ main (int argc, char **argv) struct mode_change *change = mode_compile (specified_mode, 0); newmode &= ~ umask (0); if (change == MODE_INVALID) - error (1, 0, _("invalid mode %s"), quote (specified_mode)); + error (EXIT_FAILURE, 0, _("invalid mode %s"), quote (specified_mode)); else if (change == MODE_MEMORY_EXHAUSTED) xalloc_die (); newmode = mode_adjust (newmode, change); diff --git a/src/mkfifo.c b/src/mkfifo.c index ed6736064..ae2ee326f 100644 --- a/src/mkfifo.c +++ b/src/mkfifo.c @@ -120,7 +120,7 @@ main (int argc, char **argv) newmode &= ~ umask (0); change = mode_compile (specified_mode, 0); if (change == MODE_INVALID) - error (1, 0, _("invalid mode")); + error (EXIT_FAILURE, 0, _("invalid mode")); else if (change == MODE_MEMORY_EXHAUSTED) xalloc_die (); newmode = mode_adjust (newmode, change); diff --git a/src/mknod.c b/src/mknod.c index 104426dad..66ccba06a 100644 --- a/src/mknod.c +++ b/src/mknod.c @@ -1,5 +1,5 @@ /* mknod -- make special files - Copyright (C) 90, 91, 1995-2001 Free Software Foundation, Inc. + Copyright (C) 90, 91, 1995-2002 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -128,7 +128,7 @@ main (int argc, char **argv) newmode &= ~ umask (0); change = mode_compile (specified_mode, 0); if (change == MODE_INVALID) - error (1, 0, _("invalid mode")); + error (EXIT_FAILURE, 0, _("invalid mode")); else if (change == MODE_MEMORY_EXHAUSTED) xalloc_die (); newmode = mode_adjust (newmode, change); @@ -186,20 +186,22 @@ numbers must be specified")); if (xstrtoumax (s_major, NULL, 0, &i_major, NULL) != LONGINT_OK || i_major != (major_t) i_major) - error (1, 0, _("invalid major device number %s"), quote (s_major)); + error (EXIT_FAILURE, 0, + _("invalid major device number %s"), quote (s_major)); if (xstrtoumax (s_minor, NULL, 0, &i_minor, NULL) != LONGINT_OK || i_minor != (minor_t) i_minor) - error (1, 0, _("invalid minor device number %s"), quote (s_minor)); + error (EXIT_FAILURE, 0, + _("invalid minor device number %s"), quote (s_minor)); device = makedev (i_major, i_minor); #ifdef NODEV if (device == NODEV) - error (1, 0, _("invalid device %s %s"), s_major, s_minor); + error (EXIT_FAILURE, 0, _("invalid device %s %s"), s_major, s_minor); #endif if (mknod (argv[optind], newmode | node_type, device) != 0) - error (1, errno, "%s", quote (argv[optind])); + error (EXIT_FAILURE, errno, "%s", quote (argv[optind])); } break; @@ -214,7 +216,7 @@ major and minor device numbers may not be specified for fifo files")); usage (1); } if (mkfifo (argv[optind], newmode)) - error (1, errno, "%s", quote (argv[optind])); + error (EXIT_FAILURE, errno, "%s", quote (argv[optind])); #endif break; diff --git a/src/nice.c b/src/nice.c index c7ff18d41..13122d92f 100644 --- a/src/nice.c +++ b/src/nice.c @@ -106,7 +106,7 @@ main (int argc, char **argv) && posix2_version () < 200112) { if (xstrtol (&s[2], NULL, 10, &adjustment, "") != LONGINT_OK) - error (1, 0, _("invalid option `%s'"), s); + error (EXIT_FAILURE, 0, _("invalid option `%s'"), s); minusflag = 1; adjustment_given = 1; @@ -119,7 +119,7 @@ main (int argc, char **argv) if (s[1] == '+') ++s; if (xstrtol (&s[1], NULL, 10, &adjustment, "") != LONGINT_OK) - error (1, 0, _("invalid option `%s'"), s); + error (EXIT_FAILURE, 0, _("invalid option `%s'"), s); minusflag = 0; adjustment_given = 1; @@ -144,7 +144,7 @@ main (int argc, char **argv) case 'n': if (xstrtol (optarg, NULL, 10, &adjustment, "") != LONGINT_OK) - error (1, 0, _("invalid priority `%s'"), optarg); + error (EXIT_FAILURE, 0, _("invalid priority `%s'"), optarg); minusflag = 0; adjustment_given = 1; @@ -175,7 +175,7 @@ main (int argc, char **argv) errno = 0; current_priority = GET_PRIORITY (); if (current_priority == -1 && errno != 0) - error (1, errno, _("cannot get priority")); + error (EXIT_FAILURE, errno, _("cannot get priority")); printf ("%d\n", current_priority); exit (0); } @@ -184,12 +184,12 @@ main (int argc, char **argv) errno = 0; current_priority = GET_PRIORITY (); if (current_priority == -1 && errno != 0) - error (1, errno, _("cannot get priority")); + error (EXIT_FAILURE, errno, _("cannot get priority")); if (setpriority (PRIO_PROCESS, 0, current_priority + adjustment)) #else if (nice (adjustment) == -1) #endif - error (1, errno, _("cannot set priority")); + error (EXIT_FAILURE, errno, _("cannot set priority")); execvp (argv[i], &argv[i]); diff --git a/src/pinky.c b/src/pinky.c index 6377d483b..d25317ece 100644 --- a/src/pinky.c +++ b/src/pinky.c @@ -444,7 +444,7 @@ short_pinky (const char *filename, int fail = read_utmp (filename, &n_users, &utmp_buf); if (fail) - error (1, errno, "%s", filename); + error (EXIT_FAILURE, errno, "%s", filename); scan_entries (n_users, utmp_buf, argc_names, argv_names); } diff --git a/src/printf.c b/src/printf.c index 8496446dc..38e02c914 100644 --- a/src/printf.c +++ b/src/printf.c @@ -248,7 +248,7 @@ print_esc (const char *escstart) ++esc_length, ++p) esc_value = esc_value * 16 + hextobin (*p); if (esc_length == 0) - error (1, 0, _("missing hexadecimal number in escape")); + error (EXIT_FAILURE, 0, _("missing hexadecimal number in escape")); putchar (esc_value); } else if (*p == '0') @@ -272,7 +272,7 @@ print_esc (const char *escstart) --esc_length, ++p) { if (!ISXDIGIT (*p)) - error (1, 0, _("missing hexadecimal number in escape")); + error (EXIT_FAILURE, 0, _("missing hexadecimal number in escape")); uni_value = uni_value * 16 + hextobin (*p); } @@ -284,13 +284,13 @@ print_esc (const char *escstart) if ((uni_value >= 0x00 && uni_value <= 0x9f && uni_value != 0x24 && uni_value != 0x40 && uni_value != 0x60) || (uni_value >= 0xd800 && uni_value <= 0xdfff)) - error (1, 0, _("invalid universal character name \\%c%0*x"), + error (EXIT_FAILURE, 0, _("invalid universal character name \\%c%0*x"), esc_char, (esc_char == 'u' ? 4 : 8), uni_value); print_unicode_char (stdout, uni_value, 0); } else - error (1, 0, _("\\%c: invalid escape"), *p); + error (EXIT_FAILURE, 0, _("\\%c: invalid escape"), *p); return p - escstart - 1; } @@ -498,7 +498,7 @@ print_formatted (const char *format, int argc, char **argv) ++direc_length; } if (!strchr ("diouxXfeEgGcs", *f)) - error (1, 0, _("%%%c: invalid directive"), *f); + error (EXIT_FAILURE, 0, _("%%%c: invalid directive"), *f); ++direc_length; if (argc > 0) { diff --git a/src/pwd.c b/src/pwd.c index 7b941132c..6a4ce2ae0 100644 --- a/src/pwd.c +++ b/src/pwd.c @@ -76,7 +76,7 @@ main (int argc, char **argv) wd = xgetcwd (); if (wd == NULL) - error (1, errno, _("cannot get current directory")); + error (EXIT_FAILURE, errno, _("cannot get current directory")); printf ("%s\n", wd); exit (0); diff --git a/src/shred.c b/src/shred.c index fb77dcade..da2b78834 100644 --- a/src/shred.c +++ b/src/shred.c @@ -1556,7 +1556,7 @@ main (int argc, char **argv) || (word32) tmp != tmp || ((size_t) (tmp * sizeof (int)) / sizeof (int) != tmp)) { - error (1, 0, _("%s: invalid number of passes"), + error (EXIT_FAILURE, 0, _("%s: invalid number of passes"), quotearg_colon (optarg)); } flags.n_iterations = (size_t) tmp; @@ -1573,7 +1573,7 @@ main (int argc, char **argv) if (xstrtoumax (optarg, NULL, 0, &tmp, "cbBkKMGTPEZY0") != LONGINT_OK) { - error (1, 0, _("%s: invalid file size"), + error (EXIT_FAILURE, 0, _("%s: invalid file size"), quotearg_colon (optarg)); } flags.size = tmp; diff --git a/src/sleep.c b/src/sleep.c index 57be102de..62b1f16f8 100644 --- a/src/sleep.c +++ b/src/sleep.c @@ -173,7 +173,7 @@ clock_get_realtime (struct timespec *ts) #endif if (fail) - error (1, errno, _("cannot read realtime clock")); + error (EXIT_FAILURE, errno, _("cannot read realtime clock")); return ts; } diff --git a/src/stty.c b/src/stty.c index 3fe28c0e2..ed9ec5566 100644 --- a/src/stty.c +++ b/src/stty.c @@ -1,5 +1,5 @@ /* stty -- change and print terminal line settings - Copyright (C) 1990-2001 Free Software Foundation, Inc. + Copyright (C) 1990-2002 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -900,10 +900,10 @@ mutually exclusive")); device_name = file_name; fd = open (device_name, O_RDONLY | O_NONBLOCK); if (fd < 0) - error (1, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); if ((fdflags = fcntl (fd, F_GETFL)) == -1 || fcntl (fd, F_SETFL, fdflags & ~O_NONBLOCK) < 0) - error (1, errno, _("%s: couldn't reset non-blocking mode"), + error (EXIT_FAILURE, errno, _("%s: couldn't reset non-blocking mode"), device_name); } else @@ -916,7 +916,7 @@ mutually exclusive")); spurious difference in an uninitialized portion of the structure. */ memset (&mode, 0, sizeof (mode)); if (tcgetattr (fd, &mode)) - error (1, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); if (verbose_output || recoverable_output || noargs) { @@ -1078,7 +1078,7 @@ mutually exclusive")); struct termios new_mode; if (tcsetattr (fd, TCSADRAIN, &mode)) - error (1, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); /* POSIX (according to Zlotnick's book) tcsetattr returns zero if it performs *any* of the requested operations. This means it @@ -1091,7 +1091,7 @@ mutually exclusive")); spurious difference in an uninitialized portion of the structure. */ memset (&new_mode, 0, sizeof (new_mode)); if (tcgetattr (fd, &new_mode)) - error (1, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); /* Normally, one shouldn't use memcmp to compare structures that may have `holes' containing uninitialized data, but we have been @@ -1116,7 +1116,7 @@ mutually exclusive")); if (speed_was_set || memcmp (&mode, &new_mode, sizeof (mode)) != 0) #endif { - error (1, 0, + error (EXIT_FAILURE, 0, _("%s: unable to perform all requested operations"), device_name); #ifdef TESTING @@ -1397,7 +1397,7 @@ set_window_size (int rows, int cols, int fd, const char *device_name) if (get_win_size (fd, &win)) { if (errno != EINVAL) - error (1, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); memset (&win, 0, sizeof (win)); } @@ -1439,16 +1439,16 @@ set_window_size (int rows, int cols, int fd, const char *device_name) win.ws_col = 1; if (ioctl (fd, TIOCSWINSZ, (char *) &win)) - error (1, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); if (ioctl (fd, TIOCSSIZE, (char *) &ttysz)) - error (1, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); return; } # endif if (ioctl (fd, TIOCSWINSZ, (char *) &win)) - error (1, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); } static void @@ -1459,9 +1459,10 @@ display_window_size (int fancy, int fd, const char *device_name) if (get_win_size (fd, &win)) { if (errno != EINVAL) - error (1, errno, "%s", device_name); + error (EXIT_FAILURE, errno, "%s", device_name); if (!fancy) - error (1, 0, _("%s: no size information for this device"), device_name); + error (EXIT_FAILURE, 0, + _("%s: no size information for this device"), device_name); } else { diff --git a/src/su.c b/src/su.c index 3d834679e..5b1328ccf 100644 --- a/src/su.c +++ b/src/su.c @@ -347,13 +347,13 @@ change_identity (const struct passwd *pw) #ifdef HAVE_INITGROUPS errno = 0; if (initgroups (pw->pw_name, pw->pw_gid) == -1) - error (1, errno, _("cannot set groups")); + error (EXIT_FAILURE, errno, _("cannot set groups")); endgrent (); #endif if (setgid (pw->pw_gid)) - error (1, errno, _("cannot set group id")); + error (EXIT_FAILURE, errno, _("cannot set group id")); if (setuid (pw->pw_uid)) - error (1, errno, _("cannot set user id")); + error (EXIT_FAILURE, errno, _("cannot set user id")); } /* Run SHELL, or DEFAULT_SHELL if SHELL is empty. @@ -526,7 +526,7 @@ main (int argc, char **argv) pw = getpwnam (new_user); if (pw == 0) - error (1, 0, _("user %s does not exist"), new_user); + error (EXIT_FAILURE, 0, _("user %s does not exist"), new_user); endpwent (); /* Make sure pw->pw_shell is non-NULL. It may be NULL when NEW_USER @@ -549,7 +549,7 @@ main (int argc, char **argv) #ifdef SYSLOG_FAILURE log_su (pw, 0); #endif - error (1, 0, _("incorrect password")); + error (EXIT_FAILURE, 0, _("incorrect password")); } #ifdef SYSLOG_SUCCESS else diff --git a/src/tac-pipe.c b/src/tac-pipe.c index 8e21d1cc3..e8e41aed7 100644 --- a/src/tac-pipe.c +++ b/src/tac-pipe.c @@ -54,7 +54,7 @@ buf_init_from_stdin (Buf *x, int eol_byte) } bytes_read = full_read (STDIN_FILENO, buf, BUFFER_SIZE); if (bytes_read < 0) - error (1, errno, _("read error")); + error (EXIT_FAILURE, errno, _("read error")); { struct B_pair bp; diff --git a/src/tail.c b/src/tail.c index 773f32c71..c1d6034ce 100644 --- a/src/tail.c +++ b/src/tail.c @@ -397,15 +397,16 @@ xlseek (int fd, off_t offset, int whence, char const *filename) switch (whence) { case SEEK_SET: - error (1, errno, _("%s: cannot seek to offset %s%s"), + error (EXIT_FAILURE, errno, _("%s: cannot seek to offset %s%s"), filename, sign, s); break; case SEEK_CUR: - error (1, errno, _("%s: cannot seek to relative offset %s%s"), + error (EXIT_FAILURE, errno, _("%s: cannot seek to relative offset %s%s"), filename, sign, s); break; case SEEK_END: - error (1, errno, _("%s: cannot seek to end-relative offset %s%s"), + error (EXIT_FAILURE, errno, + _("%s: cannot seek to end-relative offset %s%s"), filename, sign, s); break; default: diff --git a/src/tee.c b/src/tee.c index 6fdd5f7e6..f89f298ee 100644 --- a/src/tee.c +++ b/src/tee.c @@ -148,7 +148,7 @@ main (int argc, char **argv) errs = tee (argc - optind, (const char **) &argv[optind]); if (close (STDIN_FILENO) != 0) - error (1, errno, _("standard input")); + error (EXIT_FAILURE, errno, _("standard input")); exit (errs); } diff --git a/src/touch.c b/src/touch.c index 2cbe7614f..836277eee 100644 --- a/src/touch.c +++ b/src/touch.c @@ -302,7 +302,7 @@ main (int argc, char **argv) flexible_date++; newtime = get_date (optarg, NULL); if (newtime == (time_t) -1) - error (1, 0, _("invalid date format %s"), quote (optarg)); + error (EXIT_FAILURE, 0, _("invalid date format %s"), quote (optarg)); date_set++; break; @@ -322,7 +322,7 @@ main (int argc, char **argv) posix_date++; if (! posixtime (&newtime, optarg, PDS_LEADING_YEAR | PDS_CENTURY | PDS_SECONDS)) - error (1, 0, _("invalid date format %s"), quote (optarg)); + error (EXIT_FAILURE, 0, _("invalid date format %s"), quote (optarg)); date_set++; break; @@ -353,7 +353,8 @@ main (int argc, char **argv) if (use_ref) { if (stat (ref_file, &ref_stats)) - error (1, errno, _("failed to get attributes of %s"), quote (ref_file)); + error (EXIT_FAILURE, errno, + _("failed to get attributes of %s"), quote (ref_file)); date_set++; } diff --git a/src/uname.c b/src/uname.c index 3b9403724..e35abfb54 100644 --- a/src/uname.c +++ b/src/uname.c @@ -223,7 +223,7 @@ main (int argc, char **argv) struct utsname name; if (uname (&name) == -1) - error (1, errno, _("cannot get system name")); + error (EXIT_FAILURE, errno, _("cannot get system name")); if (toprint & PRINT_KERNEL_NAME) print_element (name.sysname); diff --git a/src/uptime.c b/src/uptime.c index 5c644c4c0..a2468e319 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -126,7 +126,7 @@ print_uptime (int n, const STRUCT_UTMP *this) #endif { if (boot_time == 0) - error (1, errno, _("couldn't get boot time")); + error (EXIT_FAILURE, errno, _("couldn't get boot time")); uptime = time_now - boot_time; } updays = uptime / 86400; @@ -175,7 +175,7 @@ uptime (const char *filename) int fail = read_utmp (filename, &n_users, &utmp_buf); if (fail) - error (1, errno, "%s", filename); + error (EXIT_FAILURE, errno, "%s", filename); print_uptime (n_users, utmp_buf); } diff --git a/src/users.c b/src/users.c index 6067724c6..83192ae45 100644 --- a/src/users.c +++ b/src/users.c @@ -102,7 +102,7 @@ users (const char *filename) int fail = read_utmp (filename, &n_users, &utmp_buf); if (fail) - error (1, errno, "%s", filename); + error (EXIT_FAILURE, errno, "%s", filename); list_entries_users (n_users, utmp_buf); } diff --git a/src/who.c b/src/who.c index 95db2d5f7..4f8deff61 100644 --- a/src/who.c +++ b/src/who.c @@ -555,7 +555,7 @@ who (const char *filename) int fail = read_utmp (filename, &n_users, &utmp_buf); if (fail) - error (1, errno, "%s", filename); + error (EXIT_FAILURE, errno, "%s", filename); if (short_list) list_entries_who (n_users, utmp_buf); -- cgit v1.2.3-54-g00ecf