From: Martin Mares Date: Fri, 2 Feb 2007 11:55:28 +0000 (+0100) Subject: Hunted down a dozen of damned printf cast bugs. X-Git-Tag: holmes-import~506^2~109^2~4 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=21f2455e1e9f211a194cef708e3878f7a6495895;p=libucw.git Hunted down a dozen of damned printf cast bugs. Condemned eternally be the man who gave C precise types, but no formatting sequences for printing them. --- diff --git a/lib/conf-dump.c b/lib/conf-dump.c index c4ac16bb..f4af30ac 100644 --- a/lib/conf-dump.c +++ b/lib/conf-dump.c @@ -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: diff --git a/lib/profile.c b/lib/profile.c index feed51f5..0bd25aa9 100644 --- a/lib/profile.c +++ b/lib/profile.c @@ -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 diff --git a/lib/shell/config.c b/lib/shell/config.c index 02d89dd8..e1bcc052 100644 --- a/lib/shell/config.c +++ b/lib/shell/config.c @@ -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);