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:
Paul Eggert
2024-11-01 13:44:33 -07:00
parent 3b0d006830
commit f8a679e942
17 changed files with 120 additions and 122 deletions

View File

@@ -654,7 +654,7 @@ available_space_after (union block *pointer)
void
xclose (int fd)
{
if (close (fd) != 0)
if (close (fd) < 0)
close_error (_("(pipe)"));
}
@@ -949,7 +949,7 @@ archive_is_dev (void)
{
struct stat st;
if (fstat (archive, &st))
if (fstat (archive, &st) < 0)
{
stat_diag (*archive_name_cursor);
return false;
@@ -1143,7 +1143,7 @@ close_archive (void)
if (verify_option)
verify_volume ();
if (rmtclose (archive) != 0)
if (rmtclose (archive) < 0)
close_error (*archive_name_cursor);
sys_wait_for_child (child_pid, hit_eof);
@@ -1158,7 +1158,7 @@ static void
write_fatal_details (char const *name, ssize_t status, idx_t size)
{
write_error_details (name, status, size);
if (rmtclose (archive) != 0)
if (rmtclose (archive) < 0)
close_error (*archive_name_cursor);
sys_wait_for_child (child_pid, false);
fatal_exit ();
@@ -1178,7 +1178,7 @@ init_volume_number (void)
quotearg_colon (volno_file_option));
if (ferror (file))
read_error (volno_file_option);
if (fclose (file) != 0)
if (fclose (file) < 0)
close_error (volno_file_option);
}
else if (errno != ENOENT)
@@ -1196,7 +1196,7 @@ closeout_volume_number (void)
fprintf (file, "%jd\n", global_volno);
if (ferror (file))
write_error (volno_file_option);
if (fclose (file) != 0)
if (fclose (file) < 0)
close_error (volno_file_option);
}
else
@@ -1338,7 +1338,7 @@ new_volume (enum access_mode mode)
continued_file_size = continued_file_offset = 0;
current_block = record_start;
if (rmtclose (archive) != 0)
if (rmtclose (archive) < 0)
close_error (*archive_name_cursor);
archive_name_cursor++;
@@ -1358,7 +1358,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))
if (sys_exec_info_script (archive_name_cursor, global_volno + 1) != 0)
paxfatal (0, _("%s command failed"), quote (info_script_option));
}
else
@@ -1538,7 +1538,7 @@ try_new_volume (void)
return false;
}
if (strcmp (continued_file_name, bufmap_head->file_name))
if (strcmp (continued_file_name, bufmap_head->file_name) != 0)
{
if ((archive_format == GNU_FORMAT || archive_format == OLDGNU_FORMAT)
&& strlen (bufmap_head->file_name) >= NAME_FIELD_SIZE