]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
od: fix issues with recent format string changes
authorPádraig Brady <P@draigBrady.com>
Tue, 1 Aug 2023 12:30:02 +0000 (13:30 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 1 Aug 2023 12:30:02 +0000 (13:30 +0100)
* src/ioblksize.h: Avoid syntax check with redundant idx.h inclusion.
* src/od.c (FMT_BYTES_ALLOCATED): Increase by two to avoid:
  error: '%s' directive writing between 1 and 2 bytes into a region
  of size between 1 and 4 [-Werror=format-overflow=]
(maint): Use %td to print idx_t rather than invalid %jt format.

src/ioblksize.h
src/od.c

index 80d7931ba8d341cab671f3865f83c2802ab68dd1..0a240628664e6c3f2a02a98f0a47e3c6c47c16e2 100644 (file)
@@ -17,7 +17,6 @@
 /* Include this file _after_ system headers if possible.  */
 
 /* sys/stat.h and minmax.h will already have been included by system.h. */
-#include "idx.h"
 #include "count-leading-zeros.h"
 #include "stat-size.h"
 
index 7f5cfbb22bc25f20eafab0e84fe8edc3093a07ce..df7fe9eb8602a549f6fb0eb8cc00dc13b1555d7f 100644 (file)
--- a/src/od.c
+++ b/src/od.c
@@ -84,7 +84,7 @@ enum output_format
 enum
   {
     FMT_BYTES_ALLOCATED =
-           (sizeof "%*.99" - 1
+           (sizeof "%*.99" + 1
             + MAX (sizeof "ld",
                    MAX (sizeof PRIdMAX,
                         MAX (sizeof PRIoMAX,
@@ -1927,7 +1927,7 @@ main (int argc, char **argv)
         bytes_per_block = desired_width;
       else
         {
-          error (0, 0, _("warning: invalid width %jt; using %d instead"),
+          error (0, 0, _("warning: invalid width %td; using %d instead"),
                  desired_width, l_c_m);
           bytes_per_block = l_c_m;
         }