maint: pacify -Wzero-as-null-pointer-constant

Recent Gnulib enables this warning, and it did find a bug
in GNU Tar, so pacify GCC everywhere else by preferring
NULL to 0 for pointers.
This commit is contained in:
Paul Eggert 2026-01-23 17:25:45 -08:00
parent 29bb75ed65
commit 8fca6143ea
12 changed files with 157 additions and 156 deletions

View File

@ -318,8 +318,8 @@ struct zip_program
};
static struct zip_magic const magic[] = {
{ ct_none, 0, 0 },
{ ct_tar, 0, 0 },
{ ct_none, 0, NULL },
{ ct_tar, 0, NULL },
{ ct_compress, 2, "\037\235" },
{ ct_gzip, 2, "\037\213" },
{ ct_bzip2, 3, "BZh" },
@ -413,7 +413,7 @@ check_compressed_archive (bool *pshort)
sfr = read_full_records;
read_full_records = true; /* Suppress fatal error on reading a partial
record */
*pshort = find_next_block () == 0;
*pshort = !find_next_block ();
/* Restore global values */
read_full_records = sfr;
@ -615,12 +615,12 @@ find_next_block (void)
if (current_block == record_end)
{
if (hit_eof)
return 0;
return NULL;
flush_archive ();
if (current_block == record_end)
{
hit_eof = true;
return 0;
return NULL;
}
}
return current_block;

View File

@ -311,7 +311,7 @@ format_checkpoint_string (FILE *fp, intmax_t len,
#if HAVE_STRUCT_TM_TM_GMTOFF && HAVE_STRUCT_TM_TM_ZONE
/* struct tm has POSIX.1-2024 tm_gmtoff and tm_zone,
so nstrftime ignores tz and any tz value will do. */
timezone_t tz = 0;
timezone_t tz = NULL;
#else
static timezone_t tz;
if (tm && !tz)

View File

@ -245,7 +245,7 @@ to_chars_subst (bool negative, bool gnu_format, uintmax_t value, int valsize,
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);
return to_chars (negsub, s, valsize, NULL, where, size, type);
}
else
paxerror (0, _("value %s%ju out of %s range %jd..%ju"),
@ -349,13 +349,13 @@ gid_to_chars (gid_t v, char *p, int s)
static bool
major_to_chars (major_t v, char *p, int s)
{
return to_chars (v < 0, v, sizeof v, 0, p, s, "major_t");
return to_chars (v < 0, v, sizeof v, NULL, p, s, "major_t");
}
static bool
minor_to_chars (minor_t v, char *p, int s)
{
return to_chars (v < 0, v, sizeof v, 0, p, s, "minor_t");
return to_chars (v < 0, v, sizeof v, NULL, p, s, "minor_t");
}
static bool
@ -395,19 +395,19 @@ mode_to_chars (mode_t v, char *p, int s)
| (v & S_IWOTH ? TOWRITE : 0)
| (v & S_IXOTH ? TOEXEC : 0));
}
return to_chars (negative, u, sizeof v, 0, p, s, "mode_t");
return to_chars (negative, u, sizeof v, NULL, p, s, "mode_t");
}
bool
off_to_chars (off_t v, char *p, int s)
{
return to_chars (v < 0, v, sizeof v, 0, p, s, "off_t");
return to_chars (v < 0, v, sizeof v, NULL, p, s, "off_t");
}
bool
time_to_chars (time_t v, char *p, int s)
{
return to_chars (v < 0, v, sizeof v, 0, p, s, "time_t");
return to_chars (v < 0, v, sizeof v, NULL, p, s, "time_t");
}
static uintmax_t
@ -1264,7 +1264,7 @@ get_directory_entries (struct tar_stat_info *st)
{
while (! (st->dirstream = fdopendir (st->fd)))
if (! open_failure_recover (st))
return 0;
return NULL;
return streamsavedir (st->dirstream, savedir_sort_order);
}
@ -1317,7 +1317,7 @@ create_archive (void)
while ((p = name_from_list ()) != NULL)
if (!excluded_name (p->name, NULL))
dump_file (0, p->name, p->name);
dump_file (NULL, p->name, p->name);
blank_name_list ();
while ((p = name_from_list ()) != NULL)
@ -1377,7 +1377,7 @@ create_archive (void)
const char *name;
while ((name = name_next (true)))
if (!excluded_name (name, NULL))
dump_file (0, name, name);
dump_file (NULL, name, name);
}
write_eot ();
@ -1498,8 +1498,8 @@ file_count_links (struct tar_stat_info *st)
free (linkname);
if (! ((link_table
|| (link_table = hash_initialize (0, 0, hash_link,
compare_links, 0)))
|| (link_table = hash_initialize (0, NULL, hash_link,
compare_links, NULL)))
&& (duplicate = hash_insert (link_table, lp))))
xalloc_die ();
@ -1620,7 +1620,7 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p)
bool is_dir;
struct tar_stat_info const *parent = st->parent;
bool top_level = ! parent;
void (*diag) (char const *) = 0;
void (*diag) (char const *) = NULL;
if (interactive_option && !confirm ("add", p))
return NULL;

View File

