Fewer macros in extract.c
* src/extract.c (ALL_MODE_BITS, RECOVER_NO, RECOVER_OK) (RECOVER_SKIP): Now constants or inline functions, not macros. (maybe_recoverable): Return enum recover, not int.
This commit is contained in:
@@ -36,7 +36,7 @@ static bool we_are_root; /* true if our effective uid == 0 */
|
|||||||
static mode_t newdir_umask; /* umask when creating new directories */
|
static mode_t newdir_umask; /* umask when creating new directories */
|
||||||
static mode_t current_umask; /* current umask (which is set to 0 if -p) */
|
static mode_t current_umask; /* current umask (which is set to 0 if -p) */
|
||||||
|
|
||||||
#define ALL_MODE_BITS ((mode_t) ~ (mode_t) 0)
|
static mode_t const all_mode_bits = ~ (mode_t) 0;
|
||||||
|
|
||||||
#if ! HAVE_FCHMOD && ! defined fchmod
|
#if ! HAVE_FCHMOD && ! defined fchmod
|
||||||
# define fchmod(fd, mode) (errno = ENOSYS, -1)
|
# define fchmod(fd, mode) (errno = ENOSYS, -1)
|
||||||
@@ -645,7 +645,7 @@ repair_delayed_set_stat (char const *dir,
|
|||||||
data->atime = current_stat_info.atime;
|
data->atime = current_stat_info.atime;
|
||||||
data->mtime = current_stat_info.mtime;
|
data->mtime = current_stat_info.mtime;
|
||||||
data->current_mode = st.st_mode;
|
data->current_mode = st.st_mode;
|
||||||
data->current_mode_mask = ALL_MODE_BITS;
|
data->current_mode_mask = all_mode_bits;
|
||||||
data->interdir = false;
|
data->interdir = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -830,9 +830,7 @@ file_newer_p (const char *file_name, struct stat const *stp,
|
|||||||
&& tar_timespec_cmp (tar_stat->mtime, get_stat_mtime (stp)) <= 0);
|
&& tar_timespec_cmp (tar_stat->mtime, get_stat_mtime (stp)) <= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RECOVER_NO 0
|
enum recover { RECOVER_NO, RECOVER_OK, RECOVER_SKIP };
|
||||||
#define RECOVER_OK 1
|
|
||||||
#define RECOVER_SKIP 2
|
|
||||||
|
|
||||||
/* Attempt repairing what went wrong with the extraction. Delete an
|
/* Attempt repairing what went wrong with the extraction. Delete an
|
||||||
already existing file or create missing intermediate directories.
|
already existing file or create missing intermediate directories.
|
||||||
@@ -846,7 +844,7 @@ file_newer_p (const char *file_name, struct stat const *stp,
|
|||||||
Set *INTERDIR_MADE if an intermediate directory is made as part of
|
Set *INTERDIR_MADE if an intermediate directory is made as part of
|
||||||
the recovery process. */
|
the recovery process. */
|
||||||
|
|
||||||
static int
|
static enum recover
|
||||||
maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
|
maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
|
||||||
{
|
{
|
||||||
int e = errno;
|
int e = errno;
|
||||||
@@ -994,7 +992,7 @@ apply_nonancestor_delayed_set_stat (char const *file_name, bool after_links)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
current_mode = st.st_mode;
|
current_mode = st.st_mode;
|
||||||
current_mode_mask = ALL_MODE_BITS;
|
current_mode_mask = all_mode_bits;
|
||||||
if (! (st.st_dev == data->dev && st.st_ino == data->ino))
|
if (! (st.st_dev == data->dev && st.st_ino == data->ino))
|
||||||
{
|
{
|
||||||
paxerror (0,
|
paxerror (0,
|
||||||
@@ -1122,7 +1120,7 @@ extract_dir (char *file_name, int typeflag)
|
|||||||
|| deref_stat (file_name, &st) == 0)
|
|| deref_stat (file_name, &st) == 0)
|
||||||
{
|
{
|
||||||
current_mode = st.st_mode;
|
current_mode = st.st_mode;
|
||||||
current_mode_mask = ALL_MODE_BITS;
|
current_mode_mask = all_mode_bits;
|
||||||
|
|
||||||
if (S_ISDIR (current_mode))
|
if (S_ISDIR (current_mode))
|
||||||
{
|
{
|
||||||
@@ -1265,7 +1263,7 @@ open_output_file (char const *file_name, int typeflag, mode_t mode,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*current_mode = st.st_mode;
|
*current_mode = st.st_mode;
|
||||||
*current_mode_mask = ALL_MODE_BITS;
|
*current_mode_mask = all_mode_bits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1312,7 +1310,8 @@ extract_file (char *file_name, int typeflag)
|
|||||||
¤t_mode_mask))
|
¤t_mode_mask))
|
||||||
< 0))
|
< 0))
|
||||||
{
|
{
|
||||||
int recover = maybe_recoverable (file_name, true, &interdir_made);
|
enum recover recover
|
||||||
|
= maybe_recoverable (file_name, true, &interdir_made);
|
||||||
if (recover != RECOVER_OK)
|
if (recover != RECOVER_OK)
|
||||||
{
|
{
|
||||||
skip_member ();
|
skip_member ();
|
||||||
@@ -1521,7 +1520,7 @@ extract_link (char *file_name, MAYBE_UNUSED int typeflag)
|
|||||||
{
|
{
|
||||||
bool interdir_made = false;
|
bool interdir_made = false;
|
||||||
char const *link_name;
|
char const *link_name;
|
||||||
int rc;
|
enum recover rc;
|
||||||
|
|
||||||
link_name = current_stat_info.link_name;
|
link_name = current_stat_info.link_name;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user