- Rich Felker writes: fix invalid printf format strings
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Wed, 29 Mar 2006 22:34:47 +0000 (22:34 -0000)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Wed, 29 Mar 2006 22:34:47 +0000 (22:34 -0000)
  http://busybox.net/lists/busybox/2006-March/019568.html

   text    data     bss     dec     hex filename
 900619   10316 1038724 1949659  1dbfdb busybox.oorig
 900603   10316 1038724 1949643  1dbfcb busybox

coreutils/stat.c
e2fsprogs/blkid/blkid_getsize.c
libbb/human_readable.c
networking/interface.c

index c845a2aa7e7ac953c2e4cace4e27a7d0776466d9..36e0dadf3c66e3247f7b1bb86a138fd365b7870b 100644 (file)
@@ -400,7 +400,7 @@ static int do_statfs(char const *filename, char const *format)
 #else
 
        format = (flags & OPT_TERSE
-               ? "%s %Lx %lu "
+               ? "%s %llx %lu "
                : "  File: \"%s\"\n"
                  "    ID: %-8Lx Namelen: %-7lu ");
        printf(format,
index 58cc7352a2d11c3e859702564a32f87fc5ce2e7d..3bc11e3f475c87d570fef311b08270ff8916148d 100644 (file)
@@ -173,7 +173,7 @@ int main(int argc, char **argv)
                perror(argv[0]);
 
        bytes = blkid_get_dev_size(fd);
-       printf("Device %s has %Ld 1k blocks.\n", argv[1], bytes >> 10);
+       printf("Device %s has %lld 1k blocks.\n", argv[1], bytes >> 10);
 
        return 0;
 }
