diff --git a/src/conky.cc b/src/conky.cc index fe218469..8c58b7f7 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -3161,7 +3161,7 @@ char load_config_file(const char *f) err = 1; } if (err) { - CONF_ERR2("default_bar_size takes 2 integer arguments (ie. 'default_bar_size 0 6')") + CONF_ERR2("default_bar_size takes 2 integer arguments (ie. 'default_bar_size 0 6')"); } } #ifdef BUILD_X11 @@ -3175,7 +3175,7 @@ char load_config_file(const char *f) err = 1; } if (err) { - CONF_ERR2("default_graph_size takes 2 integer arguments (ie. 'default_graph_size 0 6')") + CONF_ERR2("default_graph_size takes 2 integer arguments (ie. 'default_graph_size 0 6')"); } } CONF("default_gauge_size") { @@ -3188,7 +3188,7 @@ char load_config_file(const char *f) err = 1; } if (err) { - CONF_ERR2("default_gauge_size takes 2 integer arguments (ie. 'default_gauge_size 0 6')") + CONF_ERR2("default_gauge_size takes 2 integer arguments (ie. 'default_gauge_size 0 6')"); } } #endif diff --git a/src/logging.h b/src/logging.h index 2ea6db43..d58709e5 100644 --- a/src/logging.h +++ b/src/logging.h @@ -30,17 +30,27 @@ #ifndef _LOGGING_H #define _LOGGING_H +#include #include #include "mail.h" void clean_up(void *memtofree1, void* memtofree2); void clean_up_without_threads(void *memtofree1, void* memtofree2); -#define NORM_ERR(format, args...) { \ +template +void gettextize_format(const char *format, Args&&... args) +{ fprintf(stderr, gettext(format), args...); } + +// explicit specialization for no arguments to avoid the +// "format not a string literal and no format arguments" warning +inline void gettextize_format(const char *format) +{ fputs(gettext(format), stderr); } + +#define NORM_ERR(...) do { \ fprintf(stderr, PACKAGE_NAME": "); \ - fprintf(stderr, gettext(format), ##args); \ - fprintf(stderr, "\n"); \ -} + gettextize_format(__VA_ARGS__); \ + fputs("\n", stderr); \ +} while(0) /* critical error */ #define CRIT_ERR(memtofree1, memtofree2, ...) \ @@ -51,12 +61,13 @@ void clean_up_without_threads(void *memtofree1, void* memtofree2); /* debugging output */ extern int global_debug_level; -#define __DBGP(level, format, args...) \ +#define __DBGP(level, ...) do {\ if (global_debug_level > level) { \ fprintf(stderr, "DEBUG(%d) [" __FILE__ ":%d]: ", level, __LINE__); \ - fprintf(stderr, gettext(format), ##args); \ - fprintf(stderr, "\n"); \ - } + gettextize_format(__VA_ARGS__); \ + fputs("\n", stderr); \ + } \ +} while(0) #define DBGP(...) __DBGP(0, __VA_ARGS__) #define DBGP2(...) __DBGP(1, __VA_ARGS__) diff --git a/src/timed-thread.cc b/src/timed-thread.cc index e85d405d..b27da658 100644 --- a/src/timed-thread.cc +++ b/src/timed-thread.cc @@ -24,9 +24,7 @@ * */ -#ifdef HAVE_CONFIG_H #include -#endif #include #include @@ -79,7 +77,7 @@ timed_thread::timed_thread(const std::function &start_rou { #ifdef DEBUG - assert(interval_usecs >= MINIMUM_INTERVAL_USECS); + assert(interval_usecs >= std::chrono::microseconds(MINIMUM_INTERVAL_USECS)); #endif /* DEBUG */ /* create thread pipe (used to tell threads to die) */ diff --git a/src/user.cc b/src/user.cc index 49d9e398..5add413c 100644 --- a/src/user.cc +++ b/src/user.cc @@ -28,6 +28,8 @@ * */ +#include + #include "logging.h" #include #include @@ -50,10 +52,10 @@ void print_uid_name(struct text_object *obj, char *p, int p_max_size) { if(pw != NULL) { snprintf(p, p_max_size, "%s", pw->pw_name); } else { - NORM_ERR("The uid %d doesn't exist", uid) + NORM_ERR("The uid %d doesn't exist", uid); } } else { - NORM_ERR("$uid_name didn't receive a uid as argument") + NORM_ERR("$uid_name didn't receive a uid as argument"); } } @@ -72,9 +74,9 @@ void print_gid_name(struct text_object *obj, char *p, int p_max_size) { if(grp != NULL) { snprintf(p, p_max_size, "%s", grp->gr_name); } else { - NORM_ERR("The gid %d doesn't exist", gid) + NORM_ERR("The gid %d doesn't exist", gid); } } else { - NORM_ERR("$gid_name didn't receive a gid as argument") + NORM_ERR("$gid_name didn't receive a gid as argument"); } }