mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-08-08 00:51:39 +00:00
all: Don't discard const through {mem,str,strr}chr
C23 made these generic functions that no longer cast const away for you, leading to warnings when compiling with C23 and a recent enough toolchain (glibc supports this since 2.43). This commit fixes all the warnings that can simply be fixed by adding const, without adding casts. (the latter excludes parse_forced_key_frames() in ffmpeg_mux_init.c). Reviewed-by: Kacper Michajłow <kasper93@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -70,7 +70,7 @@ static const char *json_escape_str(AVBPrint *dst, const char *src, void *log_ctx
|
||||
}
|
||||
|
||||
for (p = src; *p; p++) {
|
||||
char *s = strchr(json_escape, *p);
|
||||
const char *s = strchr(json_escape, *p);
|
||||
if (s) {
|
||||
av_bprint_chars(dst, '\\', 1);
|
||||
av_bprint_chars(dst, json_subst[s - json_escape], 1);
|
||||
|
||||
@@ -75,7 +75,7 @@ static void handle_open_brace(AVBPrint *dst, const char **inp, int *an, int *clo
|
||||
if (!*closing_brace_missing) {
|
||||
if ( (*an != 1 && in[1] == '\\')
|
||||
|| (in[1] && strchr("CcFfoPSsYy", in[1]) && in[2] == ':')) {
|
||||
char *bracep = strchr(in+2, '}');
|
||||
const char *bracep = strchr(in+2, '}');
|
||||
if (bracep) {
|
||||
*inp = bracep;
|
||||
return;
|
||||
@@ -204,7 +204,7 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in)
|
||||
|
||||
if (scantag(in+tag_close+1, buffer, &len) && len > 0) {
|
||||
const int skip = len + tag_close;
|
||||
const char *tagname = buffer;
|
||||
char *tagname = buffer;
|
||||
while (*tagname == ' ') {
|
||||
likely_a_tag = 0;
|
||||
tagname++;
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
static int indexof(const char *s, int c)
|
||||
{
|
||||
char *f = strchr(s, c);
|
||||
const char *f = strchr(s, c);
|
||||
return f ? (f - s) : -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ retry:
|
||||
sync = bs;
|
||||
c = *bs++;
|
||||
if (c == '#') {
|
||||
uint8_t *match = memchr(bs, '\n', end-bs);
|
||||
const uint8_t *match = memchr(bs, '\n', end-bs);
|
||||
if (match)
|
||||
bs = match + 1;
|
||||
else
|
||||
|
||||
@@ -114,11 +114,11 @@ static void append_inout(AVFilterInOut **inouts, AVFilterInOut **element)
|
||||
|
||||
static int parse_sws_flags(const char **buf, char **dst, void *log_ctx)
|
||||
{
|
||||
char *p = strchr(*buf, ';');
|
||||
|
||||
if (strncmp(*buf, "sws_flags=", 10))
|
||||
return 0;
|
||||
|
||||
const char *p = strchr(*buf, ';');
|
||||
|
||||
if (!p) {
|
||||
av_log(log_ctx, AV_LOG_ERROR, "sws_flags not terminated with ';'.\n");
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
@@ -682,14 +682,13 @@ static int match_stream_specifier(const AVFormatContext *s, const AVStream *st,
|
||||
return match && (stream_id == st->id);
|
||||
} else if (*spec == 'm' && *(spec + 1) == ':') {
|
||||
const AVDictionaryEntry *tag;
|
||||
char *key, *val;
|
||||
int ret;
|
||||
|
||||
if (match) {
|
||||
spec += 2;
|
||||
val = strchr(spec, ':');
|
||||
const char *val = strchr(spec, ':');
|
||||
|
||||
key = val ? av_strndup(spec, val - spec) : av_strdup(spec);
|
||||
char *key = val ? av_strndup(spec, val - spec) : av_strdup(spec);
|
||||
if (!key)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt,
|
||||
char *semi;
|
||||
av_opt_get(pb, "mime_type", AV_OPT_SEARCH_CHILDREN, &mime_type_opt);
|
||||
pd.mime_type = (const char *)mime_type_opt;
|
||||
semi = pd.mime_type ? strchr(pd.mime_type, ';') : NULL;
|
||||
semi = pd.mime_type ? strchr(mime_type_opt, ';') : NULL;
|
||||
if (semi) {
|
||||
*semi = '\0';
|
||||
}
|
||||
|
||||
@@ -1057,7 +1057,8 @@ static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies)
|
||||
{
|
||||
AVDictionary *new_params = NULL;
|
||||
const AVDictionaryEntry *e, *cookie_entry;
|
||||
char *eql, *name;
|
||||
const char *eql;
|
||||
char *name;
|
||||
|
||||
// ensure the cookie is parsable
|
||||
if (parse_set_cookie(p, &new_params))
|
||||
|
||||
@@ -252,18 +252,13 @@ char *av_strireplace(const char *str, const char *from, const char *to)
|
||||
|
||||
const char *av_basename(const char *path)
|
||||
{
|
||||
char *p;
|
||||
#if HAVE_DOS_PATHS
|
||||
char *q, *d;
|
||||
#endif
|
||||
|
||||
if (!path || *path == '\0')
|
||||
return ".";
|
||||
|
||||
p = strrchr(path, '/');
|
||||
const char *p = strrchr(path, '/');
|
||||
#if HAVE_DOS_PATHS
|
||||
q = strrchr(path, '\\');
|
||||
d = strchr(path, ':');
|
||||
const char *q = strrchr(path, '\\');
|
||||
const char *d = strchr(path, ':');
|
||||
p = FFMAX3(p, q, d);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -402,8 +402,8 @@ int av_channel_layout_from_string(AVChannelLayout *channel_layout,
|
||||
return ret;
|
||||
|
||||
if (ret >= 0) {
|
||||
end = strchr(str, ')');
|
||||
if (matches == 2 && (nb_channels != channel_layout->nb_channels || !end || *++end)) {
|
||||
const char *end_par = strchr(str, ')');
|
||||
if (matches == 2 && (nb_channels != channel_layout->nb_channels || !end_par || *++end_par)) {
|
||||
av_channel_layout_uninit(channel_layout);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
@@ -749,7 +749,7 @@ int av_channel_layout_index_from_channel(const AVChannelLayout *channel_layout,
|
||||
int av_channel_layout_index_from_string(const AVChannelLayout *channel_layout,
|
||||
const char *str)
|
||||
{
|
||||
char *chname;
|
||||
const char *chname;
|
||||
enum AVChannel ch = AV_CHAN_NONE;
|
||||
|
||||
switch (channel_layout->order) {
|
||||
|
||||
@@ -283,16 +283,14 @@ char *av_strdup(const char *s)
|
||||
|
||||
char *av_strndup(const char *s, size_t len)
|
||||
{
|
||||
char *ret = NULL, *end;
|
||||
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
end = memchr(s, 0, len);
|
||||
const char *end = memchr(s, 0, len);
|
||||
if (end)
|
||||
len = end - s;
|
||||
|
||||
ret = av_realloc(NULL, len + 1);
|
||||
char *ret = av_realloc(NULL, len + 1);
|
||||
if (!ret)
|
||||
return NULL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user