diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2023-02-09 19:10:47 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2023-02-09 19:54:20 -0800 |
commit | d374d32ccf12f8cf33c8f823d573498b7c8b27a4 (patch) | |
tree | 32b943c4a862bc5b0cfdca5829dd0d3aee9afdf1 /src | |
parent | d195e3863cdba55bd851dac44dbf4f0bcb89a4fe (diff) | |
download | coreutils-d374d32ccf12f8cf33c8f823d573498b7c8b27a4.tar.gz |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/copy.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/copy.c b/src/copy.c index e16fedb28..dfbb557de 100644 --- a/src/copy.c +++ b/src/copy.c @@ -1052,7 +1052,7 @@ union scan_inference }; /* 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 infer_scantype (int fd, struct stat const *sb, union scan_inference *scan_inference) @@ -1060,19 +1060,17 @@ infer_scantype (int fd, struct stat const *sb, if (! (HAVE_STRUCT_STAT_ST_BLOCKS && S_ISREG (sb->st_mode) && ST_NBLOCKS (*sb) < sb->st_size / ST_NBLOCKSIZE)) - { - scan_inference->ext_start = -1; - return PLAIN_SCANTYPE; - } + return PLAIN_SCANTYPE; #ifdef SEEK_HOLE - scan_inference->ext_start = lseek (fd, 0, SEEK_DATA); - if (0 <= scan_inference->ext_start || errno == ENXIO) - return LSEEK_SCANTYPE; + off_t ext_start = lseek (fd, 0, SEEK_DATA); + if (0 <= ext_start || errno == ENXIO) + { + scan_inference->ext_start = ext_start; + return LSEEK_SCANTYPE; + } else if (errno != EINVAL && !is_ENOTSUP (errno)) return ERROR_SCANTYPE; -#else - scan_inference->ext_start = -1; #endif return ZERO_SCANTYPE; |