index ad9025c083c7d3d11aef31f385fb8222e0e843f3..cf029c0a244566a03180186542256c02768be0d6 100644 (file)
@@ -33,8 +33,8 @@ const char *make_human_readable_str(unsigned long long size,
 {
        /* The code will adjust for additional (appended) units. */
        static const char zero_and_units[] = { '0', 0, 'k', 'M', 'G', 'T' };
-       static const char fmt[] = "%Lu";
-       static const char fmt_tenths[] = "%Lu.%d%c";
+       static const char fmt[] = "%llu";
+       static const char fmt_tenths[] = "%llu.%d%c";
 
        static char str[21];            /* Sufficient for 64 bit unsigned integers. */
 
@@ -74,7 +74,7 @@ const char *make_human_readable_str(unsigned long long size,
                        if ( frac >= 5 ) {
                                ++val;
                        }
-                       f = "%Lu%*c" /* fmt_no_tenths */ ;
+                       f = "%llu%*c" /* fmt_no_tenths */ ;
                        frac = 1;
                }
 #endif
index 0c395272fd70baab4f197ff7a56c85ec17ab6ad0..e1af2bf193cf1d4ef65de94d9411011732b015ee 100644 (file)
@@ -1038,23 +1038,23 @@ static char *get_name(char *name, char *p)
  * args. */
 
 /* static const char * const ss_fmt[] = { */
-/*     "%Ln%Lu%lu%lu%lu%lu%ln%ln%Ln%Lu%lu%lu%lu%lu%lu", */
-/*     "%Lu%Lu%lu%lu%lu%lu%ln%ln%Lu%Lu%lu%lu%lu%lu%lu", */
-/*     "%Lu%Lu%lu%lu%lu%lu%lu%lu%Lu%Lu%lu%lu%lu%lu%lu%lu" */
+/*     "%lln%llu%lu%lu%lu%lu%ln%ln%lln%llu%lu%lu%lu%lu%lu", */
+/*     "%llu%llu%lu%lu%lu%lu%ln%ln%llu%llu%lu%lu%lu%lu%lu", */
+/*     "%llu%llu%lu%lu%lu%lu%lu%lu%llu%llu%lu%lu%lu%lu%lu%lu" */
 /* }; */
 
        /* Lie about the size of the int pointed to for %n. */
 #if INT_MAX == LONG_MAX
 static const char * const ss_fmt[] = {
-       "%n%Lu%u%u%u%u%n%n%n%Lu%u%u%u%u%u",
-       "%Lu%Lu%u%u%u%u%n%n%Lu%Lu%u%u%u%u%u",
-       "%Lu%Lu%u%u%u%u%u%u%Lu%Lu%u%u%u%u%u%u"
+       "%n%llu%u%u%u%u%n%n%n%llu%u%u%u%u%u",
+       "%llu%llu%u%u%u%u%n%n%llu%llu%u%u%u%u%u",
+       "%llu%llu%u%u%u%u%u%u%llu%llu%u%u%u%u%u%u"
 };
 #else
 static const char * const ss_fmt[] = {
-       "%n%Lu%lu%lu%lu%lu%n%n%n%Lu%lu%lu%lu%lu%lu",
-       "%Lu%Lu%lu%lu%lu%lu%n%n%Lu%Lu%lu%lu%lu%lu%lu",
-       "%Lu%Lu%lu%lu%lu%lu%lu%lu%Lu%Lu%lu%lu%lu%lu%lu%lu"
+       "%n%llu%lu%lu%lu%lu%n%n%n%llu%lu%lu%lu%lu%lu",
+       "%llu%llu%lu%lu%lu%lu%n%n%llu%llu%lu%lu%lu%lu%lu",
+       "%llu%llu%lu%lu%lu%lu%lu%lu%llu%llu%lu%lu%lu%lu%lu%lu"
 };
 
 #endif
@@ -1748,7 +1748,7 @@ static void print_bytes_scaled(unsigned long long ull, const char *end)
 #endif
        } while (i);
 
-       printf("X bytes:%Lu (%Lu.%u %sB)%s", ull, int_part, frac_part, ext, end);
+       printf("X bytes:%llu (%llu.%u %sB)%s", ull, int_part, frac_part, ext, end);
 }
 
 static const char * const ife_print_flags_strs[] = {
@@ -1989,23 +1989,23 @@ static void ife_print(struct interface *ptr)
                 */
                printf("          ");
 
-               printf(_("RX packets:%Lu errors:%lu dropped:%lu overruns:%lu frame:%lu\n"),
+               printf("RX packets:%llu errors:%lu dropped:%lu overruns:%lu frame:%lu\n",
                           ptr->stats.rx_packets, ptr->stats.rx_errors,
                           ptr->stats.rx_dropped, ptr->stats.rx_fifo_errors,
                           ptr->stats.rx_frame_errors);
                if (can_compress)
-                       printf(_("             compressed:%lu\n"),
+                       printf("             compressed:%lu\n",
                                   ptr->stats.rx_compressed);
                printf("          ");
-               printf(_("TX packets:%Lu errors:%lu dropped:%lu overruns:%lu carrier:%lu\n"),
+               printf("TX packets:%llu errors:%lu dropped:%lu overruns:%lu carrier:%lu\n",
                           ptr->stats.tx_packets, ptr->stats.tx_errors,
                           ptr->stats.tx_dropped, ptr->stats.tx_fifo_errors,
                           ptr->stats.tx_carrier_errors);
-               printf(_("          collisions:%lu "), ptr->stats.collisions);
+               printf("          collisions:%lu "), ptr->stats.collisions;
                if (can_compress)
-                       printf(_("compressed:%lu "), ptr->stats.tx_compressed);
+                       printf("compressed:%lu ", ptr->stats.tx_compressed);
                if (ptr->tx_queue_len != -1)
-                       printf(_("txqueuelen:%d "), ptr->tx_queue_len);
+                       printf("txqueuelen:%d ", ptr->tx_queue_len);
                printf("\n          R");
                print_bytes_scaled(ptr->stats.rx_bytes, "  T");
                print_bytes_scaled(ptr->stats.tx_bytes, "\n");