@ -565,7 +565,7 @@ delay_set_stat (char const *file_name, struct tar_stat_info const *st,
struct delayed_set_stat *data;
if (! (delayed_set_stat_table
|| (delayed_set_stat_table = hash_initialize (0, 0, ds_hash,
|| (delayed_set_stat_table = hash_initialize (0, NULL, ds_hash,
ds_compare, NULL))))
xalloc_die ();
@ -816,7 +816,7 @@ make_directories (char *file_name, bool *interdir_made)
mode == desired_mode, because
repair_delayed_set_stat may need to update the struct. */
delay_set_stat (file_name,
0, mode & ~ current_umask, MODE_RWX,
NULL, mode & ~ current_umask, MODE_RWX,
desired_mode, AT_SYMLINK_NOFOLLOW);
if (interdir_made)
*interdir_made = true;
@ -915,7 +915,7 @@ maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
{
int e = errno;
struct stat st;
struct stat const *stp = 0;
struct stat const *stp = NULL;
if (*interdir_made)
return RECOVER_NO;
@ -1539,7 +1539,7 @@ create_placeholder_file (char *file_name, bool is_symlink, bool *interdir_made)
p->change_dir = chdir_current;
p->sources = xmalloc (FLEXNSIZEOF (struct string_list, string,
strlen (file_name) + 1));
p->sources->next = 0;
p->sources->next = NULL;
strcpy (p->sources->string, file_name);
p->cntx_name = NULL;
assign_string_or_null (&p->cntx_name, current_stat_info.cntx_name);
@ -1554,7 +1554,7 @@ create_placeholder_file (char *file_name, bool is_symlink, bool *interdir_made)
*delayed_link_tail = p;
delayed_link_tail = &p->next;
if (! ((delayed_link_table
|| (delayed_link_table = hash_initialize (0, 0, dl_hash,
|| (delayed_link_table = hash_initialize (0, NULL, dl_hash,
dl_compare, free)))
&& hash_insert (delayed_link_table, p)))
xalloc_die ();
@ -1856,7 +1856,7 @@ prepare_to_extract (char const *file_name, char typeflag)
break;
case KEEP_NEWER_FILES:
if (file_newer_p (file_name, 0, &current_stat_info))
if (file_newer_p (file_name, NULL, &current_stat_info))
{
warnopt (WARN_IGNORE_NEWER, 0, _("Current %s is newer or same age"),
quote (file_name));

View File

@ -388,18 +388,18 @@ note_directory (char const *name, struct timespec mtime,
directory->dump = NULL;
if (! ((directory_table
|| (directory_table = hash_initialize (0, 0,
|| (directory_table = hash_initialize (0, NULL,
hash_directory_canonical_name,
compare_directory_canonical_names,
0)))
NULL)))
&& hash_insert (directory_table, directory)))
xalloc_die ();
if (! ((directory_meta_table
|| (directory_meta_table = hash_initialize (0, 0,
|| (directory_meta_table = hash_initialize (0, NULL,
hash_directory_meta,
compare_directory_meta,
0)))
NULL)))
&& hash_insert (directory_meta_table, directory)))
xalloc_die ();
@ -411,7 +411,7 @@ static struct directory *
find_directory (const char *name)
{
if (! directory_table)
return 0;
return NULL;
else
{
char *caname = normalize_filename (chdir_current, name);
@ -452,7 +452,7 @@ static struct directory *
find_directory_meta (dev_t dev, ino_t ino)
{
if (! directory_meta_table)
return 0;
return NULL;
else
{
struct directory *dir = make_directory ("", NULL);
@ -820,7 +820,7 @@ scan_directory (struct tar_stat_info *st)
else
{
int fd = st->fd;
void (*diag) (char const *) = 0;
void (*diag) (char const *) = NULL;
struct tar_stat_info stsub;
tar_stat_init (&stsub);

View File

@ -364,7 +364,7 @@ tar_checksum (union block *header, bool silent)
signed_sum += ' ' * sizeof header->header.chksum;
int recorded_sum = from_header (header->header.chksum,
sizeof header->header.chksum, 0,
sizeof header->header.chksum, NULL,
0, INT_MAX, true, silent);
if (recorded_sum < 0)
return HEADER_FAILURE;
@ -552,7 +552,7 @@ read_header (union block **return_block, struct tar_stat_info *info,
memcpy (np, h->name, sizeof h->name);
np[sizeof h->name] = '\0';
name = namebuf;
recent_long_name = 0;
recent_long_name = NULL;
recent_long_name_blocks = 0;
}
assign_string (&info->orig_file_name, name);
@ -573,7 +573,7 @@ read_header (union block **return_block, struct tar_stat_info *info,
memcpy (namebuf, h->linkname, sizeof h->linkname);
namebuf[sizeof h->linkname] = '\0';
name = namebuf;
recent_long_link = 0;
recent_long_link = NULL;
recent_long_link_blocks = 0;
}
assign_string (&info->link_name, name);
@ -912,7 +912,7 @@ from_header (char const *where0, int digs, char const *type,
if (!o)
{
o = clone_quoting_options (0);
o = clone_quoting_options (NULL);
set_quoting_style (o, locale_quoting_style);
}

View File

@ -169,7 +169,8 @@ map_read (Hash_table **ptab, char const *file,
ent->new_name = name ? xstrdup (name) : NULL;
if (!((*ptab
|| (*ptab = hash_initialize (0, 0, map_hash, map_compare, 0)))
|| (*ptab = hash_initialize (0, NULL, map_hash, map_compare,
NULL)))
&& hash_insert (*ptab, ent)))
xalloc_die ();
}

View File

@ -82,31 +82,31 @@ static struct argp_option names_options[] = {
N_("change to directory DIR"), GRID_LOCAL },
{"files-from", 'T', N_("FILE"), 0,
N_("get names to extract or create from FILE"), GRID_LOCAL },
{"null", NULL_OPTION, 0, 0,
{"null", NULL_OPTION, NULL, 0,
N_("-T reads null-terminated names; implies --verbatim-files-from"),
GRID_LOCAL },
{"no-null", NO_NULL_OPTION, 0, 0,
{"no-null", NO_NULL_OPTION, NULL, 0,
N_("disable the effect of the previous --null option"), GRID_LOCAL },
{"unquote", UNQUOTE_OPTION, 0, 0,
{"unquote", UNQUOTE_OPTION, NULL, 0,
N_("unquote input file or member names (default)"), GRID_LOCAL },
{"no-unquote", NO_UNQUOTE_OPTION, 0, 0,
{"no-unquote", NO_UNQUOTE_OPTION, NULL, 0,
N_("do not unquote input file or member names"), GRID_LOCAL },
{"verbatim-files-from", VERBATIM_FILES_FROM_OPTION, 0, 0,
{"verbatim-files-from", VERBATIM_FILES_FROM_OPTION, NULL, 0,
N_("-T reads file names verbatim (no escape or option handling)"), GRID_LOCAL },
{"no-verbatim-files-from", NO_VERBATIM_FILES_FROM_OPTION, 0, 0,
{"no-verbatim-files-from", NO_VERBATIM_FILES_FROM_OPTION, NULL, 0,
N_("-T treats file names starting with dash as options (default)"),
GRID_LOCAL },
{"exclude", EXCLUDE_OPTION, N_("PATTERN"), 0,
N_("exclude files, given as a PATTERN"), GRID_LOCAL },
{"exclude-from", 'X', N_("FILE"), 0,
N_("exclude patterns listed in FILE"), GRID_LOCAL },
{"exclude-caches", EXCLUDE_CACHES_OPTION, 0, 0,
{"exclude-caches", EXCLUDE_CACHES_OPTION, NULL, 0,
N_("exclude contents of directories containing CACHEDIR.TAG, "
"except for the tag file itself"), GRID_LOCAL },
{"exclude-caches-under", EXCLUDE_CACHES_UNDER_OPTION, 0, 0,
{"exclude-caches-under", EXCLUDE_CACHES_UNDER_OPTION, NULL, 0,
N_("exclude everything under directories containing CACHEDIR.TAG"),
GRID_LOCAL },
{"exclude-caches-all", EXCLUDE_CACHES_ALL_OPTION, 0, 0,
{"exclude-caches-all", EXCLUDE_CACHES_ALL_OPTION, NULL, 0,
N_("exclude directories containing CACHEDIR.TAG"), GRID_LOCAL },
{"exclude-tag", EXCLUDE_TAG_OPTION, N_("FILE"), 0,
N_("exclude contents of directories containing FILE, except"
@ -127,29 +127,29 @@ static struct argp_option names_options[] = {
N_("read exclude patterns from the VCS ignore files"), GRID_LOCAL },
{"exclude-backups", EXCLUDE_BACKUPS_OPTION, NULL, 0,
N_("exclude backup and lock files"), GRID_LOCAL },
{"recursion", RECURSION_OPTION, 0, 0,
{"recursion", RECURSION_OPTION, NULL, 0,
N_("recurse into directories (default)"), GRID_LOCAL },
{"no-recursion", NO_RECURSION_OPTION, 0, 0,
{"no-recursion", NO_RECURSION_OPTION, NULL, 0,
N_("avoid descending automatically in directories"), GRID_LOCAL },
{NULL, 0, NULL, 0,
N_("File name matching options (affect both exclude and include patterns):"),
GRH_MATCH },
{"anchored", ANCHORED_OPTION, 0, 0,
{"anchored", ANCHORED_OPTION, NULL, 0,
N_("patterns match file name start"), GRID_MATCH },
{"no-anchored", NO_ANCHORED_OPTION, 0, 0,
{"no-anchored", NO_ANCHORED_OPTION, NULL, 0,
N_("patterns match after any '/' (default for exclusion)"), GRID_MATCH },
{"ignore-case", IGNORE_CASE_OPTION, 0, 0,
{"ignore-case", IGNORE_CASE_OPTION, NULL, 0,
N_("ignore case"), GRID_MATCH },
{"no-ignore-case", NO_IGNORE_CASE_OPTION, 0, 0,
{"no-ignore-case", NO_IGNORE_CASE_OPTION, NULL, 0,
N_("case sensitive matching (default)"), GRID_MATCH },
{"wildcards", WILDCARDS_OPTION, 0, 0,
{"wildcards", WILDCARDS_OPTION, NULL, 0,
N_("use wildcards (default for exclusion)"), GRID_MATCH },
{"no-wildcards", NO_WILDCARDS_OPTION, 0, 0,
{"no-wildcards", NO_WILDCARDS_OPTION, NULL, 0,
N_("verbatim string matching"), GRID_MATCH },
{"wildcards-match-slash", WILDCARDS_MATCH_SLASH_OPTION, 0, 0,
{"wildcards-match-slash", WILDCARDS_MATCH_SLASH_OPTION, NULL, 0,
N_("wildcards match '/' (default for exclusion)"), GRID_MATCH },
{"no-wildcards-match-slash", NO_WILDCARDS_MATCH_SLASH_OPTION, 0, 0,
{"no-wildcards-match-slash", NO_WILDCARDS_MATCH_SLASH_OPTION, NULL, 0,
N_("wildcards do not match '/'"), GRID_MATCH },
{NULL}
@ -1188,7 +1188,7 @@ name_gather (void)
free_name (buffer);
buffer = make_name (ep->v.name);
buffer->change_dir = change_dir;
buffer->next = 0;
buffer->next = NULL;
buffer->found_count = 0;
buffer->matching_flags = include_options ();
buffer->directory = NULL;
@ -1829,7 +1829,7 @@ collect_and_sort_names (void)
namelist = merge_sort (namelist, num_names, compare_names);
num_names = 0;
nametab = hash_initialize (0, 0, name_hash, name_compare, NULL);
nametab = hash_initialize (0, NULL, name_hash, name_compare, NULL);
for (name = namelist; name; name = next_name)
{
next_name = name->next;
@ -1905,10 +1905,10 @@ name_scan (const char *file_name, bool exact)
{
name_gather (); /* read one more */
if (namelist->found_count)
return 0;
return NULL;
}
else
return 0;
return NULL;
}
}
@ -1942,7 +1942,7 @@ blank_name_list (void)
{
struct name *name;
gnu_list_name = 0;
gnu_list_name = NULL;
for (name = namelist; name; name = name->next)
name->found_count = 0;
}

186
src/tar.c
View File

@ -532,24 +532,24 @@ static struct argp_option options[] = {
{NULL, 0, NULL, 0,
N_("Main operation mode:"), GRH_COMMAND },
{"list", 't', 0, 0,
{"list", 't', NULL, 0,
N_("list the contents of an archive"), GRID_COMMAND },
{"extract", 'x', 0, 0,
{"extract", 'x', NULL, 0,
N_("extract files from an archive"), GRID_COMMAND },
{"get", 0, 0, OPTION_ALIAS, NULL, GRID_COMMAND },
{"create", 'c', 0, 0,
{"get", 0, NULL, OPTION_ALIAS, NULL, GRID_COMMAND },
{"create", 'c', NULL, 0,
N_("create a new archive"), GRID_COMMAND },
{"diff", 'd', 0, 0,
{"diff", 'd', NULL, 0,
N_("find differences between archive and file system"), GRID_COMMAND },
{"compare", 0, 0, OPTION_ALIAS, NULL, GRID_COMMAND },
{"append", 'r', 0, 0,
{"compare", 0, NULL, OPTION_ALIAS, NULL, GRID_COMMAND },
{"append", 'r', NULL, 0,
N_("append files to the end of an archive"), GRID_COMMAND },
{"update", 'u', 0, 0,
{"update", 'u', NULL, 0,
N_("only append files newer than copy in archive"), GRID_COMMAND },
{"catenate", 'A', 0, 0,
{"catenate", 'A', NULL, 0,
N_("append tar files to an archive"), GRID_COMMAND },
{"concatenate", 0, 0, OPTION_ALIAS, NULL, GRID_COMMAND },
{"delete", DELETE_OPTION, 0, 0,
{"concatenate", 0, NULL, OPTION_ALIAS, NULL, GRID_COMMAND },
{"delete", DELETE_OPTION, NULL, 0,
N_("delete from the archive (not on mag tapes!)"), GRID_COMMAND },
{"test-label", TEST_LABEL_OPTION, NULL, 0,
N_("test the archive volume label and exit"), GRID_COMMAND },
@ -557,20 +557,20 @@ static struct argp_option options[] = {
{NULL, 0, NULL, 0,
N_("Operation modifiers:"), GRH_MODIFIER },
{"sparse", 'S', 0, 0,
{"sparse", 'S', NULL, 0,
N_("handle sparse files efficiently"), GRID_MODIFIER },
{"hole-detection", HOLE_DETECTION_OPTION, N_("TYPE"), 0,
N_("technique to detect holes"), GRID_MODIFIER },
{"sparse-version", SPARSE_VERSION_OPTION, N_("MAJOR[.MINOR]"), 0,
N_("set version of the sparse format to use (implies --sparse)"),
GRID_MODIFIER},
{"incremental", 'G', 0, 0,
{"incremental", 'G', NULL, 0,
N_("handle old GNU-format incremental backup"), GRID_MODIFIER },
{"listed-incremental", 'g', N_("FILE"), 0,
N_("handle new GNU-format incremental backup"), GRID_MODIFIER },
{"level", LEVEL_OPTION, N_("NUMBER"), 0,
N_("dump level for created listed-incremental archive"), GRID_MODIFIER },
{"ignore-failed-read", IGNORE_FAILED_READ_OPTION, 0, 0,
{"ignore-failed-read", IGNORE_FAILED_READ_OPTION, NULL, 0,
N_("do not exit with nonzero on unreadable files"), GRID_MODIFIER },
{"occurrence", OCCURRENCE_OPTION, N_("NUMBER"), OPTION_ARG_OPTIONAL,
N_("process only the NUMBERth occurrence of each file in the archive;"
@ -592,30 +592,30 @@ static struct argp_option options[] = {
{NULL, 0, NULL, 0,
N_("Overwrite control:"), GRH_OVERWRITE },
{"verify", 'W', 0, 0,
{"verify", 'W', NULL, 0,
N_("attempt to verify the archive after writing it"), GRID_OVERWRITE },
{"remove-files", REMOVE_FILES_OPTION, 0, 0,
{"remove-files", REMOVE_FILES_OPTION, NULL, 0,
N_("remove files after adding them to the archive"), GRID_OVERWRITE },
{"keep-old-files", 'k', 0, 0,
{"keep-old-files", 'k', NULL, 0,
N_("don't replace existing files when extracting, "
"treat them as errors"), GRID_OVERWRITE },
{"skip-old-files", SKIP_OLD_FILES_OPTION, 0, 0,
{"skip-old-files", SKIP_OLD_FILES_OPTION, NULL, 0,
N_("don't replace existing files when extracting, silently skip over them"),
GRID_OVERWRITE },
{"keep-newer-files", KEEP_NEWER_FILES_OPTION, 0, 0,
{"keep-newer-files", KEEP_NEWER_FILES_OPTION, NULL, 0,
N_("don't replace existing files that are newer than their archive copies"), GRID_OVERWRITE },
{"overwrite", OVERWRITE_OPTION, 0, 0,
{"overwrite", OVERWRITE_OPTION, NULL, 0,
N_("overwrite existing files when extracting"), GRID_OVERWRITE },
{"unlink-first", 'U', 0, 0,
{"unlink-first", 'U', NULL, 0,
N_("remove each file prior to extracting over it"), GRID_OVERWRITE },
{"recursive-unlink", RECURSIVE_UNLINK_OPTION, 0, 0,
{"recursive-unlink", RECURSIVE_UNLINK_OPTION, NULL, 0,
N_("empty hierarchies prior to extracting directory"), GRID_OVERWRITE },
{"no-overwrite-dir", NO_OVERWRITE_DIR_OPTION, 0, 0,
{"no-overwrite-dir", NO_OVERWRITE_DIR_OPTION, NULL, 0,
N_("preserve metadata of existing directories"), GRID_OVERWRITE },
{"overwrite-dir", OVERWRITE_DIR_OPTION, 0, 0,
{"overwrite-dir", OVERWRITE_DIR_OPTION, NULL, 0,
N_("overwrite metadata of existing directories when extracting (default)"),
GRID_OVERWRITE },
{"keep-directory-symlink", KEEP_DIRECTORY_SYMLINK_OPTION, 0, 0,
{"keep-directory-symlink", KEEP_DIRECTORY_SYMLINK_OPTION, NULL, 0,
N_("preserve existing symlinks to directories when extracting"),
GRID_OVERWRITE },
{"one-top-level", ONE_TOP_LEVEL_OPTION, N_("DIR"), OPTION_ARG_OPTIONAL,
@ -625,13 +625,13 @@ static struct argp_option options[] = {
{NULL, 0, NULL, 0,
N_("Select output stream:"), GRH_OUTPUT },
{"to-stdout", 'O', 0, 0,
{"to-stdout", 'O', NULL, 0,
N_("extract files to standard output"), GRID_OUTPUT },
{"to-command", TO_COMMAND_OPTION, N_("COMMAND"), 0,
N_("pipe extracted files to another program"), GRID_OUTPUT },
{"ignore-command-error", IGNORE_COMMAND_ERROR_OPTION, 0, 0,
{"ignore-command-error", IGNORE_COMMAND_ERROR_OPTION, NULL, 0,
N_("ignore exit codes of children"), GRID_OUTPUT },
{"no-ignore-command-error", NO_IGNORE_COMMAND_ERROR_OPTION, 0, 0,
{"no-ignore-command-error", NO_IGNORE_COMMAND_ERROR_OPTION, NULL, 0,
N_("treat non-zero exit codes of children as error"), GRID_OUTPUT },
{NULL, 0, NULL, 0,
@ -647,7 +647,7 @@ static struct argp_option options[] = {
N_("use FILE to map file owner GIDs and names"), GRID_FATTR },
{"mtime", MTIME_OPTION, N_("DATE-OR-FILE"), 0,
N_("set mtime for added files from DATE-OR-FILE"), GRID_FATTR },
{"clamp-mtime", CLAMP_MTIME_OPTION, 0, 0,
{"clamp-mtime", CLAMP_MTIME_OPTION, NULL, 0,
N_("only set time when the file is more recent than what was given with --mtime"), GRID_FATTR },
{"set-mtime-command", SET_MTIME_COMMAND_OPTION, N_("COMMAND"), 0,
N_("use output of the COMMAND to set mtime of the stored archive members"),
@ -661,28 +661,28 @@ static struct argp_option options[] = {
N_("preserve access times on dumped files, either by restoring the times"
" after reading (METHOD='replace'; default) or by not setting the times"
" in the first place (METHOD='system')"), GRID_FATTR },
{"touch", 'm', 0, 0,
{"touch", 'm', NULL, 0,
N_("don't extract file modified time"), GRID_FATTR },
{"same-owner", SAME_OWNER_OPTION, 0, 0,
{"same-owner", SAME_OWNER_OPTION, NULL, 0,
N_("try extracting files with the same ownership as exists in the archive (default for superuser)"), GRID_FATTR },
{"no-same-owner", NO_SAME_OWNER_OPTION, 0, 0,
{"no-same-owner", NO_SAME_OWNER_OPTION, NULL, 0,
N_("extract files as yourself (default for ordinary users)"), GRID_FATTR },
{"numeric-owner", NUMERIC_OWNER_OPTION, 0, 0,
{"numeric-owner", NUMERIC_OWNER_OPTION, NULL, 0,
N_("always use numbers for user/group names"), GRID_FATTR },
{"preserve-permissions", 'p', 0, 0,
{"preserve-permissions", 'p', NULL, 0,
N_("extract information about file permissions (default for superuser)"),
GRID_FATTR },
{"same-permissions", 0, 0, OPTION_ALIAS, NULL, GRID_FATTR },
{"no-same-permissions", NO_SAME_PERMISSIONS_OPTION, 0, 0,
{"same-permissions", 0, NULL, OPTION_ALIAS, NULL, GRID_FATTR },
{"no-same-permissions", NO_SAME_PERMISSIONS_OPTION, NULL, 0,
N_("apply the user's umask when extracting permissions from the archive (default for ordinary users)"), GRID_FATTR },
{"preserve-order", 's', 0, 0,
{"preserve-order", 's', NULL, 0,
N_("member arguments are listed in the same order as the "
"files in the archive"), GRID_FATTR },
{"same-order", 0, 0, OPTION_ALIAS, NULL, GRID_FATTR },
{"delay-directory-restore", DELAY_DIRECTORY_RESTORE_OPTION, 0, 0,
{"same-order", 0, NULL, OPTION_ALIAS, NULL, GRID_FATTR },
{"delay-directory-restore", DELAY_DIRECTORY_RESTORE_OPTION, NULL, 0,
N_("delay setting modification times and permissions of extracted"
" directories until the end of extraction"), GRID_FATTR },
{"no-delay-directory-restore", NO_DELAY_DIRECTORY_RESTORE_OPTION, 0, 0,
{"no-delay-directory-restore", NO_DELAY_DIRECTORY_RESTORE_OPTION, NULL, 0,
N_("cancel the effect of --delay-directory-restore option"), GRID_FATTR },
{"sort", SORT_OPTION, N_("ORDER"), 0,
#if D_INO_IN_DIRENT
@ -695,21 +695,21 @@ static struct argp_option options[] = {
{NULL, 0, NULL, 0,
N_("Handling of extended file attributes:"), GRH_XATTR },
{"xattrs", XATTR_OPTION, 0, 0,
{"xattrs", XATTR_OPTION, NULL, 0,
N_("Enable extended attributes support"), GRID_XATTR },
{"no-xattrs", NO_XATTR_OPTION, 0, 0,
{"no-xattrs", NO_XATTR_OPTION, NULL, 0,
N_("Disable extended attributes support"), GRID_XATTR },
{"xattrs-include", XATTR_INCLUDE, N_("MASK"), 0,
N_("specify the include pattern for xattr keys"), GRID_XATTR },
{"xattrs-exclude", XATTR_EXCLUDE, N_("MASK"), 0,
N_("specify the exclude pattern for xattr keys"), GRID_XATTR },
{"selinux", SELINUX_CONTEXT_OPTION, 0, 0,
{"selinux", SELINUX_CONTEXT_OPTION, NULL, 0,
N_("Enable the SELinux context support"), GRID_XATTR },
{"no-selinux", NO_SELINUX_CONTEXT_OPTION, 0, 0,
{"no-selinux", NO_SELINUX_CONTEXT_OPTION, NULL, 0,
N_("Disable the SELinux context support"), GRID_XATTR },
{"acls", ACLS_OPTION, 0, 0,
{"acls", ACLS_OPTION, NULL, 0,
N_("Enable the POSIX ACLs support"), GRID_XATTR },
{"no-acls", NO_ACLS_OPTION, 0, 0,
{"no-acls", NO_ACLS_OPTION, NULL, 0,
N_("Disable the POSIX ACLs support"), GRID_XATTR },
{NULL, 0, NULL, 0,
@ -733,7 +733,7 @@ static struct argp_option options[] = {
{NULL, '8', NULL, OPTION_HIDDEN, NULL, GRID_DEVICE },
{NULL, '9', NULL, OPTION_HIDDEN, NULL, GRID_DEVICE },
{"force-local", FORCE_LOCAL_OPTION, 0, 0,
{"force-local", FORCE_LOCAL_OPTION, NULL, 0,
N_("archive file is local even if it has a colon"),
GRID_DEVICE },
{"rmt-command", RMT_COMMAND_OPTION, N_("COMMAND"), 0,
@ -743,7 +743,7 @@ static struct argp_option options[] = {
N_("use remote COMMAND instead of rsh"),
GRID_DEVICE },
{"multi-volume", 'M', 0, 0,
{"multi-volume", 'M', NULL, 0,
N_("create/list/extract multi-volume archive"),
GRID_DEVICE },
{"tape-length", 'L', N_("NUMBER"), 0,
@ -752,7 +752,7 @@ static struct argp_option options[] = {
{"info-script", 'F', N_("NAME"), 0,
N_("run script at end of each tape (implies -M)"),
GRID_DEVICE },
{"new-volume-script", 0, 0, OPTION_ALIAS, NULL, GRID_DEVICE },
{"new-volume-script", 0, NULL, OPTION_ALIAS, NULL, GRID_DEVICE },
{"volno-file", VOLNO_FILE_OPTION, N_("FILE"), 0,
N_("use/update the volume number in FILE"),
GRID_DEVICE },
@ -764,9 +764,9 @@ static struct argp_option options[] = {
N_("BLOCKS x 512 bytes per record"), GRID_BLOCKING },
{"record-size", RECORD_SIZE_OPTION, N_("NUMBER"), 0,
N_("NUMBER of bytes per record, multiple of 512"), GRID_BLOCKING },
{"ignore-zeros", 'i', 0, 0,
{"ignore-zeros", 'i', NULL, 0,
N_("ignore zeroed blocks in archive (means EOF)"), GRID_BLOCKING },
{"read-full-records", 'B', 0, 0,
{"read-full-records", 'B', NULL, 0,
N_("reblock as we read (for 4.2BSD pipes)"), GRID_BLOCKING },
{NULL, 0, NULL, 0,
@ -789,10 +789,10 @@ static struct argp_option options[] = {
{" posix", 0, NULL, OPTION_DOC|OPTION_NO_TRANS, N_("same as pax"),
GRDOC_FORMAT },
{"old-archive", OLD_ARCHIVE_OPTION, 0, 0, /* FIXME */
{"old-archive", OLD_ARCHIVE_OPTION, NULL, 0, /* FIXME */
N_("same as --format=v7"), GRID_FORMAT_OPT },
{"portability", 0, 0, OPTION_ALIAS, NULL, GRID_FORMAT_OPT },
{"posix", POSIX_OPTION, 0, 0,
{"portability", 0, NULL, OPTION_ALIAS, NULL, GRID_FORMAT_OPT },
{"posix", POSIX_OPTION, NULL, 0,
N_("same as --format=posix"), GRID_FORMAT_OPT },
{"pax-option", PAX_OPTION, N_("keyword[[:]=value][,keyword[[:]=value]]..."), 0,
N_("control pax keywords"), GRID_FORMAT_OPT },
@ -802,37 +802,37 @@ static struct argp_option options[] = {
{NULL, 0, NULL, 0,
N_("Compression options:"), GRH_COMPRESS },
{"auto-compress", 'a', 0, 0,
{"auto-compress", 'a', NULL, 0,
N_("use archive suffix to determine the compression program"),
GRID_COMPRESS },
{"no-auto-compress", NO_AUTO_COMPRESS_OPTION, 0, 0,
{"no-auto-compress", NO_AUTO_COMPRESS_OPTION, NULL, 0,
N_("do not use archive suffix to determine the compression program"),
GRID_COMPRESS },
{"use-compress-program", 'I', N_("PROG"), 0,
N_("filter through PROG (must accept -d)"), GRID_COMPRESS },
/* Note: docstrings for the options below are generated by tar_help_filter */
{"bzip2", 'j', 0, 0, NULL, GRID_COMPRESS },
{"gzip", 'z', 0, 0, NULL, GRID_COMPRESS },
{"gunzip", 0, 0, OPTION_ALIAS, NULL, GRID_COMPRESS },
{"ungzip", 0, 0, OPTION_ALIAS, NULL, GRID_COMPRESS },
{"compress", 'Z', 0, 0, NULL, GRID_COMPRESS },
{"uncompress", 0, 0, OPTION_ALIAS, NULL, GRID_COMPRESS },
{"lzip", LZIP_OPTION, 0, 0, NULL, GRID_COMPRESS },
{"lzma", LZMA_OPTION, 0, 0, NULL, GRID_COMPRESS },
{"lzop", LZOP_OPTION, 0, 0, NULL, GRID_COMPRESS },
{"xz", 'J', 0, 0, NULL, GRID_COMPRESS },
{"zstd", ZSTD_OPTION, 0, 0, NULL, GRID_COMPRESS },
{"bzip2", 'j', NULL, 0, NULL, GRID_COMPRESS },
{"gzip", 'z', NULL, 0, NULL, GRID_COMPRESS },
{"gunzip", 0, NULL, OPTION_ALIAS, NULL, GRID_COMPRESS },
{"ungzip", 0, NULL, OPTION_ALIAS, NULL, GRID_COMPRESS },
{"compress", 'Z', NULL, 0, NULL, GRID_COMPRESS },
{"uncompress", 0, NULL, OPTION_ALIAS, NULL, GRID_COMPRESS },
{"lzip", LZIP_OPTION, NULL, 0, NULL, GRID_COMPRESS },
{"lzma", LZMA_OPTION, NULL, 0, NULL, GRID_COMPRESS },
{"lzop", LZOP_OPTION, NULL, 0, NULL, GRID_COMPRESS },
{"xz", 'J', NULL, 0, NULL, GRID_COMPRESS },
{"zstd", ZSTD_OPTION, NULL, 0, NULL, GRID_COMPRESS },
{NULL, 0, NULL, 0,
N_("Local file selection:"), GRH_FILE },
{"one-file-system", ONE_FILE_SYSTEM_OPTION, 0, 0,
{"one-file-system", ONE_FILE_SYSTEM_OPTION, NULL, 0,
N_("stay in local file system when creating archive"), GRID_FILE },
{"absolute-names", 'P', 0, 0,
{"absolute-names", 'P', NULL, 0,
N_("don't strip leading '/'s from file names"), GRID_FILE },
{"dereference", 'h', 0, 0,
{"dereference", 'h', NULL, 0,
N_("follow symlinks; archive and dump the files they point to"),
GRID_FILE },
{"hard-dereference", HARD_DEREFERENCE_OPTION, 0, 0,
{"hard-dereference", HARD_DEREFERENCE_OPTION, NULL, 0,
N_("follow hard links; archive and dump the files they refer to"),
GRID_FILE },
{"starting-file", 'K', N_("MEMBER-NAME"), 0,
@ -840,7 +840,7 @@ static struct argp_option options[] = {
GRID_FILE },
{"newer", 'N', N_("DATE-OR-FILE"), 0,
N_("only store files newer than DATE-OR-FILE"), GRID_FILE },
{"after-date", 0, 0, OPTION_ALIAS, NULL, GRID_FILE },
{"after-date", 0, NULL, OPTION_ALIAS, NULL, GRID_FILE },
{"newer-mtime", NEWER_MTIME_OPTION, N_("DATE"), 0,
N_("compare date and time when data changed only"), GRID_FILE },
{"backup", BACKUP_OPTION, N_("CONTROL"), OPTION_ARG_OPTIONAL,
@ -857,7 +857,7 @@ static struct argp_option options[] = {
{"transform", TRANSFORM_OPTION, N_("EXPRESSION"), 0,
N_("use sed replace EXPRESSION to transform file names"),
GRID_NAME_XFORM },
{"xform", 0, 0, OPTION_ALIAS, NULL, GRID_NAME_XFORM },
{"xform", 0, NULL, OPTION_ALIAS, NULL, GRID_NAME_XFORM },
{NULL, 0, NULL, 0,
N_("Informative output:"), GRH_INFORMATIVE },
@ -868,41 +868,41 @@ static struct argp_option options[] = {
{"checkpoint-action", CHECKPOINT_ACTION_OPTION, N_("ACTION"), 0,
N_("execute ACTION on each checkpoint"),
GRID_INFORMATIVE },
{"check-links", 'l', 0, 0,
{"check-links", 'l', NULL, 0,
N_("print a message if not all links are dumped"), GRID_INFORMATIVE },
{"totals", TOTALS_OPTION, N_("SIGNAL"), OPTION_ARG_OPTIONAL,
N_("print total bytes after processing the archive; "
"with an argument - print total bytes when this SIGNAL is delivered; "
"Allowed signals are: SIGHUP, SIGQUIT, SIGINT, SIGUSR1 and SIGUSR2; "
"the names without SIG prefix are also accepted"), GRID_INFORMATIVE },
{"utc", UTC_OPTION, 0, 0,
{"utc", UTC_OPTION, NULL, 0,
N_("print file modification times in UTC"), GRID_INFORMATIVE },
{"full-time", FULL_TIME_OPTION, 0, 0,
{"full-time", FULL_TIME_OPTION, NULL, 0,
N_("print file time to its full resolution"), GRID_INFORMATIVE },
{"index-file", INDEX_FILE_OPTION, N_("FILE"), 0,
N_("send verbose output to FILE"), GRID_INFORMATIVE },
{"block-number", 'R', 0, 0,
{"block-number", 'R', NULL, 0,
N_("show block number within archive with each message"), GRID_INFORMATIVE },
{"show-defaults", SHOW_DEFAULTS_OPTION, 0, 0,
{"show-defaults", SHOW_DEFAULTS_OPTION, NULL, 0,
N_("show tar defaults"), GRID_INFORMATIVE },
{"show-snapshot-field-ranges", SHOW_SNAPSHOT_FIELD_RANGES_OPTION, 0, 0,
{"show-snapshot-field-ranges", SHOW_SNAPSHOT_FIELD_RANGES_OPTION, NULL, 0,
N_("show valid ranges for snapshot-file fields"), GRID_INFORMATIVE },
{"show-omitted-dirs", SHOW_OMITTED_DIRS_OPTION, 0, 0,
{"show-omitted-dirs", SHOW_OMITTED_DIRS_OPTION, NULL, 0,
N_("when listing or extracting, list each directory that does not match search criteria"), GRID_INFORMATIVE },
{"show-transformed-names", SHOW_TRANSFORMED_NAMES_OPTION, 0, 0,
{"show-transformed-names", SHOW_TRANSFORMED_NAMES_OPTION, NULL, 0,
N_("show file or archive names after transformation"),
GRID_INFORMATIVE },
{"show-stored-names", 0, 0, OPTION_ALIAS, NULL, GRID_INFORMATIVE },
{"show-stored-names", 0, NULL, OPTION_ALIAS, NULL, GRID_INFORMATIVE },
{"quoting-style", QUOTING_STYLE_OPTION, N_("STYLE"), 0,
N_("set name quoting style; see below for valid STYLE values"), GRID_INFORMATIVE },
{"quote-chars", QUOTE_CHARS_OPTION, N_("STRING"), 0,
N_("additionally quote characters from STRING"), GRID_INFORMATIVE },
{"no-quote-chars", NO_QUOTE_CHARS_OPTION, N_("STRING"), 0,
N_("disable quoting for characters from STRING"), GRID_INFORMATIVE },
{"interactive", 'w', 0, 0,
{"interactive", 'w', NULL, 0,
N_("ask for confirmation for every action"), GRID_INFORMATIVE },
{"confirmation", 0, 0, OPTION_ALIAS, NULL, GRID_INFORMATIVE },
{"verbose", 'v', 0, 0,
{"confirmation", 0, NULL, OPTION_ALIAS, NULL, GRID_INFORMATIVE },
{"verbose", 'v', NULL, 0,
N_("verbosely list files processed"), GRID_INFORMATIVE },
{"warning", WARNING_OPTION, N_("KEYWORD"), 0,
N_("warning control"), GRID_INFORMATIVE },
@ -910,16 +910,16 @@ static struct argp_option options[] = {
{NULL, 0, NULL, 0,
N_("Compatibility options:"), GRH_COMPAT },
{NULL, 'o', 0, 0,
{NULL, 'o', NULL, 0,
N_("when creating, same as --old-archive; when extracting, same as --no-same-owner"), GRID_COMPAT },
{NULL, 0, NULL, 0,
N_("Other options:"), GRH_OTHER },
{"restrict", RESTRICT_OPTION, 0, 0,
{"restrict", RESTRICT_OPTION, NULL, 0,
N_("disable use of some potentially harmful options"), -1 },
{0, 0, 0, 0, 0, 0}
{NULL, 0, NULL, 0, NULL, 0}
};
static char const *const atime_preserve_args[] =
@ -2242,7 +2242,7 @@ find_argp_option_key (struct argp_option const *o, char key)
for (;
!(o->name == NULL
&& o->key == 0
&& o->arg == 0
&& o->arg == NULL
&& o->flags == 0
&& o->doc == NULL); o++)
if (o->key == key)
@ -2325,7 +2325,7 @@ parse_default_options (struct tar_args *args)
{
char *opts = getenv ("TAR_OPTIONS");
struct wordsplit ws;
struct option_locus loc = { OPTS_ENVIRON, "TAR_OPTIONS", 0, 0 };
struct option_locus loc = { OPTS_ENVIRON, "TAR_OPTIONS", 0, NULL };
struct option_locus *save_loc_ptr;
if (!opts)
@ -2445,7 +2445,7 @@ decode_options (int argc, char **argv)
while (in < argv + argc)
*out++ = *in++;
*out = 0;
*out = NULL;
/* Replace the old option list by the new one. */
@ -2857,7 +2857,7 @@ main (int argc, char **argv)
exit_status = TAREXIT_SUCCESS;
error_hook = checkpoint_flush_actions;
set_quoting_style (0, DEFAULT_QUOTING_STYLE);
set_quoting_style (NULL, DEFAULT_QUOTING_STYLE);
close_stdout_set_file_name (_("stdout"));
@ -2963,7 +2963,7 @@ tar_stat_close (struct tar_stat_info *st)
int status = (st->dirstream ? closedir (st->dirstream)
: 0 < st->fd ? close (st->fd)
: 0);
st->dirstream = 0;
st->dirstream = NULL;
st->fd = 0;
if (status == 0)

View File

@ -221,7 +221,7 @@ update_archive (void)
if (subcommand_option == CAT_SUBCOMMAND)
append_file (file_name);
else
dump_file (0, file_name, file_name);
dump_file (NULL, file_name, file_name);
}
}

View File

@ -73,7 +73,7 @@ utf8_convert (bool to_utf, char const *input, char **output)
size_t outlen;
iconv_t cd = utf8_init (to_utf);
if (cd == 0)
if (!cd)
{
*output = xstrdup (input);
return true;

View File

@ -904,7 +904,7 @@ xheader_destroy (struct xheader *xhdr)
}
else
free (xhdr->buffer);
xhdr->buffer = 0;
xhdr->buffer = NULL;
xhdr->size = 0;
}