mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
cp: simplify infer_scantype
* src/copy.c (infer_scantype): Do not set *SCAN_INFERENCE when returning a value other than LSEEK_SCANTYPE. This is just minor refactoring; it simplifies the code a bit. Callers are uneffected. doc: document --preserve=mode better
This commit is contained in:
1 parent
d195e3863c
commit
d374d32ccf
1 file changed
+8
-10
+8
-10
@@ -1052,7 +1052,7 @@ union scan_inference
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Return how to scan a file with descriptor FD and stat buffer SB.
|
/* Return how to scan a file with descriptor FD and stat buffer SB.
|
||||||
Store any information gathered into *SCAN_INFERENCE. */
|
Set *SCAN_INFERENCE if returning LSEEK_SCANTYPE. */
|
||||||
static enum scantype
|
static enum scantype
|
||||||
infer_scantype (int fd, struct stat const *sb,
|
infer_scantype (int fd, struct stat const *sb,
|
||||||
union scan_inference *scan_inference)
|
union scan_inference *scan_inference)
|
||||||
@@ -1060,19 +1060,17 @@ infer_scantype (int fd, struct stat const *sb,
|
|||||||
if (! (HAVE_STRUCT_STAT_ST_BLOCKS
|
if (! (HAVE_STRUCT_STAT_ST_BLOCKS
|
||||||
&& S_ISREG (sb->st_mode)
|
&& S_ISREG (sb->st_mode)
|
||||||
&& ST_NBLOCKS (*sb) < sb->st_size / ST_NBLOCKSIZE))
|
&& ST_NBLOCKS (*sb) < sb->st_size / ST_NBLOCKSIZE))
|
||||||
{
|
return PLAIN_SCANTYPE;
|
||||||
scan_inference->ext_start = -1;
|
|
||||||
return PLAIN_SCANTYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SEEK_HOLE
|
#ifdef SEEK_HOLE
|
||||||
scan_inference->ext_start = lseek (fd, 0, SEEK_DATA);
|
off_t ext_start = lseek (fd, 0, SEEK_DATA);
|
||||||
if (0 <= scan_inference->ext_start || errno == ENXIO)
|
if (0 <= ext_start || errno == ENXIO)
|
||||||
return LSEEK_SCANTYPE;
|
{
|
||||||
|
scan_inference->ext_start = ext_start;
|
||||||
|
return LSEEK_SCANTYPE;
|
||||||
|
}
|
||||||
else if (errno != EINVAL && !is_ENOTSUP (errno))
|
else if (errno != EINVAL && !is_ENOTSUP (errno))
|
||||||
return ERROR_SCANTYPE;
|
return ERROR_SCANTYPE;
|
||||||
#else
|
|
||||||
scan_inference->ext_start = -1;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ZERO_SCANTYPE;
|
return ZERO_SCANTYPE;
|
||||||
|
|||||||
Reference in new issue
Block a user