From: Paul Eggert Date: Sun, 18 Aug 2024 01:16:16 +0000 (-0700) Subject: maint: switch from ERROR to paxerror etc X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0dfcfa4aa48440f2641f80f71d0f4a75bd1fd0fb;p=thirdparty%2Ftar.git maint: switch from ERROR to paxerror etc Prefer functions like ‘paxerror’ to macros like ‘ERROR’. The functions have cleaner semantics, and calls are easier to read. --- diff --git a/src/buffer.c b/src/buffer.c index 11c5073e..1109e1e2 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -456,12 +456,12 @@ open_compressed_archive (void) { case ct_tar: if (shortfile) - ERROR ((0, 0, _("This does not look like a tar archive"))); + paxerror (0, _("This does not look like a tar archive")); return archive; case ct_none: if (shortfile) - ERROR ((0, 0, _("This does not look like a tar archive"))); + paxerror (0, _("This does not look like a tar archive")); set_compression_program_by_suffix (archive_name_array[0], NULL, false); if (!use_compress_program_option) @@ -680,8 +680,7 @@ check_tty (enum access_mode mode) if (strcmp (archive_name_array[0], "-") == 0 && isatty (mode == ACCESS_READ ? STDIN_FILENO : STDOUT_FILENO)) { - FATAL_ERROR ((0, 0, - mode == ACCESS_READ + paxfatal (0, (mode == ACCESS_READ ? _("Refusing to read archive contents from terminal " "(missing -f option?)") : _("Refusing to write archive contents to terminal " @@ -726,10 +725,10 @@ _open_archive (enum access_mode wanted_access) bool backed_up_flag = false; if (record_size == 0) - FATAL_ERROR ((0, 0, _("Invalid value for record_size"))); + paxfatal (0, 0, _("Invalid value for record_size")); if (archive_names == 0) - FATAL_ERROR ((0, 0, _("No archive name given"))); + paxfatal (0, _("No archive name given")); tar_stat_destroy (¤t_stat_info); @@ -772,7 +771,7 @@ _open_archive (enum access_mode wanted_access) { read_full_records = true; /* could be a pipe, be safe */ if (verify_option) - FATAL_ERROR ((0, 0, _("Cannot verify stdin/stdout archive"))); + paxfatal (0, _("Cannot verify stdin/stdout archive")); switch (wanted_access) { @@ -784,11 +783,10 @@ _open_archive (enum access_mode wanted_access) archive = STDIN_FILENO; type = check_compressed_archive (&shortfile); if (type != ct_tar && type != ct_none) - FATAL_ERROR ((0, 0, - _("Archive is compressed. Use %s option"), - compress_option (type))); + paxfatal (0, _("Archive is compressed. Use %s option"), + compress_option (type)); if (shortfile) - ERROR ((0, 0, _("This does not look like a tar archive"))); + paxerror (0, _("This does not look like a tar archive")); } break; @@ -840,8 +838,7 @@ _open_archive (enum access_mode wanted_access) break; default: - FATAL_ERROR ((0, 0, - _("Cannot update compressed archives"))); + paxfatal (0, _("Cannot update compressed archives")); } break; } @@ -928,13 +925,13 @@ archive_read_error (void) read_error (*archive_name_cursor); if (record_start_block == 0) - FATAL_ERROR ((0, 0, _("At beginning of tape, quitting now"))); + paxfatal (0, _("At beginning of tape, quitting now")); /* Read error in mid archive. We retry up to READ_ERROR_MAX times and then give up on reading the archive. */ if (read_error_count++ > READ_ERROR_MAX) - FATAL_ERROR ((0, 0, _("Too many errors, quitting"))); + paxfatal (0, _("Too many errors, quitting")); return; } @@ -966,11 +963,11 @@ short_read (size_t status) && archive_is_dev ()) { idx_t rsize = status / BLOCKSIZE; - WARN ((0, 0, - ngettext ("Record size = %td block", - "Record size = %td blocks", - rsize), - rsize)); + paxwarn (0, + ngettext ("Record size = %td block", + "Record size = %td blocks", + rsize), + rsize); } while (left % BLOCKSIZE != 0 @@ -987,11 +984,10 @@ short_read (size_t status) { idx_t rest = record_size - left; - FATAL_ERROR ((0, 0, - ngettext ("Unaligned block (%td byte) in archive", - "Unaligned block (%td bytes) in archive", + paxfatal (0, ngettext ("Unaligned block (%td byte) in archive", + "Unaligned block (%td bytes) in archive", rest), - rest)); + rest); } left -= status; @@ -1064,8 +1060,8 @@ backspace_output (void) { /* Lseek failed. Try a different method. */ - WARN ((0, 0, - _("Cannot backspace archive file; it may be unreadable without -i"))); + paxwarn (0, _("Cannot backspace archive file;" + " it may be unreadable without -i")); /* Replace the first part of the record with NULs. */ @@ -1102,7 +1098,7 @@ seek_archive (off_t size) return offset; if (offset % record_size) - FATAL_ERROR ((0, 0, _("rmtlseek not stopped at a record boundary"))); + paxfatal (0, _("rmtlseek not stopped at a record boundary")); /* Convert to number of records */ offset /= BLOCKSIZE; @@ -1163,8 +1159,8 @@ init_volume_number (void) { if (fscanf (file, "%d", &global_volno) != 1 || global_volno < 0) - FATAL_ERROR ((0, 0, _("%s: contains invalid volume number"), - quotearg_colon (volno_file_option))); + paxfatal (0, _("%s: contains invalid volume number"), + quotearg_colon (volno_file_option)); if (ferror (file)) read_error (volno_file_option); if (fclose (file) != 0) @@ -1198,7 +1194,7 @@ increase_volume_number (void) { global_volno++; if (global_volno < 0) - FATAL_ERROR ((0, 0, _("Volume number overflow"))); + paxfatal (0, _("Volume number overflow")); volno++; } @@ -1219,12 +1215,12 @@ change_tape_menu (FILE *read_file) if (getline (&input_buffer, &size, read_file) <= 0) { - WARN ((0, 0, _("EOF where user reply was expected"))); + paxwarn (0, _("EOF where user reply was expected")); if (subcommand_option != EXTRACT_SUBCOMMAND && subcommand_option != LIST_SUBCOMMAND && subcommand_option != DIFF_SUBCOMMAND) - WARN ((0, 0, _("WARNING: Archive is incomplete"))); + paxwarn (0, _("WARNING: Archive is incomplete")); fatal_exit (); } @@ -1251,12 +1247,12 @@ change_tape_menu (FILE *read_file) case 'q': /* Quit. */ - WARN ((0, 0, _("No new volume; exiting.\n"))); + paxwarn (0, _("No new volume; exiting.\n")); if (subcommand_option != EXTRACT_SUBCOMMAND && subcommand_option != LIST_SUBCOMMAND && subcommand_option != DIFF_SUBCOMMAND) - WARN ((0, 0, _("WARNING: Archive is incomplete"))); + paxwarn (0, _("WARNING: Archive is incomplete")); fatal_exit (); @@ -1347,8 +1343,7 @@ new_volume (enum access_mode mode) if (volno_file_option) closeout_volume_number (); if (sys_exec_info_script (archive_name_cursor, global_volno+1)) - FATAL_ERROR ((0, 0, _("%s command failed"), - quote (info_script_option))); + paxfatal (0, _("%s command failed"), quote (info_script_option)); } else change_tape_menu (read_file); @@ -1409,7 +1404,7 @@ read_header0 (struct tar_stat_info *info) set_next_block_after (current_header); return true; } - ERROR ((0, 0, _("This does not look like a tar archive"))); + paxerror (0, _("This does not look like a tar archive")); return false; } @@ -1446,7 +1441,7 @@ try_new_volume (void) header = find_next_block (); if (!header) { - WARN ((0, 0, _("This does not look like a tar archive"))); + paxwarn (0, _("This does not look like a tar archive")); return false; } @@ -1458,7 +1453,7 @@ try_new_volume (void) if (read_header (&header, &dummy, read_header_x_global) != HEADER_SUCCESS_EXTENDED) { - WARN ((0, 0, _("This does not look like a tar archive"))); + paxwarn (0, _("This does not look like a tar archive")); return false; } @@ -1487,7 +1482,7 @@ try_new_volume (void) break; default: - WARN ((0, 0, _("This does not look like a tar archive"))); + paxwarn (0, _("This does not look like a tar archive")); return false; } break; @@ -1522,8 +1517,8 @@ try_new_volume (void) { if (!continued_file_name) { - WARN ((0, 0, _("%s is not continued on this volume"), - quote (bufmap_head->file_name))); + paxwarn (0, _("%s is not continued on this volume"), + quote (bufmap_head->file_name)); return false; } @@ -1533,13 +1528,14 @@ try_new_volume (void) && strlen (bufmap_head->file_name) >= NAME_FIELD_SIZE && strncmp (continued_file_name, bufmap_head->file_name, NAME_FIELD_SIZE) == 0) - WARN ((0, 0, - _("%s is possibly continued on this volume: header contains truncated name"), - quote (bufmap_head->file_name))); + paxwarn (0, + _("%s is possibly continued on this volume:" + " header contains truncated name"), + quote (bufmap_head->file_name)); else { - WARN ((0, 0, _("%s is not continued on this volume"), - quote (bufmap_head->file_name))); + paxwarn (0, _("%s is not continued on this volume"), + quote (bufmap_head->file_name)); return false; } } @@ -1548,21 +1544,21 @@ try_new_volume (void) if (ckd_add (&s, continued_file_size, continued_file_offset) || s != bufmap_head->sizetotal) { - WARN ((0, 0, _("%s is the wrong size (%jd != %ju + %ju)"), - quote (continued_file_name), - intmax (bufmap_head->sizetotal), - uintmax (continued_file_size), - uintmax (continued_file_offset))); + paxwarn (0, _("%s is the wrong size (%jd != %ju + %ju)"), + quote (continued_file_name), + intmax (bufmap_head->sizetotal), + uintmax (continued_file_size), + uintmax (continued_file_offset)); return false; } if (bufmap_head->sizetotal - bufmap_head->sizeleft != continued_file_offset) { - WARN ((0, 0, _("This volume is out of sequence (%jd - %jd != %ju)"), - intmax (bufmap_head->sizetotal), - intmax (bufmap_head->sizeleft), - uintmax (continued_file_offset))); + paxwarn (0, _("This volume is out of sequence (%jd - %jd != %ju)"), + intmax (bufmap_head->sizetotal), + intmax (bufmap_head->sizeleft), + uintmax (continued_file_offset)); return false; } } @@ -1624,8 +1620,8 @@ match_volume_label (void) union block *label = find_next_block (); if (!label) - FATAL_ERROR ((0, 0, _("Archive not labeled to match %s"), - quote (volume_label_option))); + paxfatal (0, _("Archive not labeled to match %s"), + quote (volume_label_option)); if (label->header.typeflag == GNUTYPE_VOLHDR) { ASSIGN_STRING_N (&volume_label, label->header.name); @@ -1642,13 +1638,13 @@ match_volume_label (void) } if (!volume_label) - FATAL_ERROR ((0, 0, _("Archive not labeled to match %s"), - quote (volume_label_option))); + paxfatal (0, _("Archive not labeled to match %s"), + quote (volume_label_option)); if (!check_label_pattern (volume_label)) - FATAL_ERROR ((0, 0, _("Volume %s does not match %s"), - quote_n (0, volume_label), - quote_n (1, volume_label_option))); + paxfatal (0, _("Volume %s does not match %s"), + quote_n (0, volume_label), + quote_n (1, volume_label_option)); } /* Mark the archive with volume label STR. */ @@ -1737,9 +1733,10 @@ gnu_add_multi_volume_header (struct bufmap *map) if (len > NAME_FIELD_SIZE) { - WARN ((0, 0, - _("%s: file name too long to be stored in a GNU multivolume header, truncated"), - quotearg_colon (map->file_name))); + paxwarn (0, + _("%s: file name too long to be stored" + " in a GNU multivolume header, truncated"), + quotearg_colon (map->file_name)); len = NAME_FIELD_SIZE; } @@ -1931,7 +1928,7 @@ _gnu_flush_write (size_t buffer_level) if (status % BLOCKSIZE) { - ERROR ((0, 0, _("write did not end on a block boundary"))); + paxerror (0, _("write did not end on a block boundary")); archive_write_error (status); } diff --git a/src/checkpoint.c b/src/checkpoint.c index 5f82ef20..cfe20d98 100644 --- a/src/checkpoint.c +++ b/src/checkpoint.c @@ -132,7 +132,7 @@ checkpoint_compile_action (const char *str) act = alloc_action (cop_sleep); act->v.time = stoint (arg, &p, NULL, 0, TYPE_MAXIMUM (time_t)); if ((p == arg) | *p) - FATAL_ERROR ((0, 0, _("%s: not a valid timeout"), str)); + paxfatal (0, _("%s: not a valid timeout"), str); } else if (strcmp (str, "totals") == 0) alloc_action (cop_totals); @@ -143,7 +143,7 @@ checkpoint_compile_action (const char *str) sigaddset (&sigs, act->v.signal); } else - FATAL_ERROR ((0, 0, _("%s: unknown checkpoint action"), str)); + paxfatal (0, _("%s: unknown checkpoint action"), str); } void @@ -304,10 +304,10 @@ format_checkpoint_string (FILE *fp, size_t len, if (wordsplit (arg, &ws, (WRDSF_NOVAR | WRDSF_NOCMD | WRDSF_QUOTE | WRDSF_DELIM))) - ERROR ((0, 0, _("cannot split string '%s': %s"), - arg, wordsplit_strerror (&ws))); + paxerror (0, _("cannot split string '%s': %s"), + arg, wordsplit_strerror (&ws)); else if (3 < ws.ws_wordc) - ERROR ((0, 0, _("too many words in '%s'"), arg)); + paxerror (0, _("too many words in '%s'"), arg); else { int i; diff --git a/src/common.h b/src/common.h index 5216d09d..2d7f76cd 100644 --- a/src/common.h +++ b/src/common.h @@ -1027,12 +1027,8 @@ extern int warning_option; #define WARNING_ENABLED(opt) (warning_option & (opt)) -#define WARNOPT(opt,args) \ - do \ - { \ - if (WARNING_ENABLED (opt)) WARN (args); \ - } \ - while (0) +extern void warnopt (int, int, char const *, ...) + ATTRIBUTE_COLD ATTRIBUTE_FORMAT ((printf, 3, 4)); /* Module unlink.c */ diff --git a/src/compare.c b/src/compare.c index 90c89c9e..7716dfcd 100644 --- a/src/compare.c +++ b/src/compare.c @@ -133,7 +133,7 @@ read_and_process (struct tar_stat_info *st, bool (*processor) (idx_t, char *)) data_block = find_next_block (); if (! data_block) { - ERROR ((0, 0, _("Unexpected EOF in archive"))); + paxerror (0, _("Unexpected EOF in archive")); return; } @@ -477,9 +477,9 @@ diff_archive (void) switch (current_header->header.typeflag) { default: - ERROR ((0, 0, _("%s: Unknown file type '%c', diffed as normal file"), - quotearg_colon (current_stat_info.file_name), - current_header->header.typeflag)); + paxerror (0, _("%s: Unknown file type '%c', diffed as normal file"), + quotearg_colon (current_stat_info.file_name), + current_header->header.typeflag); FALLTHROUGH; case AREGTYPE: case REGTYPE: @@ -529,19 +529,17 @@ verify_volume (void) int may_fail = 0; if (removed_prefixes_p ()) { - WARN((0, 0, - _("Archive contains file names with leading prefixes removed."))); + paxwarn (0, + _("Archive contains file names with leading prefixes removed.")); may_fail = 1; } if (transform_program_p ()) { - WARN((0, 0, - _("Archive contains transformed file names."))); + paxwarn (0, _("Archive contains transformed file names.")); may_fail = 1; } if (may_fail) - WARN((0, 0, - _("Verification may fail to locate original files."))); + paxwarn (0, _("Verification may fail to locate original files.")); clear_directory_table (); @@ -595,10 +593,11 @@ verify_volume (void) } while (status == HEADER_FAILURE); - ERROR ((0, 0, - ngettext ("VERIFY FAILURE: %d invalid header detected", - "VERIFY FAILURE: %d invalid headers detected", - counter), counter)); + paxerror (0, + ngettext ("VERIFY FAILURE: %d invalid header detected", + "VERIFY FAILURE: %d invalid headers detected", + counter), + counter); } if (status == HEADER_END_OF_FILE) break; @@ -611,9 +610,9 @@ verify_volume (void) read_header_auto); if (status == HEADER_ZERO_BLOCK) break; - WARNOPT (WARN_ALONE_ZERO_BLOCK, - (0, 0, _("A lone zero block at %jd"), - intmax (current_block_ordinal ()))); + warnopt (WARN_ALONE_ZERO_BLOCK, + 0, _("A lone zero block at %jd"), + intmax (current_block_ordinal ())); } continue; } diff --git a/src/create.c b/src/create.c index 65a386b4..b6e555e3 100644 --- a/src/create.c +++ b/src/create.c @@ -69,12 +69,11 @@ exclusion_tag_warning (const char *dirname, const char *tagname, const char *message) { if (verbose_option) - WARNOPT (WARN_CACHEDIR, - (0, 0, - _("%s: contains a cache directory tag %s; %s"), - quotearg_colon (dirname), - quotearg_n (1, tagname), - message)); + warnopt (WARN_CACHEDIR, 0, + _("%s: contains a cache directory tag %s; %s"), + quotearg_colon (dirname), + quotearg_n (1, tagname), + message); } enum exclusion_tag_type @@ -238,14 +237,14 @@ to_chars_subst (bool negative, bool gnu_format, uintmax_t value, size_t valsize, Apart from this they are completely identical. */ uintmax_t s = (negsub &= archive_format == GNU_FORMAT) ? - sub : sub; char const *ssign = &"-"[!negsub]; - WARN ((0, 0, _("value %s%ju out of %s range %jd..%ju;" - " substituting %s%ju"), - valuesign, value, type, minval, maxval, ssign, s)); + paxwarn (0, _("value %s%ju out of %s range %jd..%ju;" + " substituting %s%ju"), + valuesign, value, type, minval, maxval, ssign, s); return to_chars (negsub, s, valsize, 0, where, size, type); } else - ERROR ((0, 0, _("value %s%ju out of %s range %jd..%ju"), - valuesign, value, type, minval, maxval)); + paxerror (0, _("value %s%ju out of %s range %jd..%ju"), + valuesign, value, type, minval, maxval); return false; } @@ -304,7 +303,7 @@ to_chars (bool negative, uintmax_t value, size_t valsize, if (! warned_once) { warned_once = true; - WARN ((0, 0, _("Generating negative octal headers"))); + paxwarn (0, _("Generating negative octal headers")); } where[size - 1] = '\0'; to_octal (value & MAX_VAL_WITH_DIGITS (valsize * CHAR_BIT, 1), @@ -581,18 +580,17 @@ write_ustar_long_name (const char *name) if (length > PREFIX_FIELD_SIZE + NAME_FIELD_SIZE + 1) { - ERROR ((0, 0, _("%s: file name is too long (max %d); not dumped"), - quotearg_colon (name), - PREFIX_FIELD_SIZE + NAME_FIELD_SIZE + 1)); + paxerror (0, _("%s: file name is too long (max %d); not dumped"), + quotearg_colon (name), + PREFIX_FIELD_SIZE + NAME_FIELD_SIZE + 1); return NULL; } i = split_long_name (name, length); if (i == 0 || (nlen = length - i - 1) > NAME_FIELD_SIZE || nlen == 0) { - ERROR ((0, 0, - _("%s: file name is too long (cannot be split); not dumped"), - quotearg_colon (name))); + paxerror (0, _("%s: file name is too long (cannot be split); not dumped"), + quotearg_colon (name)); return NULL; } @@ -617,9 +615,8 @@ write_long_link (struct tar_stat_info *st) case V7_FORMAT: /* old V7 tar format */ case USTAR_FORMAT: case STAR_FORMAT: - ERROR ((0, 0, - _("%s: link name is too long; not dumped"), - quotearg_colon (st->link_name))); + paxerror (0, _("%s: link name is too long; not dumped"), + quotearg_colon (st->link_name)); break; case OLDGNU_FORMAT: @@ -644,9 +641,8 @@ write_long_name (struct tar_stat_info *st) case V7_FORMAT: if (strlen (st->file_name) > NAME_FIELD_SIZE-1) { - ERROR ((0, 0, _("%s: file name is too long (max %d); not dumped"), - quotearg_colon (st->file_name), - NAME_FIELD_SIZE - 1)); + paxerror (0, _("%s: file name is too long (max %d); not dumped"), + quotearg_colon (st->file_name), NAME_FIELD_SIZE - 1); return NULL; } break; @@ -1080,15 +1076,14 @@ dump_regular_file (int fd, struct tar_stat_info *st) if (count != bufsize) { memset (blk->buffer + count, 0, bufsize - count); - WARNOPT (WARN_FILE_SHRANK, - (0, 0, - ngettext (("%s: File shrank by %jd byte;" - " padding with zeros"), - ("%s: File shrank by %jd bytes;" - " padding with zeros"), - size_left), - quotearg_colon (st->orig_file_name), - intmax (size_left))); + warnopt (WARN_FILE_SHRANK, 0, + ngettext (("%s: File shrank by %jd byte;" + " padding with zeros"), + ("%s: File shrank by %jd bytes;" + " padding with zeros"), + size_left), + quotearg_colon (st->orig_file_name), + intmax (size_left)); if (! ignore_failed_read_option) set_exit_status (TAREXIT_DIFFERS); pad_archive (size_left - (bufsize - count)); @@ -1180,10 +1175,9 @@ dump_dir0 (struct tar_stat_info *st, char const *directory) && st->parent->stat.st_dev != st->stat.st_dev) { if (verbose_option) - WARNOPT (WARN_XDEV, - (0, 0, - _("%s: file is on a different filesystem; not dumped"), - quotearg_colon (st->orig_file_name))); + warnopt (WARN_XDEV, 0, + _("%s: file is on a different filesystem; not dumped"), + quotearg_colon (st->orig_file_name)); } else { @@ -1433,9 +1427,8 @@ compare_links (void const *entry1, void const *entry2) static void unknown_file_error (char const *p) { - WARNOPT (WARN_FILE_IGNORED, - (0, 0, _("%s: Unknown file type; file ignored"), - quotearg_colon (p))); + warnopt (WARN_FILE_IGNORED, 0, + _("%s: Unknown file type; file ignored"), quotearg_colon (p)); if (!ignore_failed_read_option) set_exit_status (TAREXIT_FAILURE); } @@ -1535,19 +1528,13 @@ file_count_links (struct tar_stat_info *st) void check_links (void) { - struct link *lp; - if (!link_table) return; - for (lp = hash_get_first (link_table); lp; + for (struct link *lp = hash_get_first (link_table); lp; lp = hash_get_next (link_table, lp)) - { - if (lp->nlink) - { - WARN ((0, 0, _("Missing links to %s."), quote (lp->name))); - } - } + if (lp->nlink) + paxwarn (0, _("Missing links to %s."), quote (lp->name)); } /* Assuming DIR is the working directory, open FILE, using FLAGS to @@ -1704,18 +1691,16 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p) && (!after_date_option || OLDER_TAR_STAT_TIME (*st, c))) { if (!incremental_option && verbose_option) - WARNOPT (WARN_FILE_UNCHANGED, - (0, 0, _("%s: file is unchanged; not dumped"), - quotearg_colon (p))); + warnopt (WARN_FILE_UNCHANGED, 0, _("%s: file is unchanged; not dumped"), + quotearg_colon (p)); return allocated; } /* See if we are trying to dump the archive. */ if (sys_file_is_archive (st)) { - WARNOPT (WARN_IGNORE_ARCHIVE, - (0, 0, _("%s: archive cannot contain itself; not dumped"), - quotearg_colon (p))); + warnopt (WARN_IGNORE_ARCHIVE, 0, + _("%s: archive cannot contain itself; not dumped"), quotearg_colon (p)); return allocated; } @@ -1835,9 +1820,8 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p) if (!ok) { - WARNOPT (WARN_FILE_CHANGED, - (0, 0, _("%s: file changed as we read it"), - quotearg_colon (p))); + warnopt (WARN_FILE_CHANGED, 0, _("%s: file changed as we read it"), + quotearg_colon (p)); if (! ignore_failed_read_option) set_exit_status (TAREXIT_DIFFERS); } @@ -1910,14 +1894,12 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p) } else if (S_ISSOCK (st->stat.st_mode)) { - WARNOPT (WARN_FILE_IGNORED, - (0, 0, _("%s: socket ignored"), quotearg_colon (p))); + warnopt (WARN_FILE_IGNORED, 0, _("%s: socket ignored"), quotearg_colon (p)); return allocated; } else if (S_ISDOOR (st->stat.st_mode)) { - WARNOPT (WARN_FILE_IGNORED, - (0, 0, _("%s: door ignored"), quotearg_colon (p))); + warnopt (WARN_FILE_IGNORED, 0, _("%s: door ignored"), quotearg_colon (p)); return allocated; } else diff --git a/src/delete.c b/src/delete.c index 069c47fd..ecf8bbae 100644 --- a/src/delete.c +++ b/src/delete.c @@ -57,7 +57,7 @@ move_archive (off_t count) || ckd_add (&position, move_start, increment) || position < 0) { - ERROR ((0, EOVERFLOW, "lseek: %s", archive_name_array[0])); + paxerror (EOVERFLOW, "lseek: %s", archive_name_array[0]); return; } else if (rmtlseek (archive, position, SEEK_SET) == position) @@ -205,12 +205,12 @@ delete_archive_members (void) switch (previous_status) { case HEADER_STILL_UNREAD: - WARN ((0, 0, _("This does not look like a tar archive"))); + paxwarn (0, _("This does not look like a tar archive")); FALLTHROUGH; case HEADER_SUCCESS: case HEADER_SUCCESS_EXTENDED: case HEADER_ZERO_BLOCK: - ERROR ((0, 0, _("Skipping to next header"))); + paxerror (0, _("Skipping to next header")); FALLTHROUGH; case HEADER_FAILURE: break; @@ -348,7 +348,7 @@ delete_archive_members (void) break; case HEADER_FAILURE: - ERROR ((0, 0, _("Deleting non-header from archive"))); + paxerror (0, _("Deleting non-header from archive")); set_next_block_after (current_header); break; diff --git a/src/exclist.c b/src/exclist.c index e8d636e4..6c1a3dfd 100644 --- a/src/exclist.c +++ b/src/exclist.c @@ -93,7 +93,7 @@ info_attach_exclist (struct tar_stat_info *dir) fp = fdopen (fd, "r"); if (!fp) { - ERROR ((0, errno, _("%s: fdopen failed"), file->name)); + paxerror (errno, _("%s: fdopen failed"), file->name); close (fd); continue; } @@ -110,10 +110,7 @@ info_attach_exclist (struct tar_stat_info *dir) FNM_FILE_NAME|EXCLUDE_WILDCARDS|EXCLUDE_ANCHORED, '\n', vcsfile->data)) - { - int e = errno; - FATAL_ERROR ((0, e, "%s", quotearg_colon (file->name))); - } + paxfatal (errno, "%s", quotearg_colon (file->name)); fclose (fp); ent = xmalloc (sizeof (*ent)); diff --git a/src/extract.c b/src/extract.c index 36d34f92..77dbd5c9 100644 --- a/src/extract.c +++ b/src/extract.c @@ -369,9 +369,8 @@ static void check_time (char const *file_name, struct timespec t) { if (t.tv_sec < 0) - WARNOPT (WARN_TIMESTAMP, - (0, 0, _("%s: implausibly old time stamp %s"), - file_name, tartime (t, true))); + warnopt (WARN_TIMESTAMP, 0, _("%s: implausibly old time stamp %s"), + file_name, tartime (t, true)); else if (timespec_cmp (volume_start_time, t) < 0) { struct timespec now; @@ -387,9 +386,8 @@ check_time (char const *file_name, struct timespec t) diff.tv_nsec += BILLION; diff.tv_sec--; } - WARNOPT (WARN_TIMESTAMP, - (0, 0, _("%s: time stamp %s is %s s in the future"), - file_name, tartime (t, true), code_timespec (diff, buf))); + warnopt (WARN_TIMESTAMP, 0, _("%s: time stamp %s is %s s in the future"), + file_name, tartime (t, true), code_timespec (diff, buf)); } } } @@ -653,8 +651,8 @@ repair_delayed_set_stat (char const *dir, } } - ERROR ((0, 0, _("%s: Unexpected inconsistency when making directory"), - quotearg_colon (dir))); + paxerror (0, _("%s: Unexpected inconsistency when making directory"), + quotearg_colon (dir)); } static void @@ -891,8 +889,7 @@ maybe_recoverable (char *file_name, bool regular, bool *interdir_made) switch (old_files_option) { case SKIP_OLD_FILES: - WARNOPT (WARN_EXISTING_FILE, - (0, 0, _("%s: skipping existing file"), file_name)); + warnopt (WARN_EXISTING_FILE, 0, _("%s: skipping existing file"), file_name); return RECOVER_SKIP; case KEEP_OLD_FILES: @@ -1000,9 +997,10 @@ apply_nonancestor_delayed_set_stat (char const *file_name, bool after_links) current_mode_mask = ALL_MODE_BITS; if (! (st.st_dev == data->dev && st.st_ino == data->ino)) { - ERROR ((0, 0, - _("%s: Directory renamed before its status could be extracted"), - quotearg_colon (data->file_name))); + paxerror (0, + _("%s: Directory renamed before its status" + " could be extracted"), + quotearg_colon (data->file_name)); skip_this_one = 1; } } @@ -1223,8 +1221,8 @@ open_output_file (char const *file_name, int typeflag, mode_t mode, if (!conttype_diagnosed) { conttype_diagnosed = 1; - WARNOPT (WARN_CONTIGUOUS_CAST, - (0, 0, _("Extracting contiguous files as regular files"))); + warnopt (WARN_CONTIGUOUS_CAST, 0, + _("Extracting contiguous files as regular files")); } } @@ -1341,7 +1339,7 @@ extract_file (char *file_name, int typeflag) data_block = find_next_block (); if (! data_block) { - ERROR ((0, 0, _("Unexpected EOF in archive"))); + paxerror (0, _("Unexpected EOF in archive")); break; /* FIXME: What happens, then? */ } @@ -1611,10 +1609,9 @@ extract_symlink (char *file_name, MAYBE_UNUSED int typeflag) if (!warned) { warned = true; - WARNOPT (WARN_SYMLINK_CAST, - (0, 0, - _("Attempting extraction of symbolic links" - " as hard links"))); + warnopt (WARN_SYMLINK_CAST, 0, + _("Attempting extraction of symbolic links" + " as hard links")); } return extract_link (file_name, typeflag); } @@ -1755,21 +1752,19 @@ prepare_to_extract (char const *file_name, int typeflag, tar_extractor_t *fun) return false; case GNUTYPE_MULTIVOL: - ERROR ((0, 0, - _("%s: Cannot extract -- file is continued from another volume"), - quotearg_colon (current_stat_info.file_name))); + paxerror (0, _("%s: Cannot extract -- file is continued from another volume"), + quotearg_colon (current_stat_info.file_name)); return false; case GNUTYPE_LONGNAME: case GNUTYPE_LONGLINK: - ERROR ((0, 0, _("Unexpected long name header"))); + paxerror (0, _("Unexpected long name header")); return false; default: - WARNOPT (WARN_UNKNOWN_CAST, - (0, 0, - _("%s: Unknown file type '%c', extracted as normal file"), - quotearg_colon (file_name), typeflag)); + warnopt (WARN_UNKNOWN_CAST, 0, + _("%s: Unknown file type '%c', extracted as normal file"), + quotearg_colon (file_name), typeflag); extractor = extract_file; } @@ -1797,9 +1792,8 @@ prepare_to_extract (char const *file_name, int typeflag, tar_extractor_t *fun) case KEEP_NEWER_FILES: if (file_newer_p (file_name, 0, ¤t_stat_info)) { - WARNOPT (WARN_IGNORE_NEWER, - (0, 0, _("Current %s is newer or same age"), - quote (file_name))); + warnopt (WARN_IGNORE_NEWER, 0, _("Current %s is newer or same age"), + quote (file_name)); return false; } break; @@ -1828,8 +1822,8 @@ extract_archive (void) skip_dotdot_name = (!absolute_names_option && contains_dot_dot (current_stat_info.orig_file_name)); if (skip_dotdot_name) - ERROR ((0, 0, _("%s: Member name contains '..'"), - quotearg_colon (current_stat_info.orig_file_name))); + paxerror (0, _("%s: Member name contains '..'"), + quotearg_colon (current_stat_info.orig_file_name)); if (!current_stat_info.file_name[0] || skip_dotdot_name @@ -1859,9 +1853,8 @@ extract_archive (void) if (backup_option) if (!maybe_backup_file (current_stat_info.file_name, 0)) { - int e = errno; - ERROR ((0, e, _("%s: Was unable to backup this file"), - quotearg_colon (current_stat_info.file_name))); + paxerror (errno, _("%s: Was unable to backup this file"), + quotearg_colon (current_stat_info.file_name)); skip_member (); return; } @@ -2027,9 +2020,9 @@ rename_directory (char *src, char *dst) break; } - ERROR ((0, e, _("Cannot rename %s to %s"), - quote_n (0, src), - quote_n (1, dst))); + paxerror (e, _("Cannot rename %s to %s"), + quote_n (0, src), + quote_n (1, dst)); return false; } return true; diff --git a/src/incremen.c b/src/incremen.c index 0654e155..115bab3d 100644 --- a/src/incremen.c +++ b/src/incremen.c @@ -492,11 +492,10 @@ procdir (const char *name_buffer, struct tar_stat_info *st, { if (strcmp (d->name, name_buffer)) { - WARNOPT (WARN_RENAME_DIRECTORY, - (0, 0, - _("%s: Directory has been renamed from %s"), - quotearg_colon (name_buffer), - quote_n (1, d->name))); + warnopt (WARN_RENAME_DIRECTORY, 0, + _("%s: Directory has been renamed from %s"), + quotearg_colon (name_buffer), + quote_n (1, d->name)); directory->orig = d; DIR_SET_FLAG (directory, DIRF_RENAMED); DIR_CLEAR_FLAG (d, DIRF_RENAMED); @@ -536,10 +535,10 @@ procdir (const char *name_buffer, struct tar_stat_info *st, { if (strcmp (d->name, name_buffer)) { - WARNOPT (WARN_RENAME_DIRECTORY, - (0, 0, _("%s: Directory has been renamed from %s"), - quotearg_colon (name_buffer), - quote_n (1, d->name))); + warnopt (WARN_RENAME_DIRECTORY, 0, + _("%s: Directory has been renamed from %s"), + quotearg_colon (name_buffer), + quote_n (1, d->name)); directory->orig = d; DIR_SET_FLAG (directory, DIRF_RENAMED); DIR_CLEAR_FLAG (d, DIRF_RENAMED); @@ -550,9 +549,8 @@ procdir (const char *name_buffer, struct tar_stat_info *st, else { DIR_SET_FLAG (directory, DIRF_NEW); - WARNOPT (WARN_NEW_DIRECTORY, - (0, 0, _("%s: Directory is new"), - quotearg_colon (name_buffer))); + warnopt (WARN_NEW_DIRECTORY, 0, _("%s: Directory is new"), + quotearg_colon (name_buffer)); directory->children = (listed_incremental_option || (OLDER_STAT_TIME (*stat_data, m) @@ -566,10 +564,9 @@ procdir (const char *name_buffer, struct tar_stat_info *st, if (one_file_system_option && st->parent && stat_data->st_dev != st->parent->stat.st_dev) { - WARNOPT (WARN_XDEV, - (0, 0, - _("%s: directory is on a different filesystem; not dumped"), - quotearg_colon (directory->name))); + warnopt (WARN_XDEV, 0, + _("%s: directory is on a different filesystem; not dumped"), + quotearg_colon (directory->name)); directory->children = NO_CHILDREN; /* If there is any dumpdir info in that directory, remove it */ if (directory->dump) @@ -588,9 +585,8 @@ procdir (const char *name_buffer, struct tar_stat_info *st, } if (perhaps_renamed) - WARNOPT (WARN_RENAME_DIRECTORY, - (0, 0, _("%s: Directory has been renamed"), - quotearg_colon (name_buffer))); + warnopt (WARN_RENAME_DIRECTORY, 0, _("%s: Directory has been renamed"), + quotearg_colon (name_buffer)); DIR_SET_FLAG (directory, DIRF_INIT); @@ -995,10 +991,9 @@ read_incr_db_01 (int version, const char *initbuf) newer_mtime_option = decode_timespec (buf, &ebuf, false); if (! valid_timespec (newer_mtime_option)) - FATAL_ERROR ((0, errno, "%s:%jd: %s", - quotearg_colon (listed_incremental_option), - lineno, - _("Invalid time stamp"))); + paxfatal (errno, "%s:%jd: %s", + quotearg_colon (listed_incremental_option), + lineno, _("Invalid time stamp")); else { if (version == 1 && *ebuf) @@ -1009,10 +1004,9 @@ read_incr_db_01 (int version, const char *initbuf) = stoint (buf_ns, &ebuf, &overflow, 0, BILLION - 1); if ((ebuf == buf_ns) | *ebuf | overflow) { - ERROR ((0, 0, "%s:%jd: %s", - quotearg_colon (listed_incremental_option), - lineno, - _("Invalid time stamp"))); + paxerror (0, "%s:%jd: %s", + quotearg_colon (listed_incremental_option), lineno, + _("Invalid time stamp")); newer_mtime_option.tv_sec = TYPE_MINIMUM (time_t); newer_mtime_option.tv_nsec = -1; } @@ -1037,17 +1031,17 @@ read_incr_db_01 (int version, const char *initbuf) mtime = decode_timespec (strp, &ebuf, false); strp = ebuf; if (!valid_timespec (mtime) || *strp != ' ') - FATAL_ERROR ((0, errno, "%s:%jd: %s", - quotearg_colon (listed_incremental_option), lineno, - _("Invalid modification time"))); + paxfatal (errno, "%s:%jd: %s", + quotearg_colon (listed_incremental_option), lineno, + _("Invalid modification time")); bool overflow; mtime.tv_nsec = stoint (strp, &ebuf, &overflow, 0, BILLION - 1); if ((ebuf == strp) | (*ebuf != ' ') | overflow) { - FATAL_ERROR ((0, 0, "%s:%jd: %s", - quotearg_colon (listed_incremental_option), lineno, - _("Invalid modification time (nanoseconds)"))); + paxfatal (0, "%s:%jd: %s", + quotearg_colon (listed_incremental_option), lineno, + _("Invalid modification time (nanoseconds)")); mtime.tv_nsec = -1; } strp = ebuf; @@ -1059,17 +1053,17 @@ read_incr_db_01 (int version, const char *initbuf) dev = stoint (strp, &ebuf, &overflow, TYPE_MINIMUM (dev_t), TYPE_MAXIMUM (dev_t)); if ((ebuf == strp) | (*ebuf != ' ') | overflow) - FATAL_ERROR ((0, 0, "%s:%jd: %s", - quotearg_colon (listed_incremental_option), lineno, - _("Invalid device number"))); + paxfatal (0, "%s:%jd: %s", + quotearg_colon (listed_incremental_option), lineno, + _("Invalid device number")); strp = ebuf + 1; ino = stoint (strp, &ebuf, &overflow, TYPE_MINIMUM (ino_t), TYPE_MAXIMUM (ino_t)); if ((ebuf == strp) | (*ebuf != ' ') | overflow) - FATAL_ERROR ((0, 0, "%s:%jd: %s", - quotearg_colon (listed_incremental_option), lineno, - _("Invalid inode number"))); + paxfatal (0, "%s:%jd: %s", + quotearg_colon (listed_incremental_option), lineno, + _("Invalid inode number")); strp = ebuf + 1; unquote_string (strp); @@ -1120,11 +1114,11 @@ read_num (FILE *fp, char const *fieldname, { buf[i] = c; if (i == sizeof buf - 1) - FATAL_ERROR ((0, 0, - _("%s: byte %jd: %s %.*s... too long"), - quotearg_colon (listed_incremental_option), - intmax (ftello (fp)), - fieldname, i + 1, buf)); + paxfatal (0, + _("%s: byte %jd: %s %.*s... too long"), + quotearg_colon (listed_incremental_option), + intmax (ftello (fp)), + fieldname, i + 1, buf); c = getc (fp); } @@ -1135,20 +1129,18 @@ read_num (FILE *fp, char const *fieldname, if (ferror (fp)) read_fatal (listed_incremental_option); if (i != 0) - FATAL_ERROR ((0, 0, "%s: %s", - quotearg_colon (listed_incremental_option), - _("Unexpected EOF in snapshot file"))); + paxfatal (0, "%s: %s", + quotearg_colon (listed_incremental_option), + _("Unexpected EOF in snapshot file")); return false; } if (c) { unsigned uc = c; - FATAL_ERROR ((0, 0, - _("%s: byte %jd: %s %s followed by invalid byte 0x%02x"), - quotearg_colon (listed_incremental_option), - intmax (ftello (fp)), - fieldname, buf, uc)); + paxfatal (0, _("%s: byte %jd: %s %s followed by invalid byte 0x%02x"), + quotearg_colon (listed_incremental_option), + intmax (ftello (fp)), fieldname, buf, uc); } char *bufend; @@ -1156,15 +1148,13 @@ read_num (FILE *fp, char const *fieldname, *pval = stoint (buf, &bufend, &overflow, min_val, max_val); if (buf == bufend) - FATAL_ERROR ((0, EINVAL, - _("%s: byte %jd: %s %s"), - quotearg_colon (listed_incremental_option), - intmax (ftello (fp)), fieldname, buf)); + paxfatal (EINVAL, _("%s: byte %jd: %s %s"), + quotearg_colon (listed_incremental_option), + intmax (ftello (fp)), fieldname, buf); if (overflow) - FATAL_ERROR ((0, ERANGE, - _("%s: byte %jd: (valid range %jd..%ju)\n\t%s %s"), - quotearg_colon (listed_incremental_option), - intmax (ftello (fp)), min_val, max_val, fieldname, buf)); + paxfatal (ERANGE, _("%s: byte %jd: (valid range %jd..%ju)\n\t%s %s"), + quotearg_colon (listed_incremental_option), + intmax (ftello (fp)), min_val, max_val, fieldname, buf); return true; } @@ -1187,9 +1177,8 @@ read_timespec (FILE *fp, struct timespec *pval) } else { - FATAL_ERROR ((0, 0, "%s: %s", - quotearg_colon (listed_incremental_option), - _("Unexpected EOF in snapshot file"))); + paxfatal (0, "%s: %s", quotearg_colon (listed_incremental_option), + _("Unexpected EOF in snapshot file")); } } @@ -1240,18 +1229,17 @@ read_incr_db_2 (void) while (read_obstack (listed_incremental_stream, &stk, &s) == 0 && s > 1) ; if (getc (listed_incremental_stream) != 0) - FATAL_ERROR ((0, 0, _("%s: byte %s: %s"), - quotearg_colon (listed_incremental_option), - offtostr (ftello (listed_incremental_stream), offbuf), - _("Missing record terminator"))); + paxfatal (0, _("%s: byte %s: %s"), + quotearg_colon (listed_incremental_option), + offtostr (ftello (listed_incremental_stream), offbuf), + _("Missing record terminator")); content = obstack_finish (&stk); note_directory (name, mtime, dev, ino, nfs, false, content); obstack_free (&stk, content); } - FATAL_ERROR ((0, 0, "%s: %s", - quotearg_colon (listed_incremental_option), - _("Unexpected EOF in snapshot file"))); + paxfatal (0, "%s: %s", quotearg_colon (listed_incremental_option), + _("Unexpected EOF in snapshot file")); } /* Display (to stdout) the range of allowed values for each field @@ -1349,17 +1337,15 @@ read_directory_file (void) { ebuf = buf + sizeof PACKAGE_NAME - 1; if (*ebuf++ != '-') - FATAL_ERROR ((0, 0, _("Bad incremental file format"))); + paxfatal (0, _("Bad incremental file format")); for (; *ebuf != '-'; ebuf++) if (!*ebuf) - FATAL_ERROR ((0, 0, _("Bad incremental file format"))); + paxfatal (0, _("Bad incremental file format")); ebuf++; if (! ('0' <= *ebuf && *ebuf <= '0' + TAR_INCREMENTAL_VERSION && !c_isdigit (ebuf[1]))) - FATAL_ERROR ((0, 0, - _("Unsupported incremental format version: %s"), - ebuf)); + paxfatal (0, _("Unsupported incremental format version: %s"), ebuf); incremental_version = *ebuf - '0'; } else @@ -1483,7 +1469,7 @@ get_gnu_dumpdir (struct tar_stat_info *stat_info) mv_size_left (size); data_block = find_next_block (); if (!data_block) - FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); + paxfatal (0, _("Unexpected EOF in archive")); copied = available_space_after (data_block); if (copied > size) copied = size; @@ -1523,9 +1509,8 @@ dumpdir_ok (char *dumpdir) if (expect && *p != expect) { unsigned char uc = *p; - ERROR ((0, 0, - _("Malformed dumpdir: expected '%c' but found %#3o"), - expect, uc)); + paxerror (0, _("Malformed dumpdir: expected '%c' but found %#3o"), + expect, uc); return false; } switch (*p) @@ -1533,8 +1518,7 @@ dumpdir_ok (char *dumpdir) case 'X': if (has_tempdir) { - ERROR ((0, 0, - _("Malformed dumpdir: 'X' duplicated"))); + paxerror (0, _("Malformed dumpdir: 'X' duplicated")); return false; } else @@ -1546,8 +1530,7 @@ dumpdir_ok (char *dumpdir) { if (!has_tempdir) { - ERROR ((0, 0, - _("Malformed dumpdir: empty name in 'R'"))); + paxerror (0, _("Malformed dumpdir: empty name in 'R'")); return false; } else @@ -1559,14 +1542,12 @@ dumpdir_ok (char *dumpdir) case 'T': if (expect != 'T') { - ERROR ((0, 0, - _("Malformed dumpdir: 'T' not preceded by 'R'"))); + paxerror (0, _("Malformed dumpdir: 'T' not preceded by 'R'")); return false; } if (p[1] == 0 && !has_tempdir) { - ERROR ((0, 0, - _("Malformed dumpdir: empty name in 'T'"))); + paxerror (0, _("Malformed dumpdir: empty name in 'T'")); return false; } expect = 0; @@ -1585,15 +1566,12 @@ dumpdir_ok (char *dumpdir) if (expect) { - ERROR ((0, 0, - _("Malformed dumpdir: expected '%c' but found end of data"), - expect)); + paxerror (0, _("Malformed dumpdir: expected '%c' but found end of data"), expect); return false; } if (has_tempdir) - WARNOPT (WARN_BAD_DUMPDIR, - (0, 0, _("Malformed dumpdir: 'X' never used"))); + warnopt (WARN_BAD_DUMPDIR, 0, _("Malformed dumpdir: 'X' never used")); return true; } @@ -1636,9 +1614,8 @@ try_purge_directory (char const *directory_name) sizeof TEMP_DIR_TEMPLATE); if (!mkdtemp (temp_stub)) { - ERROR ((0, errno, - _("Cannot create temporary directory using template %s"), - quote (temp_stub))); + paxerror (errno, _("Cannot create temporary directory using template %s"), + quote (temp_stub)); free (temp_stub); free (current_dir); return false; @@ -1698,8 +1675,8 @@ try_purge_directory (char const *directory_name) dirs and check it here? */ { stat_diag (p); - WARN ((0, 0, _("%s: Not purging directory: unable to stat"), - quotearg_colon (p))); + paxwarn (0, _("%s: Not purging directory: unable to stat"), + quotearg_colon (p)); } continue; } @@ -1710,9 +1687,8 @@ try_purge_directory (char const *directory_name) { if (one_file_system_option && st.st_dev != root_device) { - WARN ((0, 0, - _("%s: directory is on a different device: not purging"), - quotearg_colon (p))); + paxwarn (0, _("%s: directory is on a different device: not purging"), + quotearg_colon (p)); continue; } @@ -1722,10 +1698,7 @@ try_purge_directory (char const *directory_name) fprintf (stdlis, _("%s: Deleting %s\n"), program_name, quote (p)); if (! remove_any_file (p, RECURSIVE_REMOVE_OPTION)) - { - int e = errno; - ERROR ((0, e, _("%s: Cannot remove"), quotearg_colon (p))); - } + paxerror (errno, _("%s: Cannot remove"), quotearg_colon (p)); } } } diff --git a/src/list.c b/src/list.c index 0026378f..beca8ee8 100644 --- a/src/list.c +++ b/src/list.c @@ -216,8 +216,8 @@ read_and (void (*do_something) (void)) case DIRTYPE: if (show_omitted_dirs_option) - WARN ((0, 0, _("%s: Omitting"), - quotearg_colon (current_stat_info.file_name))); + paxwarn (0, _("%s: Omitting"), + quotearg_colon (current_stat_info.file_name)); FALLTHROUGH; default: skip_member (); @@ -243,9 +243,8 @@ read_and (void (*do_something) (void)) read_header_auto); if (status == HEADER_ZERO_BLOCK) break; - WARNOPT (WARN_ALONE_ZERO_BLOCK, - (0, 0, _("A lone zero block at %jd"), - intmax (current_block_ordinal ()))); + warnopt (WARN_ALONE_ZERO_BLOCK, 0, _("A lone zero block at %jd"), + intmax (current_block_ordinal ())); break; } status = prev_status; @@ -253,9 +252,9 @@ read_and (void (*do_something) (void)) case HEADER_END_OF_FILE: if (!ignore_zeros_option) - WARNOPT (WARN_MISSING_ZERO_BLOCKS, - (0, 0, _("Terminating zero blocks missing at %jd"), - intmax (current_block_ordinal ()))); + warnopt (WARN_MISSING_ZERO_BLOCKS, 0, + _("Terminating zero blocks missing at %jd"), + intmax (current_block_ordinal ())); if (block_number_option) fprintf (stdlis, _("block %jd: ** End of File **\n"), intmax (current_block_ordinal ())); @@ -268,7 +267,7 @@ read_and (void (*do_something) (void)) switch (prev_status) { case HEADER_STILL_UNREAD: - ERROR ((0, 0, _("This does not look like a tar archive"))); + paxerror (0, _("This does not look like a tar archive")); FALLTHROUGH; case HEADER_ZERO_BLOCK: case HEADER_SUCCESS: @@ -280,7 +279,7 @@ read_and (void (*do_something) (void)) fprintf (stdlis, _("block %jd: "), intmax (block_ordinal)); } - ERROR ((0, 0, _("Skipping to next header"))); + paxerror (0, _("Skipping to next header")); break; case HEADER_END_OF_FILE: @@ -476,7 +475,7 @@ read_header (union block **return_block, struct tar_stat_info *info, data_block = find_next_block (); if (! data_block) { - ERROR ((0, 0, _("Unexpected EOF in archive"))); + paxerror (0, _("Unexpected EOF in archive")); break; } written = available_space_after (data_block); @@ -750,11 +749,11 @@ from_header (char const *where0, size_t digs, char const *type, if (where == lim) { if (type && !silent) - ERROR ((0, 0, - /* TRANSLATORS: %s is type of the value (gid_t, uid_t, - etc.) */ - _("Blanks in header where numeric %s value expected"), - type)); + paxerror (0, + /* TRANSLATORS: %s is type of the value (gid_t, uid_t, + etc.) */ + _("Blanks in header where numeric %s value expected"), + type); return -1; } if (!c_isspace (*where)) @@ -803,10 +802,11 @@ from_header (char const *where0, size_t digs, char const *type, if (!overflow && value <= minus_minval) { if (!silent) - WARN ((0, 0, - /* TRANSLATORS: Second %s is a type name (gid_t,uid_t,etc.) */ - _("Archive octal value %.*s is out of %s range; assuming two's complement"), - (int) (where - where1), where1, type)); + paxwarn (0, + /* TRANSLATORS: Second %s is a type name (gid_t,uid_t,etc.) */ + _("Archive octal value %.*s is out of %s range;" + " assuming two's complement"), + (int) (where - where1), where1, type); negative = true; } } @@ -814,10 +814,10 @@ from_header (char const *where0, size_t digs, char const *type, if (overflow) { if (type && !silent) - ERROR ((0, 0, - /* TRANSLATORS: Second %s is a type name (gid_t,uid_t,etc.) */ - _("Archive octal value %.*s is out of %s range"), - (int) (where - where1), where1, type)); + paxerror (0, + /* TRANSLATORS: Second %s is a type name (gid_t,uid_t,etc.) */ + _("Archive octal value %.*s is out of %s range"), + (int) (where - where1), where1, type); return -1; } } @@ -836,7 +836,7 @@ from_header (char const *where0, size_t digs, char const *type, if (! warned_once) { warned_once = true; - WARN ((0, 0, _("Archive contains obsolescent base-64 headers"))); + paxwarn (0, _("Archive contains obsolescent base-64 headers")); } } negative = *where++ == '-'; @@ -849,9 +849,8 @@ from_header (char const *where0, size_t digs, char const *type, if (ckd_mul (&value, value, 64)) { if (type && !silent) - ERROR ((0, 0, - _("Archive signed base-64 string %s is out of %s range"), - quote_mem (where0, digs), type)); + paxerror (0, _("Archive signed base-64 string %s is out of %s range"), + quote_mem (where0, digs), type); return -1; } value |= dig - 1; @@ -881,9 +880,7 @@ from_header (char const *where0, size_t digs, char const *type, if (((value << LG_256 >> LG_256) | topbits) != value) { if (type && !silent) - ERROR ((0, 0, - _("Archive base-256 value is out of %s range"), - type)); + paxerror (0, _("Archive base-256 value is out of %s range"), type); return -1; } } @@ -909,10 +906,10 @@ from_header (char const *where0, size_t digs, char const *type, lim--; quotearg_buffer (buf, sizeof buf, where0, lim - where0, o); if (!silent) - ERROR ((0, 0, - /* TRANSLATORS: Second %s is a type name (gid_t,uid_t,etc.) */ - _("Archive contains %.*s where numeric %s value expected"), - (int) sizeof buf, buf, type)); + paxerror (0, + /* TRANSLATORS: Second %s is a type name (gid_t,uid_t,etc.) */ + _("Archive contains %.*s where numeric %s value expected"), + (int) sizeof buf, buf, type); } return -1; @@ -925,8 +922,8 @@ from_header (char const *where0, size_t digs, char const *type, { char const *value_sign = &"-"[!negative]; /* TRANSLATORS: Second %s is type name (gid_t,uid_t,etc.) */ - ERROR ((0, 0, _("Archive value %s%ju is out of %s range %jd..%ju"), - value_sign, value, type, minval, maxval)); + paxerror (0, _("Archive value %s%ju is out of %s range %jd..%ju"), + value_sign, value, type, minval, maxval); } return -1; @@ -1150,7 +1147,7 @@ simple_print_header (struct tar_stat_info *st, union block *blk, case GNUTYPE_LONGNAME: case GNUTYPE_LONGLINK: modes[0] = 'L'; - ERROR ((0, 0, _("Unexpected long name header"))); + paxerror (0, _("Unexpected long name header")); break; case GNUTYPE_SPARSE: @@ -1387,7 +1384,7 @@ skim_file (off_t size, bool must_copy) { x = find_next_block (); if (! x) - FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); + paxfatal (0, _("Unexpected EOF in archive")); set_next_block_after (x); size -= BLOCKSIZE; diff --git a/src/map.c b/src/map.c index 499c3fb3..69d1a688 100644 --- a/src/map.c +++ b/src/map.c @@ -98,8 +98,8 @@ map_read (Hash_table **ptab, char const *file, ++line; if (wordsplit (buf, &ws, wsopt)) - FATAL_ERROR ((0, 0, _("%s:%jd: cannot split line: %s"), - file, line, wordsplit_strerror (&ws))); + paxfatal (0, _("%s:%jd: cannot split line: %s"), + file, line, wordsplit_strerror (&ws)); wsopt |= WRDSF_REUSE; if (ws.ws_wordc == 0) continue; @@ -177,7 +177,7 @@ map_read (Hash_table **ptab, char const *file, wordsplit_free (&ws); fclose (fp); if (err) - FATAL_ERROR ((0, 0, _("errors reading map file"))); + paxfatal (0, _("errors reading map file")); } /* UID translation */ diff --git a/src/misc.c b/src/misc.c index 073af842..03da6f44 100644 --- a/src/misc.c +++ b/src/misc.c @@ -798,9 +798,9 @@ maybe_backup_file (const char *file_name, bool this_is_the_archive) { /* The backup operation failed. */ int e = errno; - ERROR ((0, e, _("%s: Cannot rename to %s"), - quotearg_colon (before_backup_name), - quote_n (1, after_backup_name))); + paxerror (e, _("%s: Cannot rename to %s"), + quotearg_colon (before_backup_name), + quote_n (1, after_backup_name)); assign_null (&after_backup_name); return false; } @@ -817,9 +817,9 @@ undo_last_backup (void) != 0) { int e = errno; - ERROR ((0, e, _("%s: Cannot rename to %s"), - quotearg_colon (after_backup_name), - quote_n (1, before_backup_name))); + paxerror (e, _("%s: Cannot rename to %s"), + quotearg_colon (after_backup_name), + quote_n (1, before_backup_name)); } if (verbose_option) fprintf (stdlis, _("Renaming %s back to %s\n"), @@ -1201,9 +1201,8 @@ file_removed_diag (const char *name, bool top_level, { if (!top_level && errno == ENOENT) { - WARNOPT (WARN_FILE_REMOVED, - (0, 0, _("%s: File removed before we read it"), - quotearg_colon (name))); + warnopt (WARN_FILE_REMOVED, 0, _("%s: File removed before we read it"), + quotearg_colon (name)); set_exit_status (TAREXIT_DIFFERS); } else diff --git a/src/names.c b/src/names.c index bdb7519f..c161f909 100644 --- a/src/names.c +++ b/src/names.c @@ -385,10 +385,7 @@ handle_file_selection_option (int key, const char *arg) case 'X': if (add_exclude_file (add_exclude, excluded, arg, EXCLUDE_OPTIONS, '\n') != 0) - { - int e = errno; - FATAL_ERROR ((0, e, "%s", quotearg_colon (arg))); - } + paxfatal (errno, "%s", quotearg_colon (arg)); break; case ANCHORED_OPTION: @@ -433,7 +430,7 @@ handle_file_selection_option (int key, const char *arg) break; default: - FATAL_ERROR ((0, 0, "unhandled positional option %d", key)); + paxfatal (0, "unhandled positional option %d", key); } } @@ -745,7 +742,10 @@ unconsumed_option_report (void) { struct name_elt *elt; - ERROR ((0, 0, _("The following options were used after non-option arguments. These options are positional and affect only arguments that follow them. Please, rearrange them properly."))); + paxerror (0, _("The following options were used after non-option arguments." + " These options are positional and affect" + " only arguments that follow them." + " Please, rearrange them properly.")); elt = unconsumed_option_tail; while (elt->prev) @@ -756,17 +756,17 @@ unconsumed_option_report (void) switch (elt->type) { case NELT_CHDIR: - ERROR ((0, 0, _("-C %s has no effect"), quote (elt->v.name))); + paxerror (0, _("-C %s has no effect"), quote (elt->v.name)); break; case NELT_OPTION: if (elt->v.opt.arg) - ERROR ((0, 0, _("--%s %s has no effect"), - file_selection_option_name (elt->v.opt.option), - quote (elt->v.opt.arg))); + paxerror (0, _("--%s %s has no effect"), + file_selection_option_name (elt->v.opt.option), + quote (elt->v.opt.arg)); else - ERROR ((0, 0, _("--%s has no effect"), - file_selection_option_name (elt->v.opt.option))); + paxerror (0, _("--%s has no effect"), + file_selection_option_name (elt->v.opt.option)); break; default: @@ -917,10 +917,9 @@ add_file_id (const char *filename) if (p->ino == st.st_ino && p->dev == st.st_dev) { int oldc = set_char_quoting (NULL, ':', 1); - ERROR ((0, 0, - _("%s: file list requested from %s already read from %s"), - quotearg_n (0, filename), - reading_from, p->from_file)); + paxerror (0, _("%s: file list requested from %s already read from %s"), + quotearg_n (0, filename), + reading_from, p->from_file); set_char_quoting (NULL, ':', oldc); return 1; } @@ -997,11 +996,11 @@ handle_option (const char *str, struct name_elt const *ent) ws.ws_offs = 1; if (wordsplit (str, &ws, WRDSF_DEFFLAGS|WRDSF_DOOFFS)) - FATAL_ERROR ((0, 0, _("cannot split string '%s': %s"), - str, wordsplit_strerror (&ws))); + paxfatal (0, _("cannot split string '%s': %s"), + str, wordsplit_strerror (&ws)); int argc; if (ckd_add (&argc, ws.ws_wordc, ws.ws_offs)) - FATAL_ERROR ((0, 0, _("too many options"))); + paxfatal (0, _("too many options")); ws.ws_wordv[0] = (char *) program_name; loc.source = OPTS_FILE; loc.name = ent->v.file.name; @@ -1046,9 +1045,9 @@ read_next_name (struct name_elt *ent, struct name_elt *ret) continue; case file_list_zero: - WARNOPT (WARN_FILENAME_WITH_NULS, - (0, 0, N_("%s: file name read contains nul character"), - quotearg_colon (ent->v.file.name))); + warnopt (WARN_FILENAME_WITH_NULS, 0, + N_("%s: file name read contains nul character"), + quotearg_colon (ent->v.file.name)); ent->v.file.term = 0; FALLTHROUGH; case file_list_success: @@ -1410,11 +1409,9 @@ regex_usage_warning (const char *name) && fnmatch_pattern_has_wildcards (name, 0)) { warned_once = 1; - WARN ((0, 0, - _("Pattern matching characters used in file names"))); - WARN ((0, 0, - _("Use --wildcards to enable pattern matching," - " or --no-wildcards to suppress this warning"))); + paxwarn (0, _("Pattern matching characters used in file names")); + paxwarn (0, _("Use --wildcards to enable pattern matching," + " or --no-wildcards to suppress this warning")); } return warned_once; } @@ -1429,11 +1426,11 @@ names_notfound (void) if (!WASFOUND (cursor) && cursor->name[0]) { regex_usage_warning (cursor->name); - ERROR ((0, 0, - (cursor->found_count == 0) ? - _("%s: Not found in archive") : - _("%s: Required occurrence not found in archive"), - quotearg_colon (cursor->name))); + paxerror (0, + (cursor->found_count == 0 + ? _("%s: Not found in archive") + : _("%s: Required occurrence not found in archive")), + quotearg_colon (cursor->name)); } /* Don't bother freeing the name list; we're about to exit. */ @@ -1447,8 +1444,7 @@ names_notfound (void) while ((name = name_next (true))) { regex_usage_warning (name); - ERROR ((0, 0, _("%s: Not found in archive"), - quotearg_colon (name))); + paxerror (0, _("%s: Not found in archive"), quotearg_colon (name)); } } } @@ -1760,15 +1756,13 @@ collect_and_sort_names (void) case 1: if (namelist->change_dir == 0) - USAGE_ERROR ((0, 0, - _("Using -C option inside file list is not " - "allowed with --listed-incremental"))); + paxusage (_("Using -C option inside file list is not " + "allowed with --listed-incremental")); break; default: - USAGE_ERROR ((0, 0, - _("Only one -C option is allowed with " - "--listed-incremental"))); + paxusage (_("Only one -C option is allowed with " + "--listed-incremental")); } read_directory_file (); diff --git a/src/sparse.c b/src/sparse.c index 70ab557a..80a1ff59 100644 --- a/src/sparse.c +++ b/src/sparse.c @@ -360,8 +360,7 @@ sparse_scan_file (struct tar_sparse_file *file) return true; #else if (hole_detection == HOLE_DETECTION_SEEK) - WARN((0, 0, - _("\"seek\" hole detection is not supported, using \"raw\"."))); + paxwarn (0, _("\"seek\" hole detection is not supported, using \"raw\".")); /* fall back to "raw" for this and all other files */ hole_detection = HOLE_DETECTION_RAW; #endif @@ -454,13 +453,12 @@ sparse_dump_region (struct tar_sparse_file *file, size_t i) + file->stat_info->sparse_map[i].numbytes - bytes_left); - WARNOPT (WARN_FILE_SHRANK, - (0, 0, - ngettext ("%s: File shrank by %jd byte; padding with zeros", - "%s: File shrank by %jd bytes; padding with zeros", - n), - quotearg_colon (file->stat_info->orig_file_name), - intmax (n))); + warnopt (WARN_FILE_SHRANK, 0, + ngettext ("%s: File shrank by %jd byte; padding with zeros", + "%s: File shrank by %jd bytes; padding with zeros", + n), + quotearg_colon (file->stat_info->orig_file_name), + intmax (n)); if (! ignore_failed_read_option) set_exit_status (TAREXIT_DIFFERS); return false; @@ -498,7 +496,7 @@ sparse_extract_region (struct tar_sparse_file *file, size_t i) union block *blk = find_next_block (); if (!blk) { - ERROR ((0, 0, _("Unexpected EOF in archive"))); + paxerror (0, _("Unexpected EOF in archive")); return false; } set_next_block_after (blk); @@ -684,7 +682,7 @@ check_data_region (struct tar_sparse_file *file, size_t i) union block *blk = find_next_block (); if (!blk) { - ERROR ((0, 0, _("Unexpected EOF in archive"))); + paxerror (0, _("Unexpected EOF in archive")); return false; } set_next_block_after (blk); @@ -843,7 +841,7 @@ oldgnu_get_sparse_info (struct tar_sparse_file *file) h = find_next_block (); if (!h) { - ERROR ((0, 0, _("Unexpected EOF in archive"))); + paxerror (0, _("Unexpected EOF in archive")); return false; } set_next_block_after (h); @@ -853,8 +851,8 @@ oldgnu_get_sparse_info (struct tar_sparse_file *file) if (rc == add_fail) { - ERROR ((0, 0, _("%s: invalid sparse archive member"), - file->stat_info->orig_file_name)); + paxerror (0, _("%s: invalid sparse archive member"), + file->stat_info->orig_file_name); return false; } return true; @@ -975,7 +973,7 @@ star_get_sparse_info (struct tar_sparse_file *file) h = find_next_block (); if (!h) { - ERROR ((0, 0, _("Unexpected EOF in archive"))); + paxerror (0, _("Unexpected EOF in archive")); return false; } set_next_block_after (h); @@ -986,8 +984,8 @@ star_get_sparse_info (struct tar_sparse_file *file) if (rc == add_fail) { - ERROR ((0, 0, _("%s: invalid sparse archive member"), - file->stat_info->orig_file_name)); + paxerror (0, _("%s: invalid sparse archive member"), + file->stat_info->orig_file_name); return false; } return true; @@ -1279,8 +1277,8 @@ pax_decode_header (struct tar_sparse_file *file) { \ if (dst == buf + UINTMAX_STRSIZE_BOUND -1) \ { \ - ERROR ((0, 0, _("%s: numeric overflow in sparse archive member"), \ - file->stat_info->orig_file_name)); \ + paxerror (0, _("%s: numeric overflow in sparse archive member"), \ + file->stat_info->orig_file_name); \ return false; \ } \ if (src == endp) \ @@ -1288,7 +1286,7 @@ pax_decode_header (struct tar_sparse_file *file) set_next_block_after (b); \ b = find_next_block (); \ if (!b) \ - FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); \ + paxfatal (0, _("Unexpected EOF in archive")); \ src = b->buffer; \ endp = b->buffer + BLOCKSIZE; \ } \ @@ -1302,13 +1300,13 @@ pax_decode_header (struct tar_sparse_file *file) set_next_block_after (current_header); blk = find_next_block (); if (!blk) - FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); + paxfatal (0, _("Unexpected EOF in archive")); p = blk->buffer; COPY_BUF (blk,nbuf,p); if (!decode_num (&u, nbuf, SIZE_MAX)) { - ERROR ((0, 0, _("%s: malformed sparse archive member"), - file->stat_info->orig_file_name)); + paxerror (0, _("%s: malformed sparse archive member"), + file->stat_info->orig_file_name); return false; } file->stat_info->sparse_map_size = u; @@ -1322,8 +1320,8 @@ pax_decode_header (struct tar_sparse_file *file) COPY_BUF (blk,nbuf,p); if (!decode_num (&u, nbuf, TYPE_MAXIMUM (off_t))) { - ERROR ((0, 0, _("%s: malformed sparse archive member"), - file->stat_info->orig_file_name)); + paxerror (0, _("%s: malformed sparse archive member"), + file->stat_info->orig_file_name); return false; } sp.offset = u; @@ -1333,8 +1331,8 @@ pax_decode_header (struct tar_sparse_file *file) || ckd_add (&size, sp.offset, u) || file->stat_info->stat.st_size < size) { - ERROR ((0, 0, _("%s: malformed sparse archive member"), - file->stat_info->orig_file_name)); + paxerror (0, _("%s: malformed sparse archive member"), + file->stat_info->orig_file_name); return false; } sp.numbytes = u; diff --git a/src/suffix.c b/src/suffix.c index 6128ec0b..0d1f34ee 100644 --- a/src/suffix.c +++ b/src/suffix.c @@ -103,11 +103,11 @@ set_compression_program_by_suffix (const char *name, const char *defprog, { use_compress_program_option = defprog; if (len > 0 && verbose) - WARN ((0, 0, - _("no compression program is defined for suffix '%s';" - " assuming %s"), - name + len, - defprog ? defprog : "uncompressed archive")); + paxwarn (0, + _("no compression program is defined for suffix '%s';" + " assuming %s"), + name + len, + defprog ? defprog : "uncompressed archive"); } } diff --git a/src/system.c b/src/system.c index 296053fc..eff8dae5 100644 --- a/src/system.c +++ b/src/system.c @@ -147,14 +147,14 @@ sys_write_archive_buffer (void) void sys_child_open_for_compress (void) { - FATAL_ERROR ((0, 0, _("Cannot use compressed or remote archives"))); + paxfatal (0, _("Cannot use compressed or remote archives")); } /* Set ARCHIVE for uncompressing, then reading an archive. */ void sys_child_open_for_uncompress (void) { - FATAL_ERROR ((0, 0, _("Cannot use compressed or remote archives"))); + paxfatal (0, _("Cannot use compressed or remote archives")); } int @@ -164,7 +164,7 @@ sys_exec_setmtime_script (const char *script_name, const char *fmt, struct timespec *ts) { - FATAL_ERROR ((0, 0, _("--set-mtime-command not implemented on this platform"))); + paxfatal (0, _("--set-mtime-command not implemented on this platform")); } #else @@ -233,11 +233,11 @@ sys_wait_for_child (pid_t child_pid, bool eof) { int sig = WTERMSIG (wait_status); if (!(!eof && sig == SIGPIPE)) - FATAL_ERROR ((0, 0, _("Child died with signal %d"), sig)); + paxfatal (0, _("Child died with signal %d"), sig); } else if (WEXITSTATUS (wait_status) != 0) - FATAL_ERROR ((0, 0, _("Child returned status %d"), - WEXITSTATUS (wait_status))); + paxfatal (0, _("Child returned status %d"), + WEXITSTATUS (wait_status)); } } @@ -328,10 +328,7 @@ xdup2 (int from, int into) if (from != into) { if (dup2 (from, into) < 0) - { - int e = errno; - FATAL_ERROR ((0, e, _("Cannot dup2"))); - } + paxfatal (errno, _("Cannot dup2")); xclose (from); } } @@ -517,14 +514,12 @@ run_decompress_program (void) { if (prog) { - WARNOPT (WARN_DECOMPRESS_PROGRAM, - (0, errno, _("cannot run %s"), prog)); - WARNOPT (WARN_DECOMPRESS_PROGRAM, - (0, 0, _("trying %s"), p)); + warnopt (WARN_DECOMPRESS_PROGRAM, errno, _("cannot run %s"), prog); + warnopt (WARN_DECOMPRESS_PROGRAM, 0, _("trying %s"), p); } if (wordsplit (p, &ws, wsflags)) - FATAL_ERROR ((0, 0, _("cannot split string '%s': %s"), - p, wordsplit_strerror (&ws))); + paxfatal (0, _("cannot split string '%s': %s"), + p, wordsplit_strerror (&ws)); wsflags |= WRDSF_REUSE; memmove (ws.ws_wordv, ws.ws_wordv + ws.ws_offs, ws.ws_wordc * sizeof *ws.ws_wordv); @@ -534,7 +529,7 @@ run_decompress_program (void) ws.ws_wordv[ws.ws_wordc] = NULL; } if (!prog) - FATAL_ERROR ((0, 0, _("unable to run decompression program"))); + paxfatal (0, _("unable to run decompression program")); exec_fatal (prog); } @@ -805,17 +800,17 @@ sys_wait_command (void) if (WIFEXITED (status)) { if (!ignore_command_error_option && WEXITSTATUS (status)) - ERROR ((0, 0, _("%jd: Child returned status %d"), - intmax (global_pid), WEXITSTATUS (status))); + paxerror (0, _("%jd: Child returned status %d"), + intmax (global_pid), WEXITSTATUS (status)); } else if (WIFSIGNALED (status)) { - WARN ((0, 0, _("%jd: Child terminated on signal %d"), - intmax (global_pid), WTERMSIG (status))); + paxwarn (0, _("%jd: Child terminated on signal %d"), + intmax (global_pid), WTERMSIG (status)); } else - ERROR ((0, 0, _("%jd: Child terminated on unknown reason"), - intmax (global_pid))); + paxerror (0, _("%jd: Child terminated on unknown reason"), + intmax (global_pid)); global_pid = -1; } @@ -951,7 +946,7 @@ sys_exec_setmtime_script (const char *script_name, int rc = 0; if (pipe (p)) - FATAL_ERROR ((0, errno, _("pipe failed"))); + paxfatal (errno, _("pipe failed")); if ((pid = xfork ()) == 0) { @@ -964,12 +959,12 @@ sys_exec_setmtime_script (const char *script_name, if (dirfd != AT_FDCWD) { if (fchdir (dirfd)) - FATAL_ERROR ((0, errno, _("chdir failed"))); + paxfatal (errno, _("chdir failed")); } close (p[0]); if (dup2 (p[1], STDOUT_FILENO) < 0) - FATAL_ERROR ((0, errno, _("dup2 failed"))); + paxfatal (errno, _("dup2 failed")); if (p[1] != STDOUT_FILENO) close (p[1]); @@ -992,7 +987,7 @@ sys_exec_setmtime_script (const char *script_name, { if (errno != EINTR) { - ERROR ((0, errno, _("poll failed"))); + paxerror (errno, _("poll failed")); stop = 1; break; } @@ -1010,7 +1005,7 @@ sys_exec_setmtime_script (const char *script_name, ssize_t nread = read (pfd.fd, buffer + buflen, bufsize - buflen); if (nread < 0) { - ERROR ((0, errno, _("error reading output of %s"), script_name)); + paxerror (errno, _("error reading output of %s"), script_name); stop = 1; break; } @@ -1036,7 +1031,7 @@ sys_exec_setmtime_script (const char *script_name, if (buflen == 0) { - ERROR ((0, 0, _("empty output from \"%s %s\""), script_name, file_name)); + paxerror (0, _("empty output from \"%s %s\""), script_name, file_name); return -1; } @@ -1057,14 +1052,15 @@ sys_exec_setmtime_script (const char *script_name, cp = strptime (buffer, fmt, &tm); if (cp == NULL) { - ERROR ((0, 0, _("output from \"%s %s\" does not satisfy format string: %s"), - script_name, file_name, buffer)); + paxerror (0, _("output from \"%s %s\" does not satisfy format string:" + " %s"), + script_name, file_name, buffer); rc = -1; } else if (*cp != 0) { - WARN ((0, 0, _("unconsumed output from \"%s %s\": %s"), - script_name, file_name, cp)); + paxwarn (0, _("unconsumed output from \"%s %s\": %s"), + script_name, file_name, cp); rc = -1; } else @@ -1073,7 +1069,7 @@ sys_exec_setmtime_script (const char *script_name, t = mktime (&tm); if (tm.tm_wday < 0) { - ERROR ((0, errno, _("mktime failed"))); + paxerror (errno, _("mktime failed")); rc = -1; } else @@ -1085,8 +1081,8 @@ sys_exec_setmtime_script (const char *script_name, } else if (! parse_datetime (ts, buffer, NULL)) { - ERROR ((0, 0, _("unparsable output from \"%s %s\": %s"), - script_name, file_name, buffer)); + paxerror (0, _("unparsable output from \"%s %s\": %s"), + script_name, file_name, buffer); rc = -1; } diff --git a/src/tar.c b/src/tar.c index 72a8bed4..5a5d4b2d 100644 --- a/src/tar.c +++ b/src/tar.c @@ -167,8 +167,8 @@ void request_stdin (const char *option) { if (stdin_used_by) - USAGE_ERROR ((0, 0, _("Options '%s' and '%s' both want standard input"), - stdin_used_by, option)); + paxusage (_("Options '%s' and '%s' both want standard input"), + stdin_used_by, option); stdin_used_by = option; } @@ -242,8 +242,8 @@ set_archive_format (char const *name) for (p = fmttab; strcmp (p->name, name) != 0; ) if (! (++p)->name) - USAGE_ERROR ((0, 0, _("%s: Invalid archive format"), - quotearg_colon (name))); + paxusage (_("%s: Invalid archive format"), + quotearg_colon (name)); archive_format = p->fmt; } @@ -273,8 +273,7 @@ static void assert_format (int fmt_mask) { if ((FORMAT_MASK (archive_format) & fmt_mask) == 0) - USAGE_ERROR ((0, 0, - _("GNU features wanted on incompatible archive format"))); + paxusage (_("GNU features wanted on incompatible archive format")); } const char * @@ -341,8 +340,10 @@ tar_set_quoting_style (char *arg) set_quoting_style (NULL, i); return; } - FATAL_ERROR ((0, 0, - _("Unknown quoting style '%s'. Try '%s --quoting-style=help' to get a list."), arg, program_name)); + paxfatal (0, + _("Unknown quoting style '%s'." + " Try '%s --quoting-style=help' to get a list."), + arg, program_name); } @@ -944,7 +945,7 @@ easprintf (char const *format, ...) va_end (args); if (!result) - FATAL_ERROR ((0, err, "vasprintf")); + paxfatal (err, "vasprintf"); return result; } @@ -972,7 +973,7 @@ option_conflict_error (const char *a, const char *b) { /* TRANSLATORS: Both %s in this statement are replaced with option names. */ - USAGE_ERROR ((0, 0, _("'%s' cannot be used with '%s'"), a, b)); + paxusage (_("'%s' cannot be used with '%s'"), a, b); } /* Classes of options that can conflict: */ @@ -1047,8 +1048,8 @@ set_subcommand_option (enum subcommand subcommand) { if (subcommand_option != UNKNOWN_SUBCOMMAND && subcommand_option != subcommand) - USAGE_ERROR ((0, 0, - _("You may not specify more than one '-Acdtrux', '--delete' or '--test-label' option"))); + paxusage (_("You may not specify more than one '-Acdtrux'," + " '--delete' or '--test-label' option")); subcommand_option = subcommand; } @@ -1060,7 +1061,7 @@ set_use_compress_program_option (const char *string, struct option_locus *loc) if (use_compress_program_option && strcmp (use_compress_program_option, string) != 0 && p->source == OPTS_COMMAND_LINE) - USAGE_ERROR ((0, 0, _("Conflicting compression options"))); + paxusage (_("Conflicting compression options")); use_compress_program_option = string; } @@ -1114,7 +1115,7 @@ decode_signal (const char *name) for (p = sigtab; p < sigtab + sizeof (sigtab) / sizeof (sigtab[0]); p++) if (strcmp (p->name, s) == 0) return p->signo; - FATAL_ERROR ((0, 0, _("Unknown signal name: %s"), name)); + paxfatal (0, _("Unknown signal name: %s"), name); } static void @@ -1144,7 +1145,7 @@ get_date_or_file (struct tar_args *args, const char *option, if (stat (str, &st) != 0) { stat_error (str); - USAGE_ERROR ((0, 0, _("Date sample file not found"))); + paxusage (_("Date sample file not found")); } *ts = get_stat_mtime (&st); } @@ -1152,8 +1153,8 @@ get_date_or_file (struct tar_args *args, const char *option, { if (! parse_datetime (ts, str, NULL)) { - WARN ((0, 0, _("Substituting %s for unknown date format %s"), - tartime (*ts, false), quote (str))); + paxwarn (0, _("Substituting %s for unknown date format %s"), + tartime (*ts, false), quote (str)); ts->tv_nsec = 0; return 1; } @@ -1181,8 +1182,8 @@ report_textual_dates (struct tar_args *args) { char const *treated_as = tartime (p->ts, true); if (strcmp (p->date, treated_as) != 0) - WARN ((0, 0, _("Option %s: Treating date '%s' as %s"), - p->option, p->date, treated_as)); + paxwarn (0, _("Option %s: Treating date '%s' as %s"), + p->option, p->date, treated_as); } free (p->date); free (p); @@ -1346,8 +1347,8 @@ parse_owner_group (char *arg, uintmax_t field_max, char const **name_option) char *end; uintmax_t u = stoint (num, &end, &overflow, 0, field_max); if ((end == num) | *end | overflow) - FATAL_ERROR ((0, 0, "%s: %s", quotearg_colon (num), - _("Invalid owner or group ID"))); + paxfatal (0, "%s: %s", quotearg_colon (num), + _("Invalid owner or group ID")); if (name_option) *name_option = name; return u; @@ -1464,8 +1465,8 @@ parse_opt (int key, char *arg, struct argp_state *state) (min (IDX_MAX, min (SSIZE_MAX, SIZE_MAX)) / BLOCKSIZE)); if ((end == arg) | *end | overflow | !blocking_factor) - USAGE_ERROR ((0, 0, "%s: %s", quotearg_colon (arg), - _("Invalid blocking factor"))); + paxusage ("%s: %s", quotearg_colon (arg), + _("Invalid blocking factor")); record_size = blocking_factor * BLOCKSIZE; } break; @@ -1663,8 +1664,8 @@ parse_opt (int key, char *arg, struct argp_state *state) break; default: - USAGE_ERROR ((0, 0, "%s: %s", quotearg_colon (arg), - _("Invalid tape length"))); + paxusage ("%s: %s", quotearg_colon (arg), + _("Invalid tape length")); } multi_volume_option = true; @@ -1676,7 +1677,7 @@ parse_opt (int key, char *arg, struct argp_state *state) char *end; incremental_level = stoint (arg, &end, NULL, 0, 1); if ((end == arg) | *end) - USAGE_ERROR ((0, 0, _("Invalid incremental level value"))); + paxusage (_("Invalid incremental level value")); } break; @@ -1722,7 +1723,7 @@ parse_opt (int key, char *arg, struct argp_state *state) FALLTHROUGH; case NEWER_MTIME_OPTION: if (TIME_OPTION_INITIALIZED (newer_mtime_option)) - USAGE_ERROR ((0, 0, _("More than one threshold date"))); + paxusage (_("More than one threshold date")); get_date_or_file (args, key == NEWER_MTIME_OPTION ? "--newer-mtime" : "--after-date", arg, &newer_mtime_option); @@ -1798,7 +1799,7 @@ parse_opt (int key, char *arg, struct argp_state *state) if ((p != arg) & (*p == '.')) tar_sparse_minor = stoint (p + 1, &p, &vminor, 0, INTMAX_MAX); if ((p == arg) | *p | vmajor | vminor) - USAGE_ERROR ((0, 0, _("Invalid sparse version value"))); + paxusage (_("Invalid sparse version value")); } break; @@ -1872,9 +1873,8 @@ parse_opt (int key, char *arg, struct argp_state *state) atime_preserve_args, atime_preserve_types) : replace_atime_preserve); if (! O_NOATIME && atime_preserve_option == system_atime_preserve) - FATAL_ERROR ((0, 0, - _("--atime-preserve='system' is not supported" - " on this platform"))); + paxfatal (0, _("--atime-preserve='system' is not supported" + " on this platform")); break; case CHECK_DEVICE_OPTION: @@ -1897,8 +1897,7 @@ parse_opt (int key, char *arg, struct argp_state *state) } checkpoint_option = stoint (arg, &p, NULL, 0, INTMAX_MAX); if (*p | (checkpoint_option <= 0)) - FATAL_ERROR ((0, 0, - _("invalid --checkpoint value"))); + paxfatal (0, _("invalid --checkpoint value")); } else checkpoint_option = DEFAULT_CHECKPOINT; @@ -1976,7 +1975,7 @@ parse_opt (int key, char *arg, struct argp_state *state) case MODE_OPTION: mode_option = mode_compile (arg); if (!mode_option) - FATAL_ERROR ((0, 0, _("Invalid mode given on option"))); + paxfatal (0, _("Invalid mode given on option")); initial_umask = umask (0); umask (initial_umask); break; @@ -2007,8 +2006,7 @@ parse_opt (int key, char *arg, struct argp_state *state) char *end; occurrence_option = stoint (arg, &end, NULL, 0, UINTMAX_MAX); if (*end) - FATAL_ERROR ((0, 0, "%s: %s", quotearg_colon (arg), - _("Invalid number"))); + paxfatal (0, "%s: %s", quotearg_colon (arg), _("Invalid number")); } break; @@ -2072,11 +2070,9 @@ parse_opt (int key, char *arg, struct argp_state *state) if (! (xstrtoumax (arg, NULL, 10, &u, TAR_SIZE_SUFFIXES) == LONGINT_OK && !ckd_add (&record_size, u, 0) && record_size <= min (SSIZE_MAX, SIZE_MAX))) - USAGE_ERROR ((0, 0, "%s: %s", quotearg_colon (arg), - _("Invalid record size"))); + paxusage ("%s: %s", quotearg_colon (arg), _("Invalid record size")); if (record_size % BLOCKSIZE != 0) - USAGE_ERROR ((0, 0, _("Record size must be a multiple of %d."), - BLOCKSIZE)); + paxusage (_("Record size must be a multiple of %d."), BLOCKSIZE); blocking_factor = record_size / BLOCKSIZE; } break; @@ -2120,8 +2116,8 @@ parse_opt (int key, char *arg, struct argp_state *state) char *end; strip_name_components = stoint (arg, &end, NULL, 0, SIZE_MAX); if (*end) - USAGE_ERROR ((0, 0, "%s: %s", quotearg_colon (arg), - _("Invalid number of elements"))); + paxusage ("%s: %s", quotearg_colon (arg), + _("Invalid number of elements")); } break; @@ -2145,7 +2141,7 @@ parse_opt (int key, char *arg, struct argp_state *state) case TO_COMMAND_OPTION: if (to_command_option) - USAGE_ERROR ((0, 0, _("Only one --to-command option allowed"))); + paxusage (_("Only one --to-command option allowed")); to_command_option = arg; break; @@ -2338,8 +2334,7 @@ parse_default_options (struct tar_args *args) ws.ws_offs = 1; if (wordsplit (opts, &ws, WRDSF_DEFFLAGS|WRDSF_DOOFFS)) - FATAL_ERROR ((0, 0, _("cannot split TAR_OPTIONS: %s"), - wordsplit_strerror (&ws))); + paxfatal (0, _("cannot split TAR_OPTIONS: %s"), wordsplit_strerror (&ws)); if (ws.ws_wordc) { int idx; @@ -2348,13 +2343,13 @@ parse_default_options (struct tar_args *args) args->loc = &loc; int argc; if (ckd_add (&argc, ws.ws_offs, ws.ws_wordc)) - FATAL_ERROR ((0, 0, "too many options")); + paxfatal (0, _("too many options")); if (argp_parse (&argp, argc, ws.ws_wordv, ARGP_IN_ORDER | ARGP_NO_EXIT, &idx, args)) abort (); /* shouldn't happen */ args->loc = save_loc_ptr; if (name_more_files ()) - USAGE_ERROR ((0, 0, _("non-option arguments in %s"), loc.name)); + paxusage (_("non-option arguments in %s"), loc.name); /* Don't free consumed words */ ws.ws_wordc = 0; } @@ -2439,11 +2434,9 @@ decode_options (int argc, char **argv) opt = find_argp_option (&argp, *letter); if (opt && opt->arg) { - if (in < argv + argc) - *out++ = *in++; - else - USAGE_ERROR ((0, 0, _("Old option '%c' requires an argument."), - *letter)); + if (! (in < argv + argc)) + paxusage (_("Old option '%c' requires an argument."), *letter); + *out++ = *in++; } } @@ -2513,8 +2506,7 @@ decode_options (int argc, char **argv) if (occurrence_option) { if (!name_more_files ()) - USAGE_ERROR ((0, 0, - _("--occurrence is meaningless without a file list"))); + paxusage (_("--occurrence is meaningless without a file list")); if (!IS_SUBCOMMAND_CLASS (SUBCL_OCCUR)) { if (option_set_in_cl (OC_OCCURRENCE)) @@ -2539,8 +2531,7 @@ decode_options (int argc, char **argv) /* Allow multiple archives only with '-M'. */ if (archive_names > 1 && !multi_volume_option) - USAGE_ERROR ((0, 0, - _("Multiple archive files require '-M' option"))); + paxusage (_("Multiple archive files require '-M' option")); if (listed_incremental_option && TIME_OPTION_INITIALIZED (newer_mtime_option)) @@ -2556,8 +2547,7 @@ decode_options (int argc, char **argv) } if (0 <= incremental_level && !listed_incremental_option) - WARN ((0, 0, - _("--level is meaningless without --listed-incremental"))); + paxwarn (0, _("--level is meaningless without --listed-incremental")); if (volume_label_option) { @@ -2573,10 +2563,9 @@ decode_options (int argc, char **argv) - 1 /* for sign, as 0 <= volno */) : 0)); if (volume_label_max_len < strlen (volume_label_option)) - USAGE_ERROR ((0, 0, - _("%s: Volume label length exceeds %d bytes"), - quotearg_colon (volume_label_option), - volume_label_max_len)); + paxusage (_("%s: Volume label length exceeds %d bytes"), + quotearg_colon (volume_label_option), + volume_label_max_len); } /* else FIXME Label length in PAX format is limited by the volume size. */ @@ -2585,9 +2574,9 @@ decode_options (int argc, char **argv) if (verify_option) { if (multi_volume_option) - USAGE_ERROR ((0, 0, _("Cannot verify multi-volume archives"))); + paxusage (_("Cannot verify multi-volume archives")); if (use_compress_program_option) - USAGE_ERROR ((0, 0, _("Cannot verify compressed archives"))); + paxusage (_("Cannot verify compressed archives")); if (!IS_SUBCOMMAND_CLASS (SUBCL_WRITE)) { if (option_set_in_cl (OC_VERIFY)) @@ -2601,27 +2590,23 @@ decode_options (int argc, char **argv) if (use_compress_program_option) { if (multi_volume_option) - USAGE_ERROR ((0, 0, _("Cannot use multi-volume compressed archives"))); + paxusage (_("Cannot use multi-volume compressed archives")); if (IS_SUBCOMMAND_CLASS (SUBCL_UPDATE)) - USAGE_ERROR ((0, 0, _("Cannot update compressed archives"))); + paxusage (_("Cannot update compressed archives")); if (subcommand_option == CAT_SUBCOMMAND) - USAGE_ERROR ((0, 0, _("Cannot concatenate compressed archives"))); + paxusage (_("Cannot concatenate compressed archives")); } if (set_mtime_command) { if (set_mtime_option != USE_FILE_MTIME) - { - USAGE_ERROR ((0, 0, - _("--mtime conflicts with --set-mtime-command"))); - } + paxusage (_("--mtime conflicts with --set-mtime-command")); set_mtime_option = COMMAND_MTIME; } else if (set_mtime_option == CLAMP_MTIME) { if (!TIME_OPTION_INITIALIZED (mtime_option)) - USAGE_ERROR ((0, 0, - _("--clamp-mtime needs a date specified using --mtime"))); + paxusage (_("--clamp-mtime needs a date specified using --mtime")); } /* It is no harm to use --pax-option on non-pax archives in archive @@ -2631,24 +2616,24 @@ decode_options (int argc, char **argv) if (args.pax_option && archive_format != POSIX_FORMAT && !IS_SUBCOMMAND_CLASS (SUBCL_READ)) - USAGE_ERROR ((0, 0, _("--pax-option can be used only on POSIX archives"))); + paxusage (_("--pax-option can be used only on POSIX archives")); /* star creates non-POSIX typed archives with xattr support, so allow the extra headers when reading */ if ((acls_option > 0) && archive_format != POSIX_FORMAT && !IS_SUBCOMMAND_CLASS (SUBCL_READ)) - USAGE_ERROR ((0, 0, _("--acls can be used only on POSIX archives"))); + paxusage (_("--acls can be used only on POSIX archives")); if ((selinux_context_option > 0) && archive_format != POSIX_FORMAT && !IS_SUBCOMMAND_CLASS (SUBCL_READ)) - USAGE_ERROR ((0, 0, _("--selinux can be used only on POSIX archives"))); + paxusage (_("--selinux can be used only on POSIX archives")); if ((xattrs_option > 0) && archive_format != POSIX_FORMAT && !IS_SUBCOMMAND_CLASS (SUBCL_READ)) - USAGE_ERROR ((0, 0, _("--xattrs can be used only on POSIX archives"))); + paxusage (_("--xattrs can be used only on POSIX archives")); if (starting_file_option && !IS_SUBCOMMAND_CLASS (SUBCL_READ)) { @@ -2696,9 +2681,8 @@ decode_options (int argc, char **argv) free (base); if (!one_top_level_dir) - USAGE_ERROR ((0, 0, - _("Cannot deduce top-level directory name; " - "please set it explicitly with --one-top-level=DIR"))); + paxusage (_("Cannot deduce top-level directory name; " + "please set it explicitly with --one-top-level=DIR")); } } @@ -2730,7 +2714,7 @@ decode_options (int argc, char **argv) verbose_option = 2; if (tape_length_option && tape_length_option < record_size) - USAGE_ERROR ((0, 0, _("Volume length cannot be less than record size"))); + paxusage (_("Volume length cannot be less than record size")); if (same_order_option && listed_incremental_option) { @@ -2753,8 +2737,7 @@ decode_options (int argc, char **argv) { case CREATE_SUBCOMMAND: if (!name_more_files ()) - USAGE_ERROR ((0, 0, - _("Cowardly refusing to create an empty archive"))); + paxusage (_("Cowardly refusing to create an empty archive")); if (args.compress_autodetect && archive_names && strcmp (archive_name_array[0], "-")) set_compression_program_by_suffix (archive_name_array[0], @@ -2780,8 +2763,7 @@ decode_options (int argc, char **argv) archive_name_cursor < archive_name_array + archive_names; archive_name_cursor++) if (!strcmp (*archive_name_cursor, "-")) - USAGE_ERROR ((0, 0, - _("Options '-Aru' are incompatible with '-f -'"))); + paxusage (_("Options '-Aru' are incompatible with '-f -'")); default: break; @@ -2864,8 +2846,8 @@ main (int argc, char **argv) close_stdout_set_file_name (_("stdout")); /* Make sure we have first three descriptors available */ if (stdopen ()) - FATAL_ERROR ((0, 0, "%s", - _("failed to assert availability of the standard file descriptors"))); + paxfatal (0, _("failed to assert availability" + " of the standard file descriptors")); /* Pre-allocate a few structures. */ @@ -2894,8 +2876,8 @@ main (int argc, char **argv) switch (subcommand_option) { case UNKNOWN_SUBCOMMAND: - USAGE_ERROR ((0, 0, - _("You must specify one of the '-Acdtrux', '--delete' or '--test-label' options"))); + paxusage (_("You must specify one of the '-Acdtrux'," + " '--delete' or '--test-label' options")); case CAT_SUBCOMMAND: case UPDATE_SUBCOMMAND: diff --git a/src/transform.c b/src/transform.c index 3926301b..b0023915 100644 --- a/src/transform.c +++ b/src/transform.c @@ -200,17 +200,16 @@ parse_transform_expr (const char *expr) break; } if (parse_xform_flags (&transform_flags, *expr)) - USAGE_ERROR ((0, 0, _("Unknown transform flag: %c"), - *expr)); + paxusage (_("Unknown transform flag: %c"), *expr); } return expr; } - USAGE_ERROR ((0, 0, _("Invalid transform expression"))); + paxusage (_("Invalid transform expression")); } delim = expr[1]; if (!delim) - USAGE_ERROR ((0, 0, _("Invalid transform expression"))); + paxusage (_("Invalid transform expression")); /* Scan regular expression */ for (i = 2; expr[i] && expr[i] != delim; i++) @@ -218,7 +217,7 @@ parse_transform_expr (const char *expr) i++; if (expr[i] != delim) - USAGE_ERROR ((0, 0, _("Invalid transform expression"))); + paxusage (_("Invalid transform expression")); /* Scan replacement expression */ for (j = i + 1; expr[j] && expr[j] != delim; j++) @@ -226,7 +225,7 @@ parse_transform_expr (const char *expr) j++; if (expr[j] != delim) - USAGE_ERROR ((0, 0, _("Invalid transform expression"))); + paxusage (_("Invalid transform expression")); /* Check flags */ tf->transform_type = transform_first; @@ -257,8 +256,7 @@ parse_transform_expr (const char *expr) default: if (parse_xform_flags (&tf->flags, *p)) - USAGE_ERROR ((0, 0, _("Unknown flag in transform expression: %c"), - *p)); + paxusage (_("Unknown flag in transform expression: %c"), *p); } if (*p == ';') @@ -275,7 +273,7 @@ parse_transform_expr (const char *expr) { char errbuf[512]; regerror (rc, &tf->regex, errbuf, sizeof (errbuf)); - USAGE_ERROR ((0, 0, _("Invalid transform expression: %s"), errbuf)); + paxusage (_("Invalid transform expression: %s"), errbuf); } if (str[0] == '^' || (i > 2 && str[i - 3] == '$')) @@ -301,8 +299,8 @@ parse_transform_expr (const char *expr) { idx_t n = stoint (cur, &cur, NULL, 0, IDX_MAX); if (tf->regex.re_nsub < n) - USAGE_ERROR ((0, 0, _("Invalid transform replacement:" - " back reference out of range"))); + paxusage (_("Invalid transform replacement:" + " back reference out of range")); add_backref_segment (tf, n); } break; diff --git a/src/update.c b/src/update.c index 98c5014d..3ce95901 100644 --- a/src/update.c +++ b/src/update.c @@ -186,11 +186,11 @@ update_archive (void) switch (previous_status) { case HEADER_STILL_UNREAD: - WARN ((0, 0, _("This does not look like a tar archive"))); + paxwarn (0, _("This does not look like a tar archive")); FALLTHROUGH; case HEADER_SUCCESS: case HEADER_ZERO_BLOCK: - ERROR ((0, 0, _("Skipping to next header"))); + paxerror (0, _("Skipping to next header")); FALLTHROUGH; case HEADER_FAILURE: break; diff --git a/src/warning.c b/src/warning.c index 7d21eb02..a7559f23 100644 --- a/src/warning.c +++ b/src/warning.c @@ -111,3 +111,17 @@ set_warning_option (const char *arg) else warning_option |= option; } + +void +warnopt (int opt, int errnum, char const *format, ...) +{ + if (WARNING_ENABLED (opt)) + { + if (error_hook) + error_hook (); + va_list ap; + va_start (ap, format); + verror (0, errnum, format, ap); + va_end (ap); + } +} diff --git a/src/xattrs.c b/src/xattrs.c index dc22269a..f8f6c295 100644 --- a/src/xattrs.c +++ b/src/xattrs.c @@ -300,11 +300,10 @@ xattrs__acls_set (struct tar_stat_info const *st, FILE_NAME may already have inherited default acls from parent directory; clean them up. */ if (acl_delete_def_file_at (chdir_fd, file_name)) - WARNOPT (WARN_XATTR_WRITE, - (0, errno, + warnopt (WARN_XATTR_WRITE, errno, _("acl_delete_def_file_at: Cannot drop default POSIX ACLs " "for file '%s'"), - file_name)); + file_name); return; } else @@ -318,10 +317,9 @@ xattrs__acls_set (struct tar_stat_info const *st, if (acl_set_file_at (chdir_fd, file_name, type, acl) < 0) /* warn even if filesystem does not support acls */ - WARNOPT (WARN_XATTR_WRITE, - (0, errno, - _ ("acl_set_file_at: Cannot set POSIX ACLs for file '%s'"), - file_name)); + warnopt (WARN_XATTR_WRITE, errno, + _ ("acl_set_file_at: Cannot set POSIX ACLs for file '%s'"), + file_name); acl_free (acl); } @@ -373,7 +371,8 @@ acls_get_text (int parentfd, const char *file_name, acl_type_t type, static int warned; if (!warned) { - WARN ((0, 0, _("--numeric-owner is ignored for ACLs: libacl is not available"))); + paxwarn (0, _("--numeric-owner is ignored for ACLs:" + " libacl is not available")); warned = 1; } #endif @@ -456,7 +455,7 @@ xattrs_acls_get (MAYBE_UNUSED int parentfd, MAYBE_UNUSED char const *file_name, #ifndef HAVE_POSIX_ACLS static int done = 0; if (!done) - WARN ((0, 0, _("POSIX ACL support is not available"))); + paxwarn (0, _("POSIX ACL support is not available")); done = 1; #else int err = file_has_acl_at (parentfd, file_name, &st->stat); @@ -486,7 +485,7 @@ xattrs_acls_set (MAYBE_UNUSED struct tar_stat_info const *st, #ifndef HAVE_POSIX_ACLS static int done = 0; if (!done) - WARN ((0, 0, _("POSIX ACL support is not available"))); + paxwarn (0, _("POSIX ACL support is not available")); done = 1; #else xattrs__acls_set (st, file_name, ACL_TYPE_ACCESS, @@ -550,7 +549,7 @@ xattrs_xattrs_get (int parentfd, char const *file_name, #ifndef HAVE_XATTRS static int done = 0; if (!done) - WARN ((0, 0, _("XATTR support is not available"))); + paxwarn (0, _("XATTR support is not available")); done = 1; #else static size_t xsz = 1024; @@ -631,10 +630,9 @@ xattrs__fd_set (char const *file_name, char typeflag, } if (ret < 0) - WARNOPT (WARN_XATTR_WRITE, - (0, errno, - _("%s: Cannot set '%s' extended attribute for file '%s'"), - sysname, attr, file_name)); + warnopt (WARN_XATTR_WRITE, errno, + _("%s: Cannot set '%s' extended attribute for file '%s'"), + sysname, attr, file_name); } } #endif @@ -650,7 +648,7 @@ xattrs_selinux_get (MAYBE_UNUSED int parentfd, MAYBE_UNUSED char const *file_nam #if HAVE_SELINUX_SELINUX_H != 1 static int done = 0; if (!done) - WARN ((0, 0, _("SELinux support is not available"))); + paxwarn (0, _("SELinux support is not available")); done = 1; #else int result = (fd @@ -672,7 +670,7 @@ xattrs_selinux_set (MAYBE_UNUSED struct tar_stat_info const *st, #if HAVE_SELINUX_SELINUX_H != 1 static int done = 0; if (!done) - WARN ((0, 0, _("SELinux support is not available"))); + paxwarn (0, _("SELinux support is not available")); done = 1; #else const char *sysname = "setfilecon"; @@ -693,10 +691,9 @@ xattrs_selinux_set (MAYBE_UNUSED struct tar_stat_info const *st, } if (ret < 0) - WARNOPT (WARN_XATTR_WRITE, - (0, errno, - _("%s: Cannot set SELinux context for file '%s'"), - sysname, file_name)); + warnopt (WARN_XATTR_WRITE, errno, + _("%s: Cannot set SELinux context for file '%s'"), + sysname, file_name); #endif } } @@ -754,7 +751,7 @@ xattrs_xattrs_set (struct tar_stat_info const *st, #ifndef HAVE_XATTRS static int done = 0; if (!done) - WARN ((0, 0, _("XATTR support is not available"))); + paxwarn (0, _("XATTR support is not available")); done = 1; #else size_t i; diff --git a/src/xheader.c b/src/xheader.c index 0fe1ce14..7f2c53dd 100644 --- a/src/xheader.c +++ b/src/xheader.c @@ -161,7 +161,7 @@ xheader_list_destroy (struct keyword_list **root) static _Noreturn void xheader_set_single_keyword (char *kw) { - USAGE_ERROR ((0, 0, _("Keyword %s is unknown or not yet implemented"), kw)); + paxusage (_("Keyword %s is unknown or not yet implemented"), kw); } static void @@ -170,7 +170,7 @@ assign_time_option (char **sval, time_t *tval, const char *input) char *p; struct timespec t = decode_timespec (input, &p, false); if (! valid_timespec (t) || *p) - ERROR ((0, 0, _("Time stamp is out of allowed range"))); + paxerror (0, _("Time stamp is out of allowed range")); else { *tval = t.tv_sec; @@ -185,7 +185,7 @@ xheader_set_keyword_equal (char *kw, char *eq) char *p = eq; if (eq == kw) - USAGE_ERROR ((0, 0, _("Malformed pax option: %s"), quote (kw))); + paxusage (_("Malformed pax option: %s"), quote (kw)); if (eq[-1] == ':') { @@ -204,7 +204,7 @@ xheader_set_keyword_equal (char *kw, char *eq) if (strcmp (kw, "delete") == 0) { if (xheader_protected_pattern_p (p)) - USAGE_ERROR ((0, 0, _("Pattern %s cannot be used"), quote (p))); + paxusage (_("Pattern %s cannot be used"), quote (p)); xheader_list_append (&keyword_pattern_list, p, NULL); } else if (strcmp (kw, "exthdr.name") == 0) @@ -218,7 +218,7 @@ xheader_set_keyword_equal (char *kw, char *eq) else { if (xheader_protected_keyword_p (kw)) - USAGE_ERROR ((0, 0, _("Keyword %s cannot be overridden"), kw)); + paxusage (_("Keyword %s cannot be overridden"), kw); if (global) xheader_list_append (&keyword_global_override_list, kw, p); else @@ -490,7 +490,7 @@ void xheader_forbid_global (void) { if (keyword_global_override_list) - USAGE_ERROR ((0, 0, _("can't update global extended header record"))); + paxusage (_("can't update global extended header record")); } /* This is reversal function for xattr_encode_keyword. See comment for @@ -623,7 +623,7 @@ decode_record (struct xheader *xhdr, /* The length is missing. FIXME: Comment why this is diagnosed only if (*p), or change code. */ if (*p) - ERROR ((0, 0, _("Malformed extended header: missing length"))); + paxerror (0, _("Malformed extended header: missing length")); return false; } @@ -632,8 +632,8 @@ decode_record (struct xheader *xhdr, /* Avoid giant diagnostics, as this won't help user. */ int len_len = min (len_lim - p, 1000); - ERROR ((0, 0, _("Extended header length %.*s is out of range"), - len_len, p)); + paxerror (0, _("Extended header length %.*s is out of range"), + len_len, p); return false; } @@ -643,8 +643,7 @@ decode_record (struct xheader *xhdr, continue; if (p == len_lim) { - ERROR ((0, 0, - _("Malformed extended header: missing blank after length"))); + paxerror (0, _("Malformed extended header: missing blank after length")); return false; } @@ -652,13 +651,13 @@ decode_record (struct xheader *xhdr, p = strchr (p, '='); if (! (p && p < nextp)) { - ERROR ((0, 0, _("Malformed extended header: missing equal sign"))); + paxerror (0, _("Malformed extended header: missing equal sign")); return false; } if (nextp[-1] != '\n') { - ERROR ((0, 0, _("Malformed extended header: missing newline"))); + paxerror (0, _("Malformed extended header: missing newline")); return false; } @@ -695,9 +694,9 @@ decx (void *data, char const *keyword, char const *value, size_t size) if (t) t->decoder (st, keyword, value, size); else - WARNOPT (WARN_UNKNOWN_KEYWORD, - (0, 0, _("Ignoring unknown extended header keyword %s"), - quotearg_style (shell_escape_always_quoting_style, keyword))); + warnopt (WARN_UNKNOWN_KEYWORD, 0, + _("Ignoring unknown extended header keyword %s"), + quotearg_style (shell_escape_always_quoting_style, keyword)); } void @@ -803,7 +802,7 @@ xheader_read (struct xheader *xhdr, union block *p, off_t size) len = BLOCKSIZE; if (!p) - FATAL_ERROR ((0, 0, _("Unexpected EOF in archive"))); + paxfatal (0, _("Unexpected EOF in archive")); memcpy (&xhdr->buffer[j], p->buffer, len); set_next_block_after (p); @@ -978,9 +977,10 @@ xheader_string_end (struct xheader *xhdr, char const *keyword) size = p; if (size != p) { - ERROR ((0, 0, - _("Generated keyword/value pair is too long (keyword=%s, length=%s)"), - keyword, nbuf)); + paxerror (0, + _("Generated keyword/value pair is too long" + " (keyword=%s, length=%s)"), + keyword, nbuf); obstack_free (xhdr->stk, obstack_finish (xhdr->stk)); return false; } @@ -1004,8 +1004,8 @@ out_of_range_header (char const *keyword, char const *value, { /* TRANSLATORS: The first %s is the pax extended header keyword (atime, gid, etc.). */ - ERROR ((0, 0, _("Extended header %s=%s is out of range %jd..%ju"), - keyword, value, minval, maxval)); + paxerror (0, _("Extended header %s=%s is out of range %jd..%ju"), + keyword, value, minval, maxval); } static void @@ -1055,14 +1055,14 @@ decode_time (struct timespec *ts, char const *arg, char const *keyword) out_of_range_header (keyword, arg, TYPE_MINIMUM (time_t), TYPE_MAXIMUM (time_t)); else - ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"), - keyword, arg)); + paxerror (0, _("Malformed extended header: invalid %s=%s"), + keyword, arg); return false; } if (*arg_lim) { - ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"), - keyword, arg)); + paxerror (0, _("Malformed extended header: invalid %s=%s"), + keyword, arg); return false; } @@ -1095,8 +1095,8 @@ decode_signed_num (intmax_t *num, char const *arg, if ((arg_lim == arg) | *arg_lim) { - ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"), - keyword, arg)); + paxerror (0, _("Malformed extended header: invalid %s=%s"), + keyword, arg); return false; } @@ -1401,8 +1401,8 @@ sparse_offset_decoder (struct tar_stat_info *st, if (st->sparse_map_avail < st->sparse_map_size) st->sparse_map[st->sparse_map_avail].offset = u; else - ERROR ((0, 0, _("Malformed extended header: excess %s=%s"), - "GNU.sparse.offset", arg)); + paxerror (0, _("Malformed extended header: excess %s=%s"), + "GNU.sparse.offset", arg); } } @@ -1426,8 +1426,8 @@ sparse_numbytes_decoder (struct tar_stat_info *st, if (st->sparse_map_avail < st->sparse_map_size) st->sparse_map[st->sparse_map_avail++].numbytes = u; else - ERROR ((0, 0, _("Malformed extended header: excess %s=%s"), - keyword, arg)); + paxerror (0, _("Malformed extended header: excess %s=%s"), + keyword, arg); } } @@ -1448,8 +1448,8 @@ sparse_map_decoder (struct tar_stat_info *st, off_t u = stoint (arg, &delim, &overflow, 0, TYPE_MAXIMUM (off_t)); if (delim == arg) { - ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"), - keyword, arg)); + paxerror (0, _("Malformed extended header: invalid %s=%s"), + keyword, arg); return; } @@ -1474,8 +1474,8 @@ sparse_map_decoder (struct tar_stat_info *st, st->sparse_map[st->sparse_map_avail++] = e; else { - ERROR ((0, 0, _("Malformed extended header: excess %s=%s"), - keyword, arg)); + paxerror (0, _("Malformed extended header: excess %s=%s"), + keyword, arg); return; } } @@ -1486,9 +1486,10 @@ sparse_map_decoder (struct tar_stat_info *st, break; else if (*delim != ',') { - ERROR ((0, 0, - _("Malformed extended header: invalid %s: unexpected delimiter %c"), - keyword, *delim)); + paxerror (0, + _("Malformed extended header: invalid %s:" + " unexpected delimiter %c"), + keyword, *delim); return; } @@ -1496,9 +1497,10 @@ sparse_map_decoder (struct tar_stat_info *st, } if (!offset) - ERROR ((0, 0, - _("Malformed extended header: invalid %s: odd number of values"), - keyword)); + paxerror (0, + _("Malformed extended header: invalid %s:" + " odd number of values"), + keyword); } static void