]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
cp: avoid -Wmaybe-uninitialized warning from GCC13
authorJim Meyering <meyering@fb.com>
Thu, 23 Jun 2022 14:33:08 +0000 (07:33 -0700)
committerJim Meyering <meyering@fb.com>
Thu, 23 Jun 2022 15:31:21 +0000 (08:31 -0700)
* src/copy.c (infer_scantype): Always set scan_inference.ext_start,
to make the code match the comment.

src/copy.c

index edc822134321e2f6df69629c13ddb662d7915414..0c368d0e4e3c22bcfdc85a42ff2670c1790d8243 100644 (file)
@@ -1045,7 +1045,10 @@ 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))
-    return PLAIN_SCANTYPE;
+    {
+      scan_inference->ext_start = -1;
+      return PLAIN_SCANTYPE;
+    }
 
 #ifdef SEEK_HOLE
   scan_inference->ext_start = lseek (fd, 0, SEEK_DATA);
@@ -1053,6 +1056,8 @@ infer_scantype (int fd, struct stat const *sb,
     return LSEEK_SCANTYPE;
   else if (errno != EINVAL && !is_ENOTSUP (errno))
     return ERROR_SCANTYPE;
+#else
+  scan_inference->ext_start = -1;
 #endif
 
   return ZERO_SCANTYPE;