Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion audio/decode/ad_lavc.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ static int receive_frame(struct mp_filter *da, struct mp_frame *out)
AVFrameSideData *sd =
av_frame_get_side_data(priv->avframe, AV_FRAME_DATA_SKIP_SAMPLES);
if (sd && sd->size >= 10) {
char *d = sd->data;
uint8_t *d = sd->data;
priv->skip_samples += AV_RL32(d + 0);
priv->trim_samples += AV_RL32(d + 4);
}
Expand Down
2 changes: 1 addition & 1 deletion audio/filter/af_lavcac3enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static void af_lavcac3enc_process(struct mp_filter *f)
uint8_t **planes = mp_aframe_get_data_rw(out);
if (!planes)
goto error;
char *buf = planes[0];
uint8_t *buf = planes[0];
memcpy(buf, hdr, header_len);
memcpy(buf + header_len, pkt->data, pkt->size);
memset(buf + header_len + pkt->size, 0,
Expand Down
2 changes: 1 addition & 1 deletion audio/filter/af_scaletempo.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ static void af_scaletempo_process(struct mp_filter *f)
uint8_t **out_planes = mp_aframe_get_data_rw(out);
if (!out_planes)
goto error;
int8_t *pout = out_planes[0];
uint8_t *pout = out_planes[0];
int out_offset = 0;
if (s->bytes_queued >= s->bytes_queue) {
int ti;
Expand Down
4 changes: 2 additions & 2 deletions audio/out/ao_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ static int init_device(struct ao *ao, int mode)

int num_channels = ao->channels.num;
err = snd_pcm_hw_params_set_channels_near
(p->alsa, alsa_hwparams, &num_channels);
(p->alsa, alsa_hwparams, (unsigned int *)&num_channels);
CHECK_ALSA_ERROR("Unable to set channels");
dump_hw_params(ao, "HW params after channels:\n", alsa_hwparams);

Expand All @@ -767,7 +767,7 @@ static int init_device(struct ao *ao, int mode)
}

err = snd_pcm_hw_params_set_rate_near
(p->alsa, alsa_hwparams, &ao->samplerate, NULL);
(p->alsa, alsa_hwparams, (unsigned int *)&ao->samplerate, NULL);
CHECK_ALSA_ERROR("Unable to set samplerate-2");
dump_hw_params(ao, "HW params after rate-2:\n", alsa_hwparams);

Expand Down
8 changes: 4 additions & 4 deletions common/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ char *mp_format_double(void *talloc_ctx, double val, int precision,
if (percent_sign)
bstr_xappend(talloc_ctx, &str, bstr0("%"));
str.start[str.len] = '\0';
return str.start;
return (char *)str.start;
}

// Set rc to the union of rc and rc2
Expand Down Expand Up @@ -231,7 +231,7 @@ void mp_append_utf8_bstr(void *talloc_ctx, struct bstr *buf, uint32_t codepoint)
uint8_t tmp;
char *output = data;
PUT_UTF8(codepoint, tmp, *output++ = tmp;);
bstr_xappend(talloc_ctx, buf, (bstr){data, output - data});
bstr_xappend(talloc_ctx, buf, (bstr){(unsigned char *)data, output - data});
}

