mirror of https://github.com/mpv-player/mpv
various: add more format specifiers checks
This commit is contained in:
parent
0db6abadd4
commit
7fb7e1dd73
|
@ -51,7 +51,8 @@ struct mp_log *mp_log_new(void *talloc_ctx, struct mp_log *parent,
|
||||||
|
|
||||||
void mp_msg(struct mp_log *log, int lev, const char *format, ...)
|
void mp_msg(struct mp_log *log, int lev, const char *format, ...)
|
||||||
PRINTF_ATTRIBUTE(3, 4);
|
PRINTF_ATTRIBUTE(3, 4);
|
||||||
void mp_msg_va(struct mp_log *log, int lev, const char *format, va_list va);
|
void mp_msg_va(struct mp_log *log, int lev, const char *format, va_list va)
|
||||||
|
PRINTF_ATTRIBUTE(3, 0);
|
||||||
|
|
||||||
int mp_msg_level(struct mp_log *log);
|
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);
|
long long bstrtoll(struct bstr str, struct bstr *rest, int base);
|
||||||
double bstrtod(struct bstr str, struct bstr *rest);
|
double bstrtod(struct bstr str, struct bstr *rest);
|
||||||
void bstr_lower(struct bstr str);
|
void bstr_lower(struct bstr str);
|
||||||
int bstr_sscanf(struct bstr str, const char *format, ...);
|
int bstr_sscanf(struct bstr str, const char *format, ...) SCANF_ATTRIBUTE(2, 3);
|
||||||
|
|
||||||
// Decode a string containing hexadecimal data. All whitespace will be silently
|
// Decode a string containing hexadecimal data. All whitespace will be silently
|
||||||
// ignored. When successful, this allocates a new array to store the output.
|
// ignored. When successful, this allocates a new array to store the output.
|
||||||
|
|
|
@ -5,11 +5,13 @@
|
||||||
|
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format(printf, a1, a2)))
|
#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format(printf, a1, a2)))
|
||||||
|
#define SCANF_ATTRIBUTE(a1, a2) __attribute__ ((format(scanf, a1, a2)))
|
||||||
#define MP_NORETURN __attribute__((noreturn))
|
#define MP_NORETURN __attribute__((noreturn))
|
||||||
#define MP_FALLTHROUGH __attribute__((fallthrough))
|
#define MP_FALLTHROUGH __attribute__((fallthrough))
|
||||||
#define MP_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
#define MP_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||||||
#else
|
#else
|
||||||
#define PRINTF_ATTRIBUTE(a1, a2)
|
#define PRINTF_ATTRIBUTE(a1, a2)
|
||||||
|
#define SCANF_ATTRIBUTE(a1, a2)
|
||||||
#define MP_NORETURN
|
#define MP_NORETURN
|
||||||
#define MP_FALLTHROUGH do {} while (0)
|
#define MP_FALLTHROUGH do {} while (0)
|
||||||
#define MP_WARN_UNUSED_RESULT
|
#define MP_WARN_UNUSED_RESULT
|
||||||
|
|
|
@ -332,12 +332,14 @@ size_t mp_fwrite(const void *restrict buffer, size_t size, size_t count,
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_UWP
|
#if HAVE_UWP
|
||||||
|
PRINTF_ATTRIBUTE(2, 0)
|
||||||
static int mp_vfprintf(FILE *stream, const char *format, va_list args)
|
static int mp_vfprintf(FILE *stream, const char *format, va_list args)
|
||||||
{
|
{
|
||||||
return vfprintf(stream, format, args);
|
return vfprintf(stream, format, args);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
PRINTF_ATTRIBUTE(2, 0)
|
||||||
static int mp_vfprintf(FILE *stream, const char *format, va_list args)
|
static int mp_vfprintf(FILE *stream, const char *format, va_list args)
|
||||||
{
|
{
|
||||||
HANDLE wstream = get_handle(stream);
|
HANDLE wstream = get_handle(stream);
|
||||||
|
|
|
@ -27,6 +27,7 @@ void terminal_get_size2(int *rows, int *cols, int *px_width, int *px_height)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRINTF_ATTRIBUTE(2, 0)
|
||||||
int mp_console_vfprintf(void *wstream, const char *format, va_list args)
|
int mp_console_vfprintf(void *wstream, const char *format, va_list args)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -62,7 +62,8 @@ void terminal_get_size2(int *rows, int *cols, int *px_width, int *px_height);
|
||||||
void terminal_set_mouse_input(bool enable);
|
void terminal_set_mouse_input(bool enable);
|
||||||
|
|
||||||
// Windows only.
|
// Windows only.
|
||||||
int mp_console_vfprintf(void *wstream, const char *format, va_list args);
|
int mp_console_vfprintf(void *wstream, const char *format, va_list args)
|
||||||
|
PRINTF_ATTRIBUTE(2, 0);
|
||||||
int mp_console_write(void *wstream, bstr str);
|
int mp_console_write(void *wstream, bstr str);
|
||||||
bool mp_check_console(void *handle);
|
bool mp_check_console(void *handle);
|
||||||
|
|
||||||
|
|
|
@ -296,6 +296,7 @@ static void term_osd_print_status_lazy(struct MPContext *mpctx)
|
||||||
talloc_free(line);
|
talloc_free(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRINTF_ATTRIBUTE(4, 0)
|
||||||
static bool set_osd_msg_va(struct MPContext *mpctx, int level, int time,
|
static bool set_osd_msg_va(struct MPContext *mpctx, int level, int time,
|
||||||
const char *fmt, va_list ap)
|
const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
|
|
|
@ -121,6 +121,7 @@ static const int map_ass_level[] = {
|
||||||
MSGL_TRACE, // 7 "verbose DEBUG"
|
MSGL_TRACE, // 7 "verbose DEBUG"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PRINTF_ATTRIBUTE(2, 0)
|
||||||
static void message_callback(int level, const char *format, va_list va, void *ctx)
|
static void message_callback(int level, const char *format, va_list va, void *ctx)
|
||||||
{
|
{
|
||||||
struct mp_log *log = ctx;
|
struct mp_log *log = ctx;
|
||||||
|
|
|
@ -168,6 +168,7 @@ bool ta_strndup_append_buffer(char **str, const char *a, size_t n)
|
||||||
return strndup_append_at(str, size, a, n);
|
return strndup_append_at(str, size, a, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TA_PRF(3, 0)
|
||||||
static bool ta_vasprintf_append_at(char **str, size_t at, const char *fmt,
|
static bool ta_vasprintf_append_at(char **str, size_t at, const char *fmt,
|
||||||
va_list ap)
|
va_list ap)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue