]> mj.ucw.cz Git - libucw.git/commitdiff
Hunted down a dozen of damned printf cast bugs.
authorMartin Mares <mj@ucw.cz>
Fri, 2 Feb 2007 11:55:28 +0000 (12:55 +0100)
committerMartin Mares <mj@ucw.cz>
Fri, 2 Feb 2007 11:55:28 +0000 (12:55 +0100)
Condemned eternally be the man who gave C precise types, but no formatting
sequences for printing them.

lib/conf-dump.c
lib/profile.c
lib/shell/config.c

index c4ac16bb076f847ff1a83c282429871057694894..f4af30ac626514b0e883403b80274005807c866e 100644 (file)
@@ -27,7 +27,7 @@ dump_basic(struct fastbuf *fb, void *ptr, enum cf_type type, union cf_union *u)
 {
   switch (type) {
     case CT_INT:       bprintf(fb, "%d ", *(uns*)ptr); break;
-    case CT_U64:       bprintf(fb, "%llu ", *(u64*)ptr); break;
+    case CT_U64:       bprintf(fb, "%llu ", (long long) *(u64*)ptr); break;
     case CT_DOUBLE:    bprintf(fb, "%lg ", *(double*)ptr); break;
     case CT_IP:                bprintf(fb, "%08x ", *(uns*)ptr); break;
     case CT_STRING:
index feed51f5567a728636ae51ac013e2b584df75c6a..0bd25aa9fc41cc5378a5bfa4563703c6f58b168d 100644 (file)
@@ -97,7 +97,7 @@ prof_ktsc_init(struct prof_ktsc *c)
 void
 prof_ktsc_switch(struct prof_ktsc *o, struct prof_ktsc *n)
 {
-  u64 u, s;
+  unsigned long long u, s;
   byte buf[256];
 
   int l = pread(self_prof_fd, buf, sizeof(buf)-1, 0);
@@ -123,7 +123,7 @@ prof_ktsc_switch(struct prof_ktsc *o, struct prof_ktsc *n)
 int
 prof_ktsc_format(char *buf, struct prof_ktsc *c)
 {
-  return sprintf(buf, "%Ld+%Ld", c->ticks_user, c->ticks_sys);
+  return sprintf(buf, "%Ld+%Ld", (long long) c->ticks_user, (long long) c->ticks_sys);
 }
 
 #endif
index 02d89dd854a6e6464bb60ff6b662283fbc325742..e1bcc0521cafd1f6004339bd3fb79964db2db8cb 100644 (file)
@@ -346,7 +346,7 @@ dump_value(uns array, struct item *item, void *v)
         sprintf(buf, "%d", *(int *)v);
         break;
       case CT_U64:
-        sprintf(buf, "%Lu", *(u64 *)v);
+        sprintf(buf, "%Lu", (long long) *(u64 *)v);
        break;
       case CT_DOUBLE:
        sprintf(buf, "%g", *(double *)v);