[vlc-commits] [Git][videolan/vlc][master] 19 commits: misc: mime: fix const correctness
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Jun 5 12:16:12 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
41a29bb4 by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
misc: mime: fix const correctness
../../src/misc/mime.c: In function ‘vlc_mime_Ext2Mime’:
../../src/misc/mime.c:97:13: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
97 | psz_ext = strrchr( psz_url, '.' );
| ^
- - - - -
1a70361c by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
config: getopt: fix const correctness
../../src/config/getopt.c: In function ‘vlc_getopt_long’:
../../src/config/getopt.c:336:22: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
336 | char *temp = strchr(optstring, c);
| ^~~~~~
- - - - -
cb817f1f by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
url: fix const correctness
This needs a bit of refactor given that the variables were re-used in
both const context and non-const context.
../../src/text/url.c: In function ‘vlc_uri2path’:
../../src/text/url.c:275:18: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
275 | char *path = strstr (url, "://");
| ^~~~~~
../../src/text/url.c:279:9: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
279 | end = memchr (url, '/', path - url);
| ^
- - - - -
8a38cc06 by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
cdrom: const correctness
../../modules/access/vcd/cdrom.c: In function ‘OpenVCDImage’:
../../modules/access/vcd/cdrom.c:799:11: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
799 | p_pos = strrchr( psz_dev, '.' );
| ^
- - - - -
d0bbe4f4 by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
input: return NULL on memory allocation failure
- - - - -
fe6d9e4f by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
input: fix const correctness
../../src/input/input.c: In function ‘input_SubtitleFile2Uri’:
../../src/input/input.c:3599:27: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
3599 | char *psz_extension = strrchr( psz_subtitle, '.');
| ^~~~~~~
- - - - -
10e9393d by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
keystore: early return
- - - - -
71dd5f39 by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
keystore: fix const correctness
../../src/misc/keystore.c:274:23: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
274 | char *psz_delim = strchr(p_credential->psz_username, ';');
| ^~~~~~
- - - - -
164cc0ff by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
misc: actions: fix const correctness
../../src/misc/messages.c: In function ‘vlc_vaLog’:
../../src/misc/messages.c:126:15: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
126 | char *p = strrchr(module, '/');
| ^~~~~~~
- - - - -
76b26406 by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
messages: fix const correctness
../../src/misc/messages.c: In function ‘vlc_vaLog’:
../../src/misc/messages.c:126:15: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
126 | char *p = strrchr(module, '/');
| ^~~~~~~
../../src/misc/messages.c:129:7: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
129 | p = strchr(module, '.');
| ^
- - - - -
c83da7bf by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
v4l2: controls: fix const correctness
../../modules/access/v4l2/controls.c: In function ‘ControlsSetFromString’:
../../modules/access/v4l2/controls.c:241:13: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
241 | end = strchr (name, '=');
| ^
- - - - -
a60f76fe by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
dvb: scan_list: fix const correctness
../../modules/access/dvb/scan_list.c: In function ‘scan_list_dvbv5_load’:
../../modules/access/dvb/scan_list.c:325:35: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
325 | char *p_end = strstr( p, "]" );
| ^~~~~~
- - - - -
026d6cd6 by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
pulse: fix const correctness
../../modules/audio_output/pulse.c: In function ‘str_map’:
../../modules/audio_output/pulse.c:880:23: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
880 | const char **r = bsearch(key, table, n, sizeof (*table), strcmp_void);
| ^~~~~~~
- - - - -
16c3fcf3 by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
channel_mixer: remap: fix const correctness
../../modules/audio_filter/channel_mixer/remap.c: In function ‘OpenFilter’:
../../modules/audio_filter/channel_mixer/remap.c:301:30: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
301 | uint8_t *pi_chnidx = memchr( channel_wg4idx, wg4_i, channel_wg4idx_len );
| ^~~~~~
- - - - -
d6f0ec2d by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
subsusf: fix const correctness
../../modules/codec/subsusf.c: In function ‘GrabAttributeValue’:
../../modules/codec/subsusf.c:283:29: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
283 | char *psz_tag_end = strchr( psz_tag_start, '>' );
| ^~~~~~
- - - - -
36e59444 by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
codec: ttml: fix const correctness
../../modules/codec/ttml/ttml.c: In function ‘tt_timings_FindLowerIndex’:
../../modules/codec/ttml/ttml.c:573:29: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
573 | tt_time_t *lookup = bsearch( &key, p_times, i_times,
| ^~~~~~~
- - - - -
9d892d40 by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
gstreamer: fourcc: fix const correctness
../../modules/codec/gstreamer/fourcc.c: In function ‘GetGstVLCFourcc’:
../../modules/codec/gstreamer/fourcc.c:86:11: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
86 | found = bsearch( gst, raw_video_fmts,
| ^
- - - - -
85e6c671 by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
stream_out: rtpfmt: fix const correctness
../../modules/stream_out/rtpfmt.c: In function ‘rtp_packetize_xiph_config’:
../../modules/stream_out/rtpfmt.c:721:19: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
721 | char *start = strstr(fmtp, "configuration=");
| ^~~~~~
- - - - -
8f92a2d4 by Alexandre Janniaux at 2026-06-05T11:46:03+00:00
rtp: sdp: fix const correctness
This needs a bit of refactoring because the port_end was then re-used
into strtoul as the char **str_end parameter. Instead of reusing, we
introduce a new port_cur cursor pointer to track the numerical end of
the port value.
../../modules/access/rtp/sdp.c: In function ‘vlc_sdp_media_parse’:
../../modules/access/rtp/sdp.c:185:22: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
185 | char *port_end = memchr(port, ' ', end - port);
| ^~~~~~
- - - - -
18 changed files:
- modules/access/dvb/scan_list.c
- modules/access/rtp/sdp.c
- modules/access/v4l2/controls.c
- modules/access/vcd/cdrom.c
- modules/audio_filter/channel_mixer/remap.c
- modules/audio_output/pulse.c
- modules/codec/gstreamer/fourcc.c
- modules/codec/subsusf.c
- modules/codec/ttml/ttml.c
- modules/codec/ttml/ttml.h
- modules/stream_out/rtpfmt.c
- src/config/getopt.c
- src/input/input.c
- src/misc/actions.c
- src/misc/keystore.c
- src/misc/messages.c
- src/misc/mime.c
- src/text/url.c
Changes:
=====================================
modules/access/dvb/scan_list.c
=====================================
@@ -322,7 +322,7 @@ scan_list_entry_t * scan_list_dvbv5_load( vlc_object_t *p_obj, const char *psz_s
}
else
{
- char *p_end = strstr( p, "]" );
+ const char *p_end = strstr( p, "]" );
if( !p_end )
b_error = true;
else
=====================================
modules/access/rtp/sdp.c
=====================================
@@ -182,18 +182,19 @@ bad:
}
const char *port = media_end + 1;
- char *port_end = memchr(port, ' ', end - port);
+ const char *port_end = memchr(port, ' ', end - port);
if (port_end == NULL)
goto bad;
const char *proto = port_end + 1;
- unsigned long port_start = strtoul(port, &port_end, 10);
+ char *port_cur;
+ unsigned long port_start = strtoul(port, &port_cur, 10);
unsigned long port_count = 1;
- if (*port_end == '/')
- port_count = strtoul(port_end + 1, &port_end, 10);
- if (*port_end != ' ')
+ if (*port_cur == '/')
+ port_count = strtoul(port_cur + 1, &port_cur, 10);
+ if (port_cur != port_end)
goto bad;
const char *proto_end = memchr(proto, ' ', end - proto);
=====================================
modules/access/v4l2/controls.c
=====================================
@@ -233,12 +233,13 @@ next:
p += strspn (p, ", ");
name = p;
+ char *begin = p;
end = strchr (p, ',');
if (end != NULL)
*(end++) = '\0';
p = end; /* next name/value pair */
- end = strchr (name, '=');
+ end = strchr (begin, '=');
if (end == NULL)
{
/* TODO? support button controls that way? */
=====================================
modules/access/vcd/cdrom.c
=====================================
@@ -789,7 +789,6 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
vcddev_t *p_vcddev )
{
int i_ret = -1;
- char *p_pos;
char *psz_vcdfile = NULL;
char *psz_cuefile = NULL;
FILE *cuefile = NULL;
@@ -798,7 +797,7 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
bool b_found = false;
/* Check if we are dealing with a .cue file */
- p_pos = strrchr( psz_dev, '.' );
+ const char *p_pos = strrchr( psz_dev, '.' );
if( p_pos && !strcasecmp( p_pos, ".cue" ) )
{
/* psz_dev must be the cue file. Let's assume there's a .bin
=====================================
modules/audio_filter/channel_mixer/remap.c
=====================================
@@ -298,7 +298,7 @@ static int OpenFilter( vlc_object_t *p_this )
assert( wg4_i < sizeof( pi_vlc_chan_order_wg4 )/sizeof( pi_vlc_chan_order_wg4[0] ) );
}
unsigned channel_wg4idx_len = sizeof( channel_wg4idx )/sizeof( channel_wg4idx[0] );
- uint8_t *pi_chnidx = memchr( channel_wg4idx, wg4_i, channel_wg4idx_len );
+ const uint8_t *pi_chnidx = memchr( channel_wg4idx, wg4_i, channel_wg4idx_len );
assert( pi_chnidx != NULL );
uint8_t chnidx = pi_chnidx - channel_wg4idx;
int64_t val = var_InheritInteger( p_this, channel_name[chnidx] );
=====================================
modules/audio_output/pulse.c
=====================================
@@ -877,7 +877,7 @@ static int strcmp_void(const void *a, const void *b)
static const char *str_map(const char *key, const char *const table[][2],
size_t n)
{
- const char **r = bsearch(key, table, n, sizeof (*table), strcmp_void);
+ const char *const *r = bsearch(key, table, n, sizeof (*table), strcmp_void);
return (r != NULL) ? r[1] : NULL;
}
=====================================
modules/codec/gstreamer/fourcc.c
=====================================
@@ -76,7 +76,7 @@ static int compare_func( const void* key, const void* ent )
vlc_fourcc_t GetGstVLCFourcc( const char* gst )
{
- gst_vlc_rawvideo_fourcc* found = NULL;
+ const gst_vlc_rawvideo_fourcc* found = NULL;
if( !gst )
{
=====================================
modules/codec/subsusf.c
=====================================
@@ -280,8 +280,8 @@ static char *GrabAttributeValue( const char *psz_attribute,
{
if( psz_attribute && psz_tag_start )
{
- char *psz_tag_end = strchr( psz_tag_start, '>' );
- char *psz_found = strcasestr( psz_tag_start, psz_attribute );
+ const char *psz_tag_end = strchr( psz_tag_start, '>' );
+ const char *psz_found = strcasestr( psz_tag_start, psz_attribute );
if( psz_found )
{
=====================================
modules/codec/ttml/ttml.c
=====================================
@@ -570,8 +570,8 @@ size_t tt_timings_FindLowerIndex( const tt_time_t *p_times, size_t i_times, tt_t
key.time = time;
key.p_last = NULL;
- tt_time_t *lookup = bsearch( &key, p_times, i_times,
- sizeof(tt_time_t), tt_bsearch_searchkey_Compare );
+ const tt_time_t *lookup = bsearch(&key, p_times, i_times,
+ sizeof(tt_time_t), tt_bsearch_searchkey_Compare);
if( lookup )
key.p_last = lookup;
*pb_found = !!lookup;
=====================================
modules/codec/ttml/ttml.h
=====================================
@@ -57,7 +57,7 @@ typedef struct
struct tt_searchkey
{
tt_time_t time;
- tt_time_t *p_last;
+ const tt_time_t *p_last;
};
/* namespaces */
=====================================
modules/stream_out/rtpfmt.c
=====================================
@@ -718,10 +718,10 @@ int rtp_packetize_xiph_config( sout_stream_id_sys_t *id, const char *fmtp,
return VLC_EGENERIC;
/* extract base64 configuration from fmtp */
- char *start = strstr(fmtp, "configuration=");
+ const char *start = strstr(fmtp, "configuration=");
assert(start != NULL);
start += sizeof("configuration=") - 1;
- char *end = strchr(start, ';');
+ const char *end = strchr(start, ';');
assert(end != NULL);
size_t len = end - start;
=====================================
src/config/getopt.c
=====================================
@@ -333,7 +333,7 @@ int vlc_getopt_long(int argc, char *const *argv,
{
char c = *(state->nextchar)++;
- char *temp = strchr(optstring, c);
+ const char *temp = strchr(optstring, c);
/* Increment `optind' when we start to process its last character. */
if (*state->nextchar == '\0')
=====================================
src/input/input.c
=====================================
@@ -3596,23 +3596,21 @@ static char *input_SubtitleFile2Uri( input_thread_t *p_input,
/* if we are provided a subtitle.sub file,
* see if we don't have a subtitle.idx and use it instead */
char *psz_idxpath = NULL;
- char *psz_extension = strrchr( psz_subtitle, '.');
- if( psz_extension && strcmp( psz_extension, ".sub" ) == 0 )
+ const char *extension_part = strrchr(psz_subtitle, '.');
+ if (extension_part && strcmp(extension_part, ".sub" ) == 0)
{
psz_idxpath = strdup( psz_subtitle );
- if( psz_idxpath )
- {
- struct stat st;
+ if (psz_idxpath == NULL)
+ return NULL;
- psz_extension = psz_extension - psz_subtitle + psz_idxpath;
- strcpy( psz_extension, ".idx" );
+ strcpy(&psz_idxpath[extension_part - psz_subtitle], ".idx");
- if( !vlc_stat( psz_idxpath, &st ) && S_ISREG( st.st_mode ) )
- {
- msg_Dbg( p_input, "using %s as subtitle file instead of %s",
- psz_idxpath, psz_subtitle );
- psz_subtitle = psz_idxpath;
- }
+ struct stat st;
+ if( !vlc_stat( psz_idxpath, &st ) && S_ISREG( st.st_mode ) )
+ {
+ msg_Dbg( p_input, "using %s as subtitle file instead of %s",
+ psz_idxpath, psz_subtitle );
+ psz_subtitle = psz_idxpath;
}
}
=====================================
src/misc/actions.c
=====================================
@@ -218,8 +218,8 @@ uint_fast32_t vlc_str2keycode (const char *name)
name += len + 1;
}
- struct key_descriptor *d = bsearch (name, s_keys, ARRAY_SIZE(s_keys),
- sizeof (s_keys[0]), keystrcmp);
+ const struct key_descriptor *d = bsearch(name, s_keys, ARRAY_SIZE(s_keys),
+ sizeof (s_keys[0]), keystrcmp);
if (d != NULL)
code = d->i_code;
else if (vlc_towc (name, &code) <= 0)
=====================================
src/misc/keystore.c
=====================================
@@ -271,19 +271,19 @@ protocol_store_path(const vlc_url_t *p_url)
static void
smb_split_domain(vlc_credential *p_credential)
{
- char *psz_delim = strchr(p_credential->psz_username, ';');
- if (psz_delim)
+ const char *psz_delim = strchr(p_credential->psz_username, ';');
+ if (psz_delim == NULL)
+ return;
+
+ size_t i_len = psz_delim - p_credential->psz_username;
+ if (i_len > 0)
{
- size_t i_len = psz_delim - p_credential->psz_username;
- if (i_len > 0)
- {
- free(p_credential->psz_split_domain);
- p_credential->psz_split_domain =
- strndup(p_credential->psz_username, i_len);
- p_credential->psz_realm = p_credential->psz_split_domain;
- }
- p_credential->psz_username = psz_delim + 1;
+ free(p_credential->psz_split_domain);
+ p_credential->psz_split_domain =
+ strndup(p_credential->psz_username, i_len);
+ p_credential->psz_realm = p_credential->psz_split_domain;
}
+ p_credential->psz_username = psz_delim + 1;
}
static void
=====================================
src/misc/messages.c
=====================================
@@ -123,7 +123,7 @@ void vlc_vaLog(struct vlc_logger *const *loggerp, int type,
return;
/* Get basename from the module filename */
- char *p = strrchr(module, '/');
+ const char *p = strrchr(module, '/');
if (p != NULL)
module = p + 1;
p = strchr(module, '.');
=====================================
src/misc/mime.c
=====================================
@@ -92,9 +92,7 @@ static const struct
const char *vlc_mime_Ext2Mime( const char *psz_url )
{
- char *psz_ext;
-
- psz_ext = strrchr( psz_url, '.' );
+ const char *psz_ext = strrchr(psz_url, '.');
if( psz_ext )
{
int i;
=====================================
src/text/url.c
=====================================
@@ -270,21 +270,24 @@ char *vlc_path2uri (const char *path, const char *scheme)
char *vlc_uri2path (const char *url)
{
char *ret = NULL;
- char *end;
+ char *path = NULL;
+ size_t schemelen = 0;
- char *path = strstr (url, "://");
- if (path == NULL)
- return NULL; /* unsupported scheme or invalid syntax */
-
- end = memchr (url, '/', path - url);
- size_t schemelen = ((end != NULL) ? end : path) - url;
- path += 3; /* skip "://" */
-
- /* Remove request parameters and/or HTML anchor if present */
- end = path + strcspn (path, "?#");
- path = strndup (path, end - path);
- if (unlikely(path == NULL))
- return NULL; /* boom! */
+ {
+ const char *start = strstr (url, "://");
+ if (start == NULL)
+ return NULL; /* unsupported scheme or invalid syntax */
+
+ const char *end = memchr (url, '/', start - url);
+ schemelen = ((end != NULL) ? end : start) - url;
+ start += 3; /* skip "://" */
+
+ /* Remove request parameters and/or HTML anchor if present */
+ end = start + strcspn (start, "?#");
+ path = strndup (start, end - start);
+ if (unlikely(path == NULL))
+ return NULL; /* boom! */
+ }
/* Decode path */
vlc_uri_decode (path);
@@ -320,9 +323,10 @@ char *vlc_uri2path (const char *url)
else
if (schemelen == 2 && !strncasecmp (url, "fd", 2))
{
- long fd = strtol(path, &end, 0);
+ char *leftover;
+ long fd = strtol(path, &leftover, 0);
- if (*end || ((unsigned long)fd) > INT_MAX)
+ if (*leftover != '\0' || ((unsigned long)fd) > INT_MAX)
goto out;
#if !defined( _WIN32 ) && !defined( __OS2__ )
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4d01c57d3254aff51c5258ded457981622b677f6...8f92a2d47fc9623308edb42f5299e352f205e13d
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4d01c57d3254aff51c5258ded457981622b677f6...8f92a2d47fc9623308edb42f5299e352f205e13d
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list