diff options
| author | Pádraig Brady <P@draigBrady.com> | 2025-11-03 22:42:22 +0000 |
|---|---|---|
| committer | Pádraig Brady <P@draigBrady.com> | 2025-11-04 16:32:16 +0000 |
| commit | 4c0cf3864a74b4bbb6c51e7abecddbde5cc6924e (patch) | |
| tree | 82366a38896168e09ecd6f349d77a3cc7eae301f | |
| parent | tests: avoid skipping of LD_PRELOAD based df tests (diff) | |
| download | coreutils-4c0cf3864a74b4bbb6c51e7abecddbde5cc6924e.tar.gz coreutils-4c0cf3864a74b4bbb6c51e7abecddbde5cc6924e.zip | |
maint: adjust lseek_copy to handle non zero offsets
* src/copy-file-data.c (lseek_copy): hole_start is initialized
only when ext_start == ipos.
(infer_scantype): Update the hole_start initialization to
the more logically correct POS, even though that init
is only needed to suppress a -Wmaybe-uninitialized warning.
Note gcc 15.2 at least doesn't seem to need that suppression.
| -rw-r--r-- | src/copy-file-data.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/copy-file-data.c b/src/copy-file-data.c index 125cf7856..c88b10cb3 100644 --- a/src/copy-file-data.c +++ b/src/copy-file-data.c @@ -338,7 +338,7 @@ lseek_copy (int src_fd, int dest_fd, char **abuf, idx_t buf_size, for (off_t ext_start = scan_inference->ext_start; 0 <= ext_start && ext_start < max_ipos; ) { - off_t ext_end = (ext_start == 0 + off_t ext_end = (ext_start == ipos ? scan_inference->hole_start : lseek (src_fd, ext_start, SEEK_HOLE)); if (0 <= ext_end) @@ -497,7 +497,7 @@ infer_scantype (int fd, struct stat const *sb, off_t pos, } else if (pos < scan_inference->ext_start || errno == ENXIO) { - scan_inference->hole_start = 0; /* Pacify -Wmaybe-uninitialized. */ + scan_inference->hole_start = pos; /* Pacify -Wmaybe-uninitialized. */ return LSEEK_SCANTYPE; } else if (errno != EINVAL && !is_ENOTSUP (errno)) |