// Parse a C/JSON-style escape beginning at code, and append the result to *str
Expand All @@ -257,7 +257,7 @@ static bool mp_parse_escape(void *talloc_ctx, bstr *dst, bstr *code)
case '\'': replace = '\''; break;
}
if (replace) {
bstr_xappend(talloc_ctx, dst, (bstr){&replace, 1});
bstr_xappend(talloc_ctx, dst, (bstr){(unsigned char *)&replace, 1});
*code = bstr_cut(*code, 1);
return true;
}
Expand All @@ -266,7 +266,7 @@ static bool mp_parse_escape(void *talloc_ctx, bstr *dst, bstr *code)
char c = bstrtoll(num, &num, 16);
if (num.len)
return false;
bstr_xappend(talloc_ctx, dst, (bstr){&c, 1});
bstr_xappend(talloc_ctx, dst, (bstr){(unsigned char *)&c, 1});
*code = bstr_cut(*code, 3);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion common/encode_lavc.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ static void encoder_2pass_prepare(struct encoder_context *p)
if (s) {
struct bstr content = stream_read_complete(s, p, 1000000000);
if (content.start) {
p->encoder->stats_in = content.start;
p->encoder->stats_in = (char *)content.start;
} else {
MP_WARN(p, "could not read '%s', "
"disabling 2-pass encoding at pass 1\n", filename);
Expand Down
2 changes: 1 addition & 1 deletion demux/demux.c
Original file line number Diff line number Diff line change
Expand Up @@ -4801,7 +4801,7 @@ static void visit_convert(void *ctx, void *ta, char **s)
bstr conv = mp_iconv_to_utf8(in->log, data, in->meta_charset,
MP_ICONV_VERBOSE);
if (conv.start && conv.start != data.start) {
char *ns = conv.start; // 0-termination is guaranteed
char *ns = (char *)conv.start; // 0-termination is guaranteed
// (The old string might not be an alloc, but if it is, it's a talloc
// child, and will not leak, even if it stays allocated uselessly.)
*s = ns;
Expand Down
2 changes: 1 addition & 1 deletion demux/demux_cue.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ static int try_open_file(struct demuxer *demuxer, enum demux_check check)
if (check >= DEMUX_CHECK_UNSAFE) {
char probe[PROBE_SIZE];
int len = stream_read_peek(s, probe, sizeof(probe));
if (len < 1 || !mp_probe_cue((bstr){probe, len}))
if (len < 1 || !mp_probe_cue((bstr){(unsigned char *)probe, len}))
return -1;
}
struct priv *p = talloc_zero(demuxer, struct priv);
Expand Down
2 changes: 1 addition & 1 deletion demux/demux_disc.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static void add_dvd_streams(demuxer_t *demuxer)
}
s = talloc_asprintf_append(s, "\n");

sh->codec->extradata = s;
sh->codec->extradata = (unsigned char *)s;
sh->codec->extradata_size = strlen(s);

demux_add_sh_stream(demuxer, sh);
Expand Down
2 changes: 1 addition & 1 deletion demux/demux_mf.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static mf_t *open_mf_pattern(void *talloc_ctx, struct demuxer *d, char *filename
int len = stream_read_peek(s, buf, sizeof(buf));
if (!len)
break;
bstr data = (bstr){buf, len};
bstr data = (bstr){(unsigned char *)buf, len};
int pos = bstrchr(data, '\n');
data = bstr_splice(data, 0, pos < 0 ? data.len : pos + 1);
bstr fname = bstr_strip(data);
Expand Down
4 changes: 2 additions & 2 deletions demux/demux_mkv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2131,7 +2131,7 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track, int idx)
if (track->private_size) {
extradata_len = track->private_size + 12;
extradata = talloc_size(sh_a, extradata_len);
char *data = extradata;
char *data = (char *)extradata;
AV_WB32(data + 0, extradata_len);
memcpy(data + 4, "alac", 4);
AV_WB32(data + 8, 0);
Expand All @@ -2142,7 +2142,7 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track, int idx)
extradata = talloc_zero_size(sh_a, extradata_len);
if (!extradata)
goto error;
char *data = extradata;
char *data = (char *)extradata;
memcpy(data + 0, "TTA1", 4);
AV_WL16(data + 4, 1);
AV_WL16(data + 6, sh_a->channels.num);
Expand Down
4 changes: 2 additions & 2 deletions demux/demux_playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static char *read_line(stream_t *s, char *mem, int max, int utf16)
int read = 0;
while (1) {
// Reserve 1 byte of ptr for terminating \0.
int l = read_characters(s, &mem[read], max - read - 1, utf16);
int l = read_characters(s, (uint8_t *)&mem[read], max - read - 1, utf16);
if (l < 0 || memchr(&mem[read], '\0', l)) {
MP_WARN(s, "error reading line\n");
return NULL;
Expand Down Expand Up @@ -252,7 +252,7 @@ static int parse_m3u(struct pl_parser *p)
bstr ext = mp_get_ext(bstr0(p->real_stream->url));
char probe[PROBE_SIZE];
int len = stream_read_peek(p->real_stream, probe, sizeof(probe));
bstr data = {probe, len};
bstr data = {(unsigned char *)probe, len};
if (ext.len && data.len >= 2 && maybe_text(data)) {
const char *exts[] = {"m3u", "m3u8", "strm", NULL};
for (int n = 0; exts[n]; n++) {
Expand Down
4 changes: 2 additions & 2 deletions demux/ebml.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target,
num_elems[i]);
break;
case EBML_TYPE_EBML_ID:
*(int32_t **) ptr = talloc_zero_array(ctx->talloc_ctx,
*(int32_t **) ptr = (int32_t *)talloc_zero_array(ctx->talloc_ctx,
uint32_t, num_elems[i]);
break;
default:
Expand Down Expand Up @@ -547,7 +547,7 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target,
}
char **strptr;
GETPTR(strptr, char *);
*strptr = talloc_strndup(ctx->talloc_ctx, data, length);
*strptr = talloc_strndup(ctx->talloc_ctx, (char *)data, length);
MP_TRACE(ctx, "string \"%s\"\n", *strptr);
break;

Expand Down
6 changes: 3 additions & 3 deletions fuzzers/fuzzer_loadfile_direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
return 0;

// Exclude data with null bytes inside
if (strlen(data) != size - 1)
if (strlen((const char *)data) != size - 1)
return 0;

#ifdef MPV_PROTO
if (!str_startswith(data, size - 1, MPV_STRINGIFY(MPV_PROTO) "://", sizeof(MPV_STRINGIFY(MPV_PROTO) "://") - 1))
if (!str_startswith((const char *)data, size - 1, MPV_STRINGIFY(MPV_PROTO) "://", sizeof(MPV_STRINGIFY(MPV_PROTO) "://") - 1))
return 0;
#endif

Expand All @@ -55,7 +55,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)

check_error(mpv_initialize(ctx));

const char *cmd[] = {"loadfile", data, NULL};
const char *cmd[] = {"loadfile", (const char *)data, NULL};
check_error(mpv_command(ctx, cmd));

player_loop(ctx);
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/fuzzer_set_property.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
switch (MPV_FORMAT)
{
case MPV_FORMAT_STRING:
value_len = strnlen(data, size);
value_len = strnlen((const char *)data, size);
if (!value_len || value_len == size)
return 0;
value_len += 1;
Expand Down
2 changes: 1 addition & 1 deletion input/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ static int pctx_read_token(struct parse_ctx *ctx, bstr *out)
if (ctx->start.len > 1 && bstr_eatstart0(&ctx->str, "`")) {
char endquote[2] = {ctx->str.start[0], '`'};
ctx->str = bstr_cut(ctx->str, 1);
int next = bstr_find(ctx->str, (bstr){endquote, 2});
int next = bstr_find(ctx->str, (bstr){(unsigned char *)endquote, 2});
if (next < 0) {
MP_ERR(ctx, "Unterminated custom quote: ...>%.*s<.\n", BSTR_P(start));
return -1;
Expand Down
2 changes: 1 addition & 1 deletion input/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ static mp_cmd_t *get_cmd_from_keys(struct input_ctx *ictx, bstr force_section,
if (MP_KEY_IS_UNICODE(code)) {
bstr text = {0};
mp_append_utf8_bstr(ret, &text, code);
ret->key_text = text.start;
ret->key_text = (char *)text.start;
}
ret->is_mouse_button = code & MP_KEY_EMIT_ON_UP;
} else {
Expand Down
4 changes: 2 additions & 2 deletions input/ipc-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static MP_THREAD_VOID client_thread(void *p)
int rc;

struct client_arg *arg = p;
bstr client_msg = { talloc_strdup(NULL, ""), 0 };
bstr client_msg = { (unsigned char *)talloc_strdup(NULL, ""), 0 };

char *tname = talloc_asprintf(NULL, "ipc/%s", arg->client_name);
mp_thread_set_name(tname);
Expand Down Expand Up @@ -163,7 +163,7 @@ static MP_THREAD_VOID client_thread(void *p)
if (fds[1].revents & (POLLIN | POLLHUP | POLLNVAL)) {
while (1) {
char buf[128];
bstr append = { buf, 0 };
bstr append = { (unsigned char *)buf, 0 };

ssize_t bytes = read(arg->client_fd, buf, sizeof(buf));
if (bytes < 0) {
Expand Down
4 changes: 2 additions & 2 deletions input/ipc-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static MP_THREAD_VOID client_thread(void *p)
char buf[4096];
HANDLE wakeup_event = CreateEventW(NULL, TRUE, FALSE, NULL);
OVERLAPPED ol = { .hEvent = CreateEventW(NULL, TRUE, TRUE, NULL) };
bstr client_msg = { talloc_strdup(NULL, ""), 0 };
bstr client_msg = { (unsigned char *)talloc_strdup(NULL, ""), 0 };
DWORD ioerr = 0;
DWORD r;

Expand Down Expand Up @@ -269,7 +269,7 @@ static MP_THREAD_VOID client_thread(void *p)
goto done;
}

bstr_xappend(NULL, &client_msg, (bstr){buf, r});
bstr_xappend(NULL, &client_msg, (bstr){(unsigned char *)buf, r});
while (bstrchr(client_msg, '\n') != -1) {
char *reply_msg = mp_ipc_consume_next_command(arg->client,
NULL, &client_msg);
Expand Down
6 changes: 3 additions & 3 deletions input/keycodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ int mp_input_get_key_from_name(const char *name)
while ((p = strchr(name, '+'))) {
for (const struct key_name *m = modifier_names; m->name; m++)
if (!bstrcasecmp(bstr0(m->name),
(struct bstr){(char *)name, p - name})) {
(struct bstr){(unsigned char *)name, p - name})) {
modifiers |= m->key;
goto found;
}
Expand Down Expand Up @@ -315,7 +315,7 @@ char *mp_input_get_key_name(int key)
{
bstr dst = {0};
mp_input_append_key_name(&dst, key);
return dst.start;
return (char *)dst.start;
}

char *mp_input_get_key_combo_name(const int *keys, int max)
Expand All @@ -328,7 +328,7 @@ char *mp_input_get_key_combo_name(const int *keys, int max)
else
break;
}
return dst.start;
return (char *)dst.start;
}

int mp_input_get_keys_from_string(char *name, int max_num_keys,
Expand Down
3 changes: 1 addition & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ test_flags = ['-Wdisabled-optimization',

test_flags_c = ['-Wmissing-prototypes',
'-Wstrict-prototypes',
'-Werror=implicit-function-declaration',
'-Wno-pointer-sign']
'-Werror=implicit-function-declaration']

flags += cc.get_supported_arguments(test_flags)
flags_c += cc.get_supported_arguments(test_flags_c)
Expand Down
12 changes: 6 additions & 6 deletions misc/bstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int bstrcasecmp(struct bstr str1, struct bstr str2)
{
int ret = 0;
if (str1.len && str2.len)
ret = strncasecmp(str1.start, str2.start, MPMIN(str1.len, str2.len));
ret = strncasecmp((char *)str1.start, (char *)str2.start, MPMIN(str1.len, str2.len));

if (!ret) {
if (str1.len == str2.len)
Expand Down Expand Up @@ -397,7 +397,7 @@ int bstr_xappend_vasprintf(void *talloc_ctx, bstr *s, const char *fmt,
va_list copy;
va_copy(copy, ap);
size_t avail = talloc_get_size(s->start) - s->len;
char *dest = s->start ? s->start + s->len : NULL;
char *dest = s->start ? (char *)(s->start + s->len) : NULL;
size = vsnprintf(dest, avail, fmt, copy);
va_end(copy);

Expand All @@ -406,7 +406,7 @@ int bstr_xappend_vasprintf(void *talloc_ctx, bstr *s, const char *fmt,

if (avail < 1 || size + 1 > avail) {
resize_append(talloc_ctx, s, size + 1);
vsnprintf(s->start + s->len, size + 1, fmt, ap);
vsnprintf((char *)(s->start + s->len), size + 1, fmt, ap);
}
s->len += size;
return size;
Expand Down Expand Up @@ -457,7 +457,7 @@ bool bstr_decode_hex(void *talloc_ctx, struct bstr hex, struct bstr *out)
arr[len++] = (a << 4) | b;
}

*out = (struct bstr){ .start = arr, .len = len };
*out = (struct bstr){ .start = (unsigned char *)arr, .len = len };
return true;
}

Expand All @@ -481,13 +481,13 @@ bool bstr_in_list0(struct bstr str, char **list)

int bstr_to_wchar(void *talloc_ctx, struct bstr s, wchar_t **ret)
{
int count = MultiByteToWideChar(CP_UTF8, 0, s.start, s.len, NULL, 0);
int count = MultiByteToWideChar(CP_UTF8, 0, (const char *)s.start, s.len, NULL, 0);
if (count <= 0)
abort();
wchar_t *wbuf = *ret;
if (!wbuf || ta_get_size(wbuf) < (count + 1) * sizeof(wchar_t))
wbuf = talloc_realloc(talloc_ctx, wbuf, wchar_t, count + 1);
MultiByteToWideChar(CP_UTF8, 0, s.start, s.len, wbuf, count);
MultiByteToWideChar(CP_UTF8, 0, (const char *)s.start, s.len, wbuf, count);
wbuf[count] = L'\0';
*ret = wbuf;
return count;
Expand Down
6 changes: 3 additions & 3 deletions misc/charset_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static const char *mp_uchardet(void *talloc_ctx, struct mp_log *log, bstr buf)
uchardet_t det = uchardet_new();
if (!det)
return NULL;
if (uchardet_handle_data(det, buf.start, buf.len) != 0) {
if (uchardet_handle_data(det, (char *)buf.start, buf.len) != 0) {
uchardet_delete(det);
return NULL;
}
Expand Down Expand Up @@ -180,7 +180,7 @@ bstr mp_iconv_to_utf8(struct mp_log *log, bstr buf, const char *cp, int flags)
size_t oleft = size - 1;

char *outbuf = talloc_size(NULL, osize);
char *ip = buf.start;
char *ip = (char *)buf.start;
char *op = outbuf;

while (1) {
Expand Down Expand Up @@ -222,7 +222,7 @@ bstr mp_iconv_to_utf8(struct mp_log *log, bstr buf, const char *cp, int flags)
iconv_close(icdsc);

outbuf[osize - oleft - 1] = 0;
return (bstr){outbuf, osize - oleft - 1};
return (bstr){(unsigned char *)outbuf, osize - oleft - 1};

failure:
#endif
Expand Down
Loading
Loading