diff options
| author | Craig Barnes <craigbarnes@protonmail.com> | 2020-08-07 19:42:34 +0000 |
|---|---|---|
| committer | Craig Barnes <craigbarnes@protonmail.com> | 2020-08-07 19:42:34 +0000 |
| commit | 7eb70a453b4ea797d9e85017c6deab6a7bc903a6 (patch) | |
| tree | 265282027801e799b9a4a3afba074c868689b49e | |
| parent | Merge branch 'syslog' into master (diff) | |
Replace GCC "unused" and "format" attributes with portable macros
| -rw-r--r-- | config.c | 3 | ||||
| -rw-r--r-- | input.c | 4 | ||||
| -rw-r--r-- | log.c | 3 | ||||
| -rw-r--r-- | log.h | 7 | ||||
| -rw-r--r-- | macros.h | 6 | ||||
| -rw-r--r-- | shm.c | 3 | ||||
| -rw-r--r-- | terminal.c | 2 |
7 files changed, 18 insertions, 10 deletions
@@ -20,6 +20,7 @@ #define LOG_ENABLE_DBG 0 #include "log.h" #include "input.h" +#include "macros.h" #include "tokenize.h" #include "util.h" #include "wayland.h" @@ -1111,7 +1112,7 @@ parse_config_file(FILE *f, struct config *conf, const char *path, bool errors_ar /* Split up into key/value pair + trailing comment */ char *key_value = strtok(line, "#"); - char *comment __attribute__((unused)) = strtok(NULL, "\n"); + char UNUSED *comment = strtok(NULL, "\n"); /* Check for new section */ if (key_value[0] == '[') { @@ -26,6 +26,7 @@ #include "config.h" #include "commands.h" #include "keymap.h" +#include "macros.h" #include "quirks.h" #include "render.h" #include "search.h" @@ -1116,8 +1117,7 @@ wl_pointer_leave(void *data, struct wl_pointer *wl_pointer, } else { if (surface != NULL) { /* Sway 1.4 sends this event with a NULL surface when we destroy the window */ - const struct wl_window *win __attribute__((unused)) - = wl_surface_get_user_data(surface); + const struct wl_window UNUSED *win = wl_surface_get_user_data(surface); assert(old_moused == win->term); } @@ -79,8 +79,7 @@ _log(enum log_class log_class, const char *module, const char *file, int lineno, static void _sys_log(enum log_class log_class, const char *module, - const char *file __attribute__((unused)), - int lineno __attribute__((unused)), + const char UNUSED *file, int UNUSED lineno, const char *fmt, int sys_errno, va_list va) { if (!do_syslog) @@ -1,5 +1,6 @@ #pragma once #include <stdbool.h> +#include "macros.h" enum log_colorize { LOG_COLORIZE_NEVER, LOG_COLORIZE_ALWAYS, LOG_COLORIZE_AUTO }; enum log_facility { LOG_FACILITY_USER, LOG_FACILITY_DAEMON }; @@ -11,16 +12,16 @@ void log_deinit(void); void log_msg(enum log_class log_class, const char *module, const char *file, int lineno, - const char *fmt, ...) __attribute__((format (printf, 5, 6))); + const char *fmt, ...) PRINTF(5); void log_errno(enum log_class log_class, const char *module, const char *file, int lineno, - const char *fmt, ...) __attribute__((format (printf, 5, 6))); + const char *fmt, ...) PRINTF(5); void log_errno_provided( enum log_class log_class, const char *module, const char *file, int lineno, int _errno, - const char *fmt, ...) __attribute__((format (printf, 6, 7))); + const char *fmt, ...) PRINTF(6); #define LOG_ERR(fmt, ...) \ log_msg(LOG_CLASS_ERROR, LOG_MODULE, __FILE__, __LINE__, fmt, ## __VA_ARGS__) @@ -20,6 +20,12 @@ #define HAS_BUILTIN(x) 0 #endif +#if GNUC_AT_LEAST(3, 0) || HAS_ATTRIBUTE(unused) || defined(__TINYC__) + #define UNUSED __attribute__((__unused__)) +#else + #define UNUSED +#endif + #if GNUC_AT_LEAST(3, 0) || HAS_ATTRIBUTE(malloc) #define MALLOC __attribute__((__malloc__)) #else @@ -22,6 +22,7 @@ #define LOG_MODULE "shm" #define LOG_ENABLE_DBG 0 #include "log.h" +#include "macros.h" #define TIME_SCROLL 0 @@ -398,7 +399,7 @@ static bool wrap_buffer(struct wl_shm *shm, struct buffer *buf, off_t new_offset) { /* We don't allow overlapping offsets */ - off_t diff __attribute__((unused)) = + off_t UNUSED diff = new_offset < buf->offset ? buf->offset - new_offset : new_offset - buf->offset; assert(diff > buf->size); @@ -1032,7 +1032,7 @@ fdm_shutdown(struct fdm *fdm, int fd, int events, void *data) wayl_win_destroy(term->window); term->window = NULL; - struct wayland *wayl __attribute__((unused)) = term->wl; + struct wayland *wayl = term->wl; /* * Normally we'd get unmapped when we destroy the Wayland |
