]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
copy: pacify older clang
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 19 Sep 2025 15:55:12 +0000 (08:55 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 19 Sep 2025 15:55:12 +0000 (08:55 -0700)
* src/copy-file-data.c (copy_file_data):
Redo conditionals for clarity.
This pacifies the clang in FreeBSD 11 and OpenBSD 7.6.
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/coreutils/2025-09/msg00104.html

src/copy-file-data.c

index 44b542de0053c32710d36939409a6ae094a75b9e..1eefd3071f58a54f725c96dfcd2fd352012398c5 100644 (file)
@@ -571,18 +571,19 @@ copy_file_data (int ifd, struct stat const *ist, off_t ipos, char const *iname,
   intmax_t result;
   off_t hole_size = 0;
 
-#ifdef SEEK_HOLE
   if (scantype == LSEEK_SCANTYPE)
-    result = lseek_copy (ifd, ofd, &buf, buf_size,
-                         ipos, ibytes, &scan_inference, ist->st_size,
-                         make_holes ? x->sparse_mode : SPARSE_NEVER,
-                         x->reflink_mode != REFLINK_NEVER,
-                         iname, oname, &hole_size, debug);
+    {
+#ifdef SEEK_HOLE
+      result = lseek_copy (ifd, ofd, &buf, buf_size,
+                           ipos, ibytes, &scan_inference, ist->st_size,
+                           make_holes ? x->sparse_mode : SPARSE_NEVER,
+                           x->reflink_mode != REFLINK_NEVER,
+                           iname, oname, &hole_size, debug);
 #else
-  assume (scantype != LSEEK_SCANTYPE);
+      unreachable ();
 #endif
-
-  if (scantype != LSEEK_SCANTYPE)
+    }
+  else
     result = sparse_copy (ifd, ofd, &buf, buf_size,
                           x->reflink_mode != REFLINK_NEVER,
                           iname, oname, ibytes,