mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-08-19 07:46:03 +00:00
Be a bit more consistent about comparing to zero
* src/buffer.c (xclose, archive_is_dev, close_archive) (write_fatal_details, init_volume_number) (closeout_volume_number, new_volume, try_new_volume): * src/checkpoint.c (format_checkpoint_string): * src/compare.c (process_rawdata, diff_file, diff_dumpdir): * src/create.c (create_archive, restore_parent_fd, dump_file0): * src/delete.c (delete_archive_members): * src/exclist.c (cvs_addfn): * src/extract.c (set_mode, mark_after_links, delay_set_stat) (repair_delayed_set_stat, make_directories, file_newer_p) (maybe_recoverable, apply_nonancestor_delayed_set_stat) (extract_dir, open_output_file, find_delayed_link_source) (create_placeholder_file, extract_symlink, extract_node) (extract_fifo, apply_delayed_link): * src/incremen.c (update_parent_directory, scan_directory) (read_obstack, read_incr_db_2, write_directory_file) (try_purge_directory): * src/map.c (map_read): * src/misc.c (maybe_backup_file, undo_last_backup, chdir_do) (tar_savedir): * src/names.c (handle_file_selection_option, add_file_id) (handle_option, read_next_name, add_hierarchy_to_namelist) (collect_and_sort_names): * src/system.c (run_decompress_program, dec_to_env, time_to_env) (oct_to_env, str_to_env, chr_to_env, sys_exec_setmtime_script): * src/tar.c (get_date_or_file, parse_default_options) (decode_options, main): * src/unlink.c (flush_deferred_unlinks): * src/update.c (append_file): * src/xattrs.c (xattrs__acls_set, xattrs_xattrs_set): Prefer < 0 when looking at syscalls; prefer != 0 to nothing when testing an integer in a boolean context. This is for style, not substance; for example, it’s easier to read ‘if (wordsplit (...) != WRDSE_OK) ...’ than ‘if (wordsplit (...)) ...’ if you don’t already know that wordsplit returns an enum rather than bool. * src/names.c (add_file_id, read_next_name, regex_usage_warning): * src/transform.c (parse_xform_flags): Return bool not int, possibly inverting sense so that true means OK. All callers changed. * src/tar.c (main): Report errno info if stdopen fails.
This commit is contained in:
+12
-12
@@ -1346,7 +1346,7 @@ create_archive (void)
|
||||
break;
|
||||
}
|
||||
st.fd = fd;
|
||||
if (fstat (fd, &st.stat) != 0)
|
||||
if (fstat (fd, &st.stat) < 0)
|
||||
{
|
||||
file_removed_diag (p->name, !p->parent,
|
||||
stat_diag);
|
||||
@@ -1555,9 +1555,9 @@ restore_parent_fd (struct tar_stat_info const *st)
|
||||
|
||||
if (parentfd < 0)
|
||||
parentfd = - errno;
|
||||
else if (! (fstat (parentfd, &parentstat) == 0
|
||||
&& parent->stat.st_ino == parentstat.st_ino
|
||||
&& parent->stat.st_dev == parentstat.st_dev))
|
||||
else if (fstat (parentfd, &parentstat) < 0
|
||||
|| parent->stat.st_ino != parentstat.st_ino
|
||||
|| parent->stat.st_dev != parentstat.st_dev)
|
||||
{
|
||||
close (parentfd);
|
||||
parentfd = IMPOSTOR_ERRNO;
|
||||
@@ -1569,12 +1569,12 @@ restore_parent_fd (struct tar_stat_info const *st)
|
||||
open_searchdir_flags);
|
||||
if (0 <= origfd)
|
||||
{
|
||||
if (fstat (parentfd, &parentstat) == 0
|
||||
&& parent->stat.st_ino == parentstat.st_ino
|
||||
&& parent->stat.st_dev == parentstat.st_dev)
|
||||
parentfd = origfd;
|
||||
else
|
||||
if (fstat (parentfd, &parentstat) < 0
|
||||
|| parent->stat.st_ino != parentstat.st_ino
|
||||
|| parent->stat.st_dev != parentstat.st_dev)
|
||||
close (origfd);
|
||||
else
|
||||
parentfd = origfd;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1619,7 +1619,7 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p)
|
||||
errno = - parentfd;
|
||||
diag = open_diag;
|
||||
}
|
||||
else if (fstatat (parentfd, name, &st->stat, fstatat_flags) != 0)
|
||||
else if (fstatat (parentfd, name, &st->stat, fstatat_flags) < 0)
|
||||
diag = stat_diag;
|
||||
else if (file_dumpable_p (&st->stat))
|
||||
{
|
||||
@@ -1629,7 +1629,7 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p)
|
||||
else
|
||||
{
|
||||
st->fd = fd;
|
||||
if (fstat (fd, &st->stat) != 0)
|
||||
if (fstat (fd, &st->stat) < 0)
|
||||
diag = stat_diag;
|
||||
}
|
||||
}
|
||||
@@ -1804,7 +1804,7 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p)
|
||||
}
|
||||
else if (atime_preserve_option == replace_atime_preserve
|
||||
&& timespec_cmp (st->atime, get_stat_atime (&st2)) != 0
|
||||
&& set_file_atime (fd, parentfd, name, st->atime) != 0)
|
||||
&& set_file_atime (fd, parentfd, name, st->atime) < 0)
|
||||
utime_error (p);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user