diff --git a/common/common.h b/common/common.h index 75083c4ea9..0bdccad737 100644 --- a/common/common.h +++ b/common/common.h @@ -142,7 +142,7 @@ uint32_t mp_round_next_power_of_2(uint32_t v); int mp_lcm(int x, int y); int mp_snprintf_cat(char *str, size_t size, const char *format, ...) - PRINTF_ATTRIBUTE(3, 4); + MP_PRINTF_ATTRIBUTE(3, 4); struct bstr; @@ -165,7 +165,7 @@ char *mp_tag_str_buf(char *buf, size_t buf_size, uint32_t tag); #define mp_tprintf(SIZE, format, ...) \ mp_tprintf_buf((char[SIZE]){0}, (SIZE), (format), __VA_ARGS__) char *mp_tprintf_buf(char *buf, size_t buf_size, const char *format, ...) - PRINTF_ATTRIBUTE(3, 4); + MP_PRINTF_ATTRIBUTE(3, 4); char **mp_dup_str_array(void *tctx, char **s); diff --git a/common/msg.h b/common/msg.h index f27b470623..61ae28d906 100644 --- a/common/msg.h +++ b/common/msg.h @@ -54,9 +54,9 @@ struct mp_log *mp_log_new(void *talloc_ctx, struct mp_log *parent, const char *name); void mp_msg(struct mp_log *log, int lev, const char *format, ...) - PRINTF_ATTRIBUTE(3, 4); + MP_PRINTF_ATTRIBUTE(3, 4); void mp_msg_va(struct mp_log *log, int lev, const char *format, va_list va) - PRINTF_ATTRIBUTE(3, 0); + MP_PRINTF_ATTRIBUTE(3, 0); int mp_msg_level(struct mp_log *log); diff --git a/misc/bstr.h b/misc/bstr.h index 887d5cafd3..c54a9cbbf0 100644 --- a/misc/bstr.h +++ b/misc/bstr.h @@ -79,7 +79,7 @@ struct bstr bstr_splice(struct bstr str, int start, int end); long long bstrtoll(struct bstr str, struct bstr *rest, int base); double bstrtod(struct bstr str, struct bstr *rest); void bstr_lower(struct bstr str); -int bstr_sscanf(struct bstr str, const char *format, ...) SCANF_ATTRIBUTE(2, 3); +int bstr_sscanf(struct bstr str, const char *format, ...) MP_SCANF_ATTRIBUTE(2, 3); // Decode a string containing hexadecimal data. All whitespace will be silently // ignored. When successful, this allocates a new array to store the output. @@ -171,7 +171,7 @@ static inline void bstr_xappend0(void *talloc_ctx, bstr *s, const char *append) * or a negative value on error. */ int bstr_xappend_asprintf(void *talloc_ctx, bstr *s, const char *fmt, ...) - PRINTF_ATTRIBUTE(3, 4); + MP_PRINTF_ATTRIBUTE(3, 4); /** * @brief Append a formatted string to the existing bstr using a va_list. @@ -187,7 +187,7 @@ int bstr_xappend_asprintf(void *talloc_ctx, bstr *s, const char *fmt, ...) * or a negative value on error. */ int bstr_xappend_vasprintf(void *talloc_ctx, bstr *s, const char *fmt, va_list va) - PRINTF_ATTRIBUTE(3, 0); + MP_PRINTF_ATTRIBUTE(3, 0); // If s starts/ends with prefix, return true and return the rest of the string // in s. diff --git a/osdep/compiler.h b/osdep/compiler.h index f5bcaf2a83..845214c6e5 100644 --- a/osdep/compiler.h +++ b/osdep/compiler.h @@ -37,19 +37,19 @@ #endif #if defined(__GNUC__) || defined(__clang__) -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__((format(printf, a1, a2))) -#define SCANF_ATTRIBUTE(a1, a2) __attribute__((format(scanf, a1, a2))) +#define MP_PRINTF_ATTRIBUTE(a1, a2) __attribute__((format(printf, a1, a2))) +#define MP_SCANF_ATTRIBUTE(a1, a2) __attribute__((format(scanf, a1, a2))) #define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), __builtin_unreachable()) #else -#define PRINTF_ATTRIBUTE(a1, a2) -#define SCANF_ATTRIBUTE(a1, a2) +#define MP_PRINTF_ATTRIBUTE(a1, a2) +#define MP_SCANF_ATTRIBUTE(a1, a2) #define MP_ASSERT_UNREACHABLE() (assert(!"unreachable"), abort()) #endif // Broken crap with __USE_MINGW_ANSI_STDIO #if defined(__MINGW32__) && defined(__GNUC__) && !defined(__clang__) -#undef PRINTF_ATTRIBUTE -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (gnu_printf, a1, a2))) +#undef MP_PRINTF_ATTRIBUTE +#define MP_PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (gnu_printf, a1, a2))) #endif #endif diff --git a/osdep/io.c b/osdep/io.c index 5167b104a9..fcaa635d50 100644 --- a/osdep/io.c +++ b/osdep/io.c @@ -327,14 +327,14 @@ size_t mp_fwrite(const void *restrict buffer, size_t size, size_t count, } #if HAVE_UWP -PRINTF_ATTRIBUTE(2, 0) +MP_PRINTF_ATTRIBUTE(2, 0) static int mp_vfprintf(FILE *stream, const char *format, va_list args) { return vfprintf(stream, format, args); } #else -PRINTF_ATTRIBUTE(2, 0) +MP_PRINTF_ATTRIBUTE(2, 0) static int mp_vfprintf(FILE *stream, const char *format, va_list args) { HANDLE wstream = get_handle(stream); diff --git a/osdep/io.h b/osdep/io.h index 4024454a31..ab1e298f7f 100644 --- a/osdep/io.h +++ b/osdep/io.h @@ -111,8 +111,8 @@ char *mp_to_utf8(void *talloc_ctx, const wchar_t *s); size_t mp_fwrite(const void *restrict buffer, size_t size, size_t count, FILE *restrict stream); -int mp_printf(const char *format, ...) PRINTF_ATTRIBUTE(1, 2); -int mp_fprintf(FILE *stream, const char *format, ...) PRINTF_ATTRIBUTE(2, 3); +int mp_printf(const char *format, ...) MP_PRINTF_ATTRIBUTE(1, 2); +int mp_fprintf(FILE *stream, const char *format, ...) MP_PRINTF_ATTRIBUTE(2, 3); int mp_open(const char *filename, int oflag, ...); int mp_creat(const char *filename, int mode); int mp_rename(const char *oldpath, const char *newpath); diff --git a/osdep/terminal-dummy.c b/osdep/terminal-dummy.c index 5a01e5b7d1..76409cc9c2 100644 --- a/osdep/terminal-dummy.c +++ b/osdep/terminal-dummy.c @@ -27,7 +27,7 @@ void terminal_get_size2(int *rows, int *cols, int *px_width, int *px_height) { } -PRINTF_ATTRIBUTE(2, 0) +MP_PRINTF_ATTRIBUTE(2, 0) int mp_console_vfprintf(void *wstream, const char *format, va_list args) { return 0; diff --git a/osdep/terminal.h b/osdep/terminal.h index ab3c3424c1..b37dcfcd82 100644 --- a/osdep/terminal.h +++ b/osdep/terminal.h @@ -66,7 +66,7 @@ void terminal_set_mouse_input(bool enable); // Windows only. int mp_console_vfprintf(void *wstream, const char *format, va_list args) - PRINTF_ATTRIBUTE(2, 0); + MP_PRINTF_ATTRIBUTE(2, 0); int mp_console_write(void *wstream, bstr str); bool mp_check_console(void *handle); diff --git a/player/command.h b/player/command.h index 9a24b2d7af..d1183829e0 100644 --- a/player/command.h +++ b/player/command.h @@ -77,7 +77,7 @@ void run_command(struct MPContext *mpctx, struct mp_cmd *cmd, void *on_completion_priv); void run_command_opts(struct MPContext *mpctx); void mp_cmd_ctx_complete(struct mp_cmd_ctx *cmd); -PRINTF_ATTRIBUTE(3, 4) +MP_PRINTF_ATTRIBUTE(3, 4) void mp_cmd_msg(struct mp_cmd_ctx *cmd, int status, const char *msg, ...); char *mp_property_expand_string(struct MPContext *mpctx, const char *str); char *mp_property_expand_escaped_string(struct MPContext *mpctx, const char *str); diff --git a/player/core.h b/player/core.h index 9498e68ff8..8d935c0181 100644 --- a/player/core.h +++ b/player/core.h @@ -585,7 +585,7 @@ const char *mp_find_non_filename_media_title(MPContext *mpctx); void set_osd_bar(struct MPContext *mpctx, int type, double min, double max, double neutral, double val); bool set_osd_msg(struct MPContext *mpctx, int level, int time, - const char* fmt, ...) PRINTF_ATTRIBUTE(4,5); + const char* fmt, ...) MP_PRINTF_ATTRIBUTE(4,5); void set_osd_function(struct MPContext *mpctx, int osd_function); void term_osd_clear_subs(struct MPContext *mpctx); void term_osd_set_subs(struct MPContext *mpctx, const char *text, int order); diff --git a/player/osd.c b/player/osd.c index 4a2952f3fa..ac65f62c87 100644 --- a/player/osd.c +++ b/player/osd.c @@ -306,7 +306,7 @@ static void term_osd_print_status_lazy(struct MPContext *mpctx) talloc_free(line); } -PRINTF_ATTRIBUTE(4, 0) +MP_PRINTF_ATTRIBUTE(4, 0) static bool set_osd_msg_va(struct MPContext *mpctx, int level, int time, const char *fmt, va_list ap) { diff --git a/sub/ass_mp.c b/sub/ass_mp.c index 4cbebc872a..c8b1bd05d6 100644 --- a/sub/ass_mp.c +++ b/sub/ass_mp.c @@ -115,7 +115,7 @@ static const int map_ass_level[] = { MSGL_TRACE, // 7 "verbose DEBUG" }; -PRINTF_ATTRIBUTE(2, 0) +MP_PRINTF_ATTRIBUTE(2, 0) static void message_callback(int level, const char *format, va_list va, void *ctx) { struct mp_log *log = ctx; diff --git a/test/libmpv_common.h b/test/libmpv_common.h index 8b251eecf1..50e2c84ddb 100644 --- a/test/libmpv_common.h +++ b/test/libmpv_common.h @@ -37,7 +37,7 @@ // Global handle. static mpv_handle *ctx; -MP_NORETURN PRINTF_ATTRIBUTE(1, 2) +MP_NORETURN MP_PRINTF_ATTRIBUTE(1, 2) static inline void fail(const char *fmt, ...) { diff --git a/test/test_utils.h b/test/test_utils.h index fbe83c3e05..b51fb7adef 100644 --- a/test/test_utils.h +++ b/test/test_utils.h @@ -48,7 +48,7 @@ FILE *test_open_out(const char *outdir, const char *name); // just define these as stubs that do nothing. struct mp_log; void mp_msg(struct mp_log *log, int lev, const char *format, ...) - PRINTF_ATTRIBUTE(3, 4); + MP_PRINTF_ATTRIBUTE(3, 4); int mp_msg_find_level(const char *s); int mp_msg_level(struct mp_log *log); void mp_msg_set_max_level(struct mp_log *log, int lev); diff --git a/video/out/gpu/shader_cache.h b/video/out/gpu/shader_cache.h index 7c51c7aead..098cfbef39 100644 --- a/video/out/gpu/shader_cache.h +++ b/video/out/gpu/shader_cache.h @@ -18,13 +18,13 @@ bool gl_sc_error_state(struct gl_shader_cache *sc); void gl_sc_reset_error(struct gl_shader_cache *sc); void gl_sc_add(struct gl_shader_cache *sc, const char *text); void gl_sc_addf(struct gl_shader_cache *sc, const char *textf, ...) - PRINTF_ATTRIBUTE(2, 3); + MP_PRINTF_ATTRIBUTE(2, 3); void gl_sc_hadd(struct gl_shader_cache *sc, const char *text); void gl_sc_haddf(struct gl_shader_cache *sc, const char *textf, ...) - PRINTF_ATTRIBUTE(2, 3); + MP_PRINTF_ATTRIBUTE(2, 3); void gl_sc_hadd_bstr(struct gl_shader_cache *sc, struct bstr text); void gl_sc_paddf(struct gl_shader_cache *sc, const char *textf, ...) - PRINTF_ATTRIBUTE(2, 3); + MP_PRINTF_ATTRIBUTE(2, 3); // A hint that the next data-type (i.e. non-binding) uniform is expected to // change frequently. This refers to the _f, _i, _vecN etc. uniform types. @@ -34,7 +34,7 @@ void gl_sc_uniform_texture(struct gl_shader_cache *sc, char *name, void gl_sc_uniform_image2D_wo(struct gl_shader_cache *sc, const char *name, struct ra_tex *tex); void gl_sc_ssbo(struct gl_shader_cache *sc, char *name, struct ra_buf *buf, - char *format, ...) PRINTF_ATTRIBUTE(4, 5); + char *format, ...) MP_PRINTF_ATTRIBUTE(4, 5); void gl_sc_uniform_f(struct gl_shader_cache *sc, char *name, float f); void gl_sc_uniform_i(struct gl_shader_cache *sc, char *name, int f); void gl_sc_uniform_vec2(struct gl_shader_cache *sc, char *name, float f[2]); diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index b994d186cb..dd06c6763f 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -1147,7 +1147,7 @@ static void pass_record(struct gl_video *p, const struct mp_pass_perf *perf) p->pass_idx++; } -PRINTF_ATTRIBUTE(2, 3) +MP_PRINTF_ATTRIBUTE(2, 3) static void pass_describe(struct gl_video *p, const char *textf, ...) { if (!p->pass || p->pass_idx == VO_PASS_PERF_MAX) diff --git a/video/out/vo_kitty.c b/video/out/vo_kitty.c index 8a8ac32c18..4ddeec4f7b 100644 --- a/video/out/vo_kitty.c +++ b/video/out/vo_kitty.c @@ -135,7 +135,7 @@ static inline void append_passthrough(struct priv *p, bstr *bs, bstr append) bstr_xappend(p, bs, p->dcs_suffix); } -PRINTF_ATTRIBUTE(3, 4) +MP_PRINTF_ATTRIBUTE(3, 4) static inline void append_asprintf_passthrough(struct priv *p, bstr *bs, const char *fmt, ...) {