[vlc-commits] [Git][videolan/vlc][master] dynamicoverlay: use size_t for p_params->i_id
François Cartegnie (@fcartegnie)
gitlab at videolan.org
Sat Feb 24 14:19:42 UTC 2024
François Cartegnie pushed to branch master at VideoLAN / VLC
Commits:
4a0b1e06 by Alexandre Janniaux at 2024-02-24T13:56:26+00:00
dynamicoverlay: use size_t for p_params->i_id
The id for the overlays are necesarily unsigned, and are used as an
array subscript, and then compared against the size of the array, so
using size_t directly as an id ensure we don't have sign warnings.
- - - - -
2 changed files:
- modules/spu/dynamicoverlay/dynamicoverlay.h
- modules/spu/dynamicoverlay/dynamicoverlay_commands.c
Changes:
=====================================
modules/spu/dynamicoverlay/dynamicoverlay.h
=====================================
@@ -55,7 +55,7 @@ char *BufferGetToken( buffer_t *p_buffer );
/** struct commandparams_t - command params structure */
typedef struct commandparams_t
{
- int32_t i_id; /*< overlay id */
+ size_t i_id; /*< overlay id */
int32_t i_shmid; /*< shared memory identifier */
vlc_fourcc_t fourcc;/*< chroma */
=====================================
modules/spu/dynamicoverlay/dynamicoverlay_commands.c
=====================================
@@ -108,6 +108,15 @@ static int parse_digit( char **psz_command, int32_t *value )
return VLC_SUCCESS;
}
+static int parse_param_id(char **psz_command, size_t *value)
+{
+ int32_t digit;
+ if (parse_digit(psz_command, &digit) == VLC_EGENERIC || digit < 0)
+ return VLC_EGENERIC;
+ *value = digit;
+ return VLC_SUCCESS;
+}
+
static int parse_char( char **psz_command, char **psz_end,
int count, char *psz_value )
{
@@ -128,7 +137,7 @@ static int parser_DataSharedMem( char *psz_command,
skip_space( &psz_command );
if( isdigit( (unsigned char)*psz_command ) )
{
- if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
+ if (parse_param_id( &psz_command, &p_params->i_id) == VLC_EGENERIC)
return VLC_EGENERIC;
}
skip_space( &psz_command );
@@ -166,7 +175,7 @@ static int parser_Id( char *psz_command, char *psz_end,
skip_space( &psz_command );
if( isdigit( (unsigned char)*psz_command ) )
{
- if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
+ if (parse_param_id( &psz_command, &p_params->i_id) == VLC_EGENERIC)
return VLC_EGENERIC;
}
return VLC_SUCCESS;
@@ -188,7 +197,7 @@ static int parser_SetAlpha( char *psz_command, char *psz_end,
skip_space( &psz_command );
if( isdigit( (unsigned char)*psz_command ) )
{
- if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
+ if (parse_param_id( &psz_command, &p_params->i_id) == VLC_EGENERIC)
return VLC_EGENERIC;
}
skip_space( &psz_command );
@@ -207,7 +216,7 @@ static int parser_SetPosition( char *psz_command, char *psz_end,
skip_space( &psz_command );
if( isdigit( (unsigned char)*psz_command ) )
{
- if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
+ if (parse_param_id( &psz_command, &p_params->i_id) == VLC_EGENERIC)
return VLC_EGENERIC;
}
skip_space( &psz_command );
@@ -232,7 +241,7 @@ static int parser_SetTextAlpha( char *psz_command, char *psz_end,
skip_space( &psz_command );
if( isdigit( (unsigned char)*psz_command ) )
{
- if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
+ if (parse_param_id( &psz_command, &p_params->i_id) == VLC_EGENERIC)
return VLC_EGENERIC;
}
skip_space( &psz_command );
@@ -257,7 +266,7 @@ static int parser_SetTextColor( char *psz_command, char *psz_end,
skip_space( &psz_command );
if( isdigit( (unsigned char)*psz_command ) )
{
- if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
+ if (parse_param_id( &psz_command, &p_params->i_id) == VLC_EGENERIC)
return VLC_EGENERIC;
}
skip_space( &psz_command );
@@ -289,7 +298,7 @@ static int parser_SetTextSize( char *psz_command, char *psz_end,
skip_space( &psz_command );
if( isdigit( (unsigned char)*psz_command ) )
{
- if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
+ if (parse_param_id( &psz_command, &p_params->i_id) == VLC_EGENERIC)
return VLC_EGENERIC;
}
skip_space( &psz_command );
@@ -308,7 +317,7 @@ static int parser_SetVisibility( char *psz_command, char *psz_end,
skip_space( &psz_command );
if( isdigit( (unsigned char)*psz_command ) )
{
- if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
+ if (parse_param_id( &psz_command, &p_params->i_id) == VLC_EGENERIC)
return VLC_EGENERIC;
}
skip_space( &psz_command );
@@ -337,7 +346,7 @@ static int unparse_default( const commandparams_t *p_results,
static int unparse_GenImage( const commandparams_t *p_results,
buffer_t *p_output )
{
- int ret = BufferPrintf( p_output, " %d", p_results->i_id );
+ int ret = BufferPrintf( p_output, " %zu", p_results->i_id );
if( ret != VLC_SUCCESS )
return ret;
@@ -441,7 +450,7 @@ static int exec_DataSharedMem( filter_t *p_filter,
p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
if( p_ovl == NULL )
{
- msg_Err( p_filter, "Invalid overlay: %d", p_params->i_id );
+ msg_Err( p_filter, "Invalid overlay: %zu", p_params->i_id );
return VLC_EGENERIC;
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/4a0b1e06dea043e22e6bd7e235ab1bbf08ca0a7b
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/4a0b1e06dea043e22e6bd7e235ab1bbf08ca0a7b
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list