From 32faedbfb446fe9b9b0ad58f1c312bb2097052b2 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Sun, 30 Sep 2012 18:01:35 +0200 Subject: [PATCH] Fix printf() specified bugs all over the code When enabling the printf() logic for the logging subsystem, several warnings were produced about missing or wrong specifiers. This fixes all those occurrences. Signed-off-by: David Herrmann --- src/conf.c | 4 ++-- src/eloop.c | 7 ++++--- src/log.c | 2 +- src/pty.c | 3 ++- src/terminal.c | 7 ++++--- src/text_gltex.c | 2 +- src/tsm_screen.c | 3 ++- src/uterm_input.c | 2 +- src/wlt_toolkit.c | 2 +- 9 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/conf.c b/src/conf.c index ed9b593..c69026a 100644 --- a/src/conf.c +++ b/src/conf.c @@ -213,13 +213,13 @@ int conf_parse_argv(struct conf_option *opts, size_t len, short_options = malloc(sizeof(char) * (len + 1) * 2); if (!short_options) { - log_error("cannot allocate enough memory to parse command line arguments (%d): %m"); + log_error("cannot allocate enough memory to parse command line arguments (%d): %m", errno); return -ENOMEM; } long_options = malloc(sizeof(struct option) * len * 2); if (!long_options) { - log_error("cannot allocate enough memory to parse command line arguments (%d): %m"); + log_error("cannot allocate enough memory to parse command line arguments (%d): %m", errno); free(short_options); return -ENOMEM; } diff --git a/src/eloop.c b/src/eloop.c index 7762a27..3badbbc 100644 --- a/src/eloop.c +++ b/src/eloop.c @@ -158,6 +158,7 @@ */ #include +#include #include #include #include @@ -505,14 +506,14 @@ static int write_eventfd(llog_submit_t llog, int fd, uint64_t val) return llog_dEINVAL(llog); if (val == 0xffffffffffffffffULL) { - llog_dwarning(llog, "increasing counter with invalid value %llu", val); + llog_dwarning(llog, "increasing counter with invalid value %" PRIu64, val); return -EINVAL;; } ret = write(fd, &val, sizeof(val)); if (ret < 0) { if (errno == EAGAIN) - llog_dwarning(llog, "eventfd overflow while writing %llu", val); + llog_dwarning(llog, "eventfd overflow while writing %" PRIu64, val); else llog_dwarning(llog, "eventfd write error (%d): %m", errno); return -EFAULT; @@ -846,7 +847,7 @@ int ev_eloop_dispatch(struct ev_eloop *loop, int timeout) ep = realloc(loop->cur_fds, sizeof(struct epoll_event) * loop->cur_fds_size * 2); if (!ep) { - llog_warning(loop, "cannot reallocate dispatch cache to size %u", + llog_warning(loop, "cannot reallocate dispatch cache to size %zu", loop->cur_fds_size * 2); } else { loop->cur_fds = ep; diff --git a/src/log.c b/src/log.c index 1fcd774..583ddd0 100644 --- a/src/log.c +++ b/src/log.c @@ -512,6 +512,6 @@ void log_print_init(const char *appname) if (!appname) appname = ""; log_format(LOG_DEFAULT_CONF, NULL, LOG_NOTICE, - "%s Build #%u %s %s", appname, + "%s Build #%lu %s %s", appname, log_build, __DATE__, __TIME__); } diff --git a/src/pty.c b/src/pty.c index 87ac930..bcd832f 100644 --- a/src/pty.c +++ b/src/pty.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -438,7 +439,7 @@ static void sig_child(struct ev_eloop *eloop, struct signalfd_siginfo *info, if (info->ssi_pid != pty->child) return; - log_info("child exited: pid: %u status: %d utime: %llu stime: %llu", + log_info("child exited: pid: %u status: %d utime: %" PRIu64 " stime: %" PRIu64, info->ssi_pid, info->ssi_status, info->ssi_utime, info->ssi_stime); diff --git a/src/terminal.c b/src/terminal.c index 526f34b..d73df10 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -31,6 +31,7 @@ */ #include +#include #include #include #include "eloop.h" @@ -65,7 +66,7 @@ struct kmscon_terminal { unsigned int min_cols; unsigned int min_rows; - unsigned int fps; + unsigned long fps; unsigned int redraw; struct ev_timer *redraw_timer; struct tsm_screen *console; @@ -119,7 +120,7 @@ static void redraw_timer_event(struct ev_timer *timer, uint64_t num, void *data) * ev_timer_enable/disable() all the time. */ if (num > 1) - log_debug("CPU is too slow; skipping %llu frames", num - 1); + log_debug("CPU is too slow; skipping %" PRIu64 " frames", num - 1); if (term->redraw-- != term->fps) { if (!term->redraw) { @@ -203,7 +204,7 @@ static int add_display(struct kmscon_terminal *term, struct uterm_display *disp) scr = malloc(sizeof(*scr)); if (!scr) { - log_error("cannot allocate memory for display %p"); + log_error("cannot allocate memory for display %p", disp); return -ENOMEM; } memset(scr, 0, sizeof(*scr)); diff --git a/src/text_gltex.c b/src/text_gltex.c index c3ffcbd..b589271 100644 --- a/src/text_gltex.c +++ b/src/text_gltex.c @@ -323,7 +323,7 @@ try_next: goto err_tex; } - log_debug("new atlas of size %ux%u for %u", width, height, newsize); + log_debug("new atlas of size %ux%u for %zu", width, height, newsize); nsize = txt->cols * txt->rows; diff --git a/src/tsm_screen.c b/src/tsm_screen.c index fc96576..8677448 100644 --- a/src/tsm_screen.c +++ b/src/tsm_screen.c @@ -32,6 +32,7 @@ */ #include +#include #include #include #include @@ -1405,7 +1406,7 @@ void tsm_screen_draw(struct tsm_screen *con, if (con->opts & TSM_SCREEN_OPT_RENDER_TIMING) llog_debug(con, - "timing: sum: %llu prepare: %llu draw: %llu render: %llu", + "timing: sum: %" PRIu64 " prepare: %" PRIu64 " draw: %" PRIu64 " render: %" PRIu64, time_prep + time_draw + time_rend, time_prep, time_draw, time_rend); } diff --git a/src/uterm_input.c b/src/uterm_input.c index 405ffc0..ad5b6a9 100644 --- a/src/uterm_input.c +++ b/src/uterm_input.c @@ -151,7 +151,7 @@ static int input_wake_up_dev(struct uterm_input_dev *dev) &ledbits); if (ret == -1) log_warn("cannot read LED state of %s (%d): %m", - errno, dev->node); + dev->node, errno); } /* rediscover the keyboard state if sth changed during sleep */ diff --git a/src/wlt_toolkit.c b/src/wlt_toolkit.c index 4f73c3e..dc15864 100644 --- a/src/wlt_toolkit.c +++ b/src/wlt_toolkit.c @@ -901,7 +901,7 @@ int wlt_display_new(struct wlt_display **out, dp_global, disp); if (!disp->dp_listener) { - log_error("cannot add wayland global listener (%d)"); + log_error("cannot add wayland global listener (%d)", errno); goto err_timer; }