mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-22 10:57:08 +00:00
various: add MP prefix for {PRINTF,SCANF}_ATTRIBUTE
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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, ...)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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, ...)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user