mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-23 15:18:35 +00:00
Minor code fixes. (#489)
* Minor code fixes. * Switch logging macros to functions.
This commit is contained in:
parent
4b92556fca
commit
a9e968956d
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ void clean_up(void *memtofree1, void *memtofree2);
|
||||
void clean_up_without_threads(void *memtofree1, void *memtofree2);
|
||||
|
||||
template <typename... Args>
|
||||
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 <typename... Args>
|
||||
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 <typename... Args>
|
||||
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 <typename... Args>
|
||||
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 <typename... Args>
|
||||
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 <typename... Args>
|
||||
void DBGP(const char *format, Args &&... args) {
|
||||
__DBGP(0, format, args...);
|
||||
}
|
||||
template <typename... Args>
|
||||
void DBGP2(const char *format, Args &&... args) {
|
||||
__DBGP(1, format, args...);
|
||||
}
|
||||
|
||||
#endif /* _LOGGING_H */
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user