diff --git a/src/core.cc b/src/core.cc index db19e86a..8b010d92 100644 --- a/src/core.cc +++ b/src/core.cc @@ -2067,7 +2067,7 @@ int extract_variable_text_internal(struct text_object *retval, } catch (obj_create_error &e) { free(buf); free(orig_p); - throw e; + throw; } if (obj != nullptr) { append_object(retval, obj); diff --git a/src/imlib2.cc b/src/imlib2.cc index bd2773a6..4f376c18 100644 --- a/src/imlib2.cc +++ b/src/imlib2.cc @@ -285,10 +285,7 @@ void cimlib_render(int x, int y, int width, int height) { imlib_free_image(); } -void print_image_callback(struct text_object *obj, char *p, - int p_max_size) { - p = p; // just a trick to make the compiler happy about this being non-const - (void)p_max_size; - +void print_image_callback(struct text_object *obj, char *, + int) { cimlib_add_image(obj->data.s); } diff --git a/src/logging.h b/src/logging.h index b2a6ad16..143f349b 100644 --- a/src/logging.h +++ b/src/logging.h @@ -65,7 +65,7 @@ void clean_up(void *memtofree1, void *memtofree2); void clean_up_without_threads(void *memtofree1, void *memtofree2); template -void gettextize_format(const char *format, Args &&... args) { +inline void gettextize_format(const char *format, Args &&... args) { fprintf(stderr, _(format), args...); } @@ -73,27 +73,29 @@ void gettextize_format(const char *format, Args &&... args) { // "format not a string literal and no format arguments" warning inline void gettextize_format(const char *format) { fputs(_(format), stderr); } -#define NORM_ERR(...) \ - do { \ - fprintf(stderr, PACKAGE_NAME ": "); \ - gettextize_format(__VA_ARGS__); \ - fputs("\n", stderr); \ - } while (0) +template +void NORM_ERR(const char *format, Args &&... args) { + fprintf(stderr, PACKAGE_NAME ": "); + gettextize_format(format, args...); + fputs("\n", stderr); +} /* critical error */ -#define CRIT_ERR(memtofree1, memtofree2, ...) \ - { \ - NORM_ERR(__VA_ARGS__); \ - clean_up(memtofree1, memtofree2); \ - exit(EXIT_FAILURE); \ - } +template +inline void CRIT_ERR(void *memtofree1, void *memtofree2, const char *format, + Args &&... args) { + NORM_ERR(format, args...); + clean_up(memtofree1, memtofree2); + exit(EXIT_FAILURE); +} -#define THREAD_CRIT_ERR(memtofree1, memtofree2, ...) \ - { \ - NORM_ERR(__VA_ARGS__); \ - clean_up_without_threads(memtofree1, memtofree2); \ - return; \ - } +template +inline void THREAD_CRIT_ERR(void *memtofree1, void *memtofree2, + const char *format, Args &&... args) { + NORM_ERR(format, args...); + clean_up_without_threads(memtofree1, memtofree2); + return; +} namespace conky { class error : public std::runtime_error { @@ -104,15 +106,21 @@ class error : public std::runtime_error { /* debugging output */ extern int global_debug_level; -#define __DBGP(level, ...) \ - do { \ - if (global_debug_level > level) { \ - fprintf(stderr, "DEBUG(%d) [" __FILE__ ":%d]: ", level, __LINE__); \ - gettextize_format(__VA_ARGS__); \ - fputs("\n", stderr); \ - } \ - } while (0) -#define DBGP(...) __DBGP(0, __VA_ARGS__) -#define DBGP2(...) __DBGP(1, __VA_ARGS__) +template +inline void __DBGP(const int level, const char *format, Args &&... args) { + if (global_debug_level > level) { + fprintf(stderr, "DEBUG(%d) [" __FILE__ ":%d]: ", level, __LINE__); + gettextize_format(format, args...); + fputs("\n", stderr); + } +} +template +void DBGP(const char *format, Args &&... args) { + __DBGP(0, format, args...); +} +template +void DBGP2(const char *format, Args &&... args) { + __DBGP(1, format, args...); +} #endif /* _LOGGING_H */ diff --git a/src/text_object.cc b/src/text_object.cc index ec46103e..e69bb211 100644 --- a/src/text_object.cc +++ b/src/text_object.cc @@ -37,15 +37,12 @@ void gen_free_opaque(struct text_object *obj) { free_and_zero(obj->data.opaque); } -int gen_false_iftest(struct text_object *obj) { - (void)obj; +int gen_false_iftest(struct text_object *) { return 0; } -void gen_print_nothing(struct text_object *obj, char *p, int p_max_size) { - (void)obj; - p = p; // just a trick to make the compiler happy about this being non-const - (void)p_max_size; +void gen_print_nothing(struct text_object *, char *, int) { + // literally does nothing } void gen_print_obj_data_s(struct text_object *obj, char *p, int p_max_size) {