This is an automated email from the git hooks/post-receive script.
Git pushed a commit to branch master
in repository ffmpeg.
The following commit(s) were added to refs/heads/master by this push:
new 97cbffe917 all: Don't discard const through {mem,str,strr}chr
97cbffe917 is described below
commit 97cbffe9172f1614af56363022f560700fa0c36b
Author: Andreas Rheinhardt <[email protected]>
AuthorDate: Fri Jul 3 15:48:32 2026 +0200
Commit: Andreas Rheinhardt <[email protected]>
CommitDate: Sun Jul 5 09:02:40 2026 +0200
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 <[email protected]>
Signed-off-by: Andreas Rheinhardt <[email protected]>
---
fftools/textformat/tf_json.c | 2 +-
libavcodec/htmlsubtitles.c | 4 ++--
libavcodec/microdvddec.c | 2 +-
libavcodec/pnm_parser.c | 2 +-
libavfilter/graphparser.c | 4 ++--
libavformat/avformat.c | 5 ++---
libavformat/format.c | 2 +-
libavformat/http.c | 3 ++-
libavutil/avstring.c | 11 +++--------
libavutil/channel_layout.c | 6 +++---
libavutil/mem.c | 6 ++----
11 files changed, 20 insertions(+), 27 deletions(-)
diff --git a/fftools/textformat/tf_json.c b/fftools/textformat/tf_json.c
index 7980a41fda..e9b0c6498c 100644
--- a/fftools/textformat/tf_json.c
+++ b/fftools/textformat/tf_json.c
@@ -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);
diff --git a/libavcodec/htmlsubtitles.c b/libavcodec/htmlsubtitles.c
index 8ce66e0b27..63c871fac7 100644
--- a/libavcodec/htmlsubtitles.c
+++ b/libavcodec/htmlsubtitles.c
@@ -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++;
diff --git a/libavcodec/microdvddec.c b/libavcodec/microdvddec.c
index 55e892562c..4065fd0257 100644
--- a/libavcodec/microdvddec.c
+++ b/libavcodec/microdvddec.c
@@ -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;
}
diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c
index 27030f8512..f32398efd0 100644
--- a/libavcodec/pnm_parser.c
+++ b/libavcodec/pnm_parser.c
@@ -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
diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c
index a23e26d2e3..d97cc87449 100644
--- a/libavfilter/graphparser.c
+++ b/libavfilter/graphparser.c
@@ -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);
diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index bb574e0c7b..0f9d50a99d 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -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);
diff --git a/libavformat/format.c b/libavformat/format.c
index 83aa980a15..45f382c2a1 100644
--- a/libavformat/format.c
+++ b/libavformat/format.c
@@ -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';
}
diff --git a/libavformat/http.c b/libavformat/http.c
index e9941a414f..719d3c2ef5 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -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))
diff --git a/libavutil/avstring.c b/libavutil/avstring.c
index 281c5cdc88..1487297cba 100644
--- a/libavutil/avstring.c
+++ b/libavutil/avstring.c
@@ -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
diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index 4f18047df3..bd4aabaaa8 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -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) {
diff --git a/libavutil/mem.c b/libavutil/mem.c
index b205d3fb25..e8e5f5f2e2 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -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;
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]