]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jc/genzeros-avoid-raw-write'
authorJunio C Hamano <gitster@pobox.com>
Fri, 24 Feb 2023 19:32:30 +0000 (11:32 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 Feb 2023 19:32:30 +0000 (11:32 -0800)
A test helper had a single write(2) of 256kB, which was too big for
some platforms (e.g. NonStop), which has been corrected by using
xwrite() wrapper appropriately.

* jc/genzeros-avoid-raw-write:
  test-genzeros: avoid raw write(2)

t/helper/test-genzeros.c

index 8ca988d6216e7895d8afea772e110b7eeaa875d1..47af843b6816005f2370fb130bc9f2bde873c029 100644 (file)
@@ -17,15 +17,16 @@ int cmd__genzeros(int argc, const char **argv)
 
        /* Writing out individual NUL bytes is slow... */
        while (count < 0)
-               if (write(1, zeros, ARRAY_SIZE(zeros)) < 0)
-                       return -1;
+               if (xwrite(1, zeros, ARRAY_SIZE(zeros)) < 0)
+                       die_errno("write error");
 
        while (count > 0) {
-               n = write(1, zeros, count < ARRAY_SIZE(zeros) ?
-                         count : ARRAY_SIZE(zeros));
+               n = xwrite(1, zeros,
+                          count < ARRAY_SIZE(zeros)
+                          ? count : ARRAY_SIZE(zeros));
 
                if (n < 0)
-                       return -1;
+                       die_errno("write error");
 
                count -= n;
        }