Fix printf() specified bugs all over the code
authorDavid Herrmann <dh.herrmann@googlemail.com>
Sun, 30 Sep 2012 16:01:35 +0000 (18:01 +0200)
committerDavid Herrmann <dh.herrmann@googlemail.com>
Sun, 30 Sep 2012 16:01:35 +0000 (18:01 +0200)
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 <dh.herrmann@googlemail.com>
src/conf.c
src/eloop.c
src/log.c
src/pty.c
src/terminal.c
src/text_gltex.c
src/tsm_screen.c
src/uterm_input.c
src/wlt_toolkit.c

index ed9b593..c69026a 100644 (file)
@@ -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;
        }
index 7762a27..3badbbc 100644 (file)
  */
 
 #include <errno.h>
+#include <inttypes.h>
 #include <pthread.h>
 #include <signal.h>
 #include <stdbool.h>
@@ -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;
index 1fcd774..583ddd0 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -512,6 +512,6 @@ void log_print_init(const char *appname)
        if (!appname)
                appname = "<unknown>";
        log_format(LOG_DEFAULT_CONF, NULL, LOG_NOTICE,
-                       "%s Build #%u %s %s", appname,
+                       "%s Build #%lu %s %s", appname,
                        log_build, __DATE__, __TIME__);
 }
index 87ac930..bcd832f 100644 (file)
--- a/src/pty.c
+++ b/src/pty.c
@@ -25,6 +25,7 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <inttypes.h>
 #include <pthread.h>
 #include <pty.h>
 #include <signal.h>
@@ -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);
 
index 526f34b..d73df10 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include <errno.h>
+#include <inttypes.h>
 #include <stdlib.h>
 #include <string.h>
 #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));
index c3ffcbd..b589271 100644 (file)
@@ -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;
 
index fc96576..8677448 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <errno.h>
+#include <inttypes.h>
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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);
 }
index 405ffc0..ad5b6a9 100644 (file)
@@ -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 */
index 4f73c3e..dc15864 100644 (file)
@@ -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;
        }