[vlc-commits] lua: use luaL_checkint() where applicable
Rémi Denis-Courmont
git at videolan.org
Sun Aug 14 16:19:25 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Aug 14 17:18:49 2016 +0300| [520b13a2ca88fc63ba3c1287e9314fbb2777c85d] | committer: Rémi Denis-Courmont
lua: use luaL_checkint() where applicable
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=520b13a2ca88fc63ba3c1287e9314fbb2777c85d
---
modules/lua/demux.c | 4 ++--
modules/lua/libs/dialog.c | 14 +++++++-------
modules/lua/libs/net.c | 16 ++++++++--------
modules/lua/libs/osd.c | 4 ++--
modules/lua/libs/playlist.c | 10 +++++-----
modules/lua/libs/stream.c | 2 +-
modules/lua/libs/volume.c | 2 +-
7 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/modules/lua/demux.c b/modules/lua/demux.c
index aa1c97b..f1b4c0d 100644
--- a/modules/lua/demux.c
+++ b/modules/lua/demux.c
@@ -52,7 +52,7 @@ struct demux_sys_t
static int vlclua_demux_peek( lua_State *L )
{
demux_t *p_demux = (demux_t *)vlclua_get_this( L );
- int n = (int)luaL_checkinteger( L, 1 );
+ int n = luaL_checkint( L, 1 );
const uint8_t *p_peek;
int i_peek = vlc_stream_Peek( p_demux->s, &p_peek, n );
@@ -67,7 +67,7 @@ static int vlclua_demux_read( lua_State *L )
{
demux_t *p_demux = (demux_t *)vlclua_get_this( L );
const uint8_t *p_read;
- int n = (int)luaL_checkinteger( L, 1 );
+ int n = luaL_checkint( L, 1 );
int i_read = vlc_stream_Peek( p_demux->s, &p_read, n );
if( i_read > 0 )
diff --git a/modules/lua/libs/dialog.c b/modules/lua/libs/dialog.c
index 64d1fcb..a9c65e7 100644
--- a/modules/lua/libs/dialog.c
+++ b/modules/lua/libs/dialog.c
@@ -380,7 +380,7 @@ static int lua_GetDialogUpdate( lua_State *L )
/* Read entry in the Lua registry */
lua_pushlightuserdata( L, (void*) &key_update );
lua_gettable( L, LUA_REGISTRYINDEX );
- return luaL_checkinteger( L, -1 );
+ return luaL_checkint( L, -1 );
}
/** Manually update a dialog
@@ -571,22 +571,22 @@ static int vlclua_create_widget_inner( lua_State *L, int i_args,
/* Set common arguments: col, row, hspan, vspan, width, height */
if( lua_isnumber( L, arg ) )
- p_widget->i_column = luaL_checkinteger( L, arg );
+ p_widget->i_column = luaL_checkint( L, arg );
else goto end_of_args;
if( lua_isnumber( L, ++arg ) )
- p_widget->i_row = luaL_checkinteger( L, arg );
+ p_widget->i_row = luaL_checkint( L, arg );
else goto end_of_args;
if( lua_isnumber( L, ++arg ) )
- p_widget->i_horiz_span = luaL_checkinteger( L, arg );
+ p_widget->i_horiz_span = luaL_checkint( L, arg );
else goto end_of_args;
if( lua_isnumber( L, ++arg ) )
- p_widget->i_vert_span = luaL_checkinteger( L, arg );
+ p_widget->i_vert_span = luaL_checkint( L, arg );
else goto end_of_args;
if( lua_isnumber( L, ++arg ) )
- p_widget->i_width = luaL_checkinteger( L, arg );
+ p_widget->i_width = luaL_checkint( L, arg );
else goto end_of_args;
if( lua_isnumber( L, ++arg ) )
- p_widget->i_height = luaL_checkinteger( L, arg );
+ p_widget->i_height = luaL_checkint( L, arg );
else goto end_of_args;
end_of_args:
diff --git a/modules/lua/libs/net.c b/modules/lua/libs/net.c
index 3368c0d..147061a 100644
--- a/modules/lua/libs/net.c
+++ b/modules/lua/libs/net.c
@@ -210,7 +210,7 @@ static int vlclua_net_listen_tcp( lua_State *L )
{
vlc_object_t *p_this = vlclua_get_this( L );
const char *psz_host = luaL_checkstring( L, 1 );
- int i_port = (int)luaL_checkinteger( L, 2 );
+ int i_port = luaL_checkint( L, 2 );
int *pi_fd = net_ListenTCP( p_this, psz_host, i_port );
if( pi_fd == NULL )
return luaL_error( L, "Cannot listen on %s:%d", psz_host, i_port );
@@ -282,7 +282,7 @@ static int vlclua_net_connect_tcp( lua_State *L )
{
vlc_object_t *p_this = vlclua_get_this( L );
const char *psz_host = luaL_checkstring( L, 1 );
- int i_port = (int)luaL_checkinteger( L, 2 );
+ int i_port = luaL_checkint( L, 2 );
int i_fd = net_Connect( p_this, psz_host, i_port, SOCK_STREAM, IPPROTO_TCP );
lua_pushinteger( L, vlclua_fd_map_safe( L, i_fd ) );
return 1;
@@ -290,14 +290,14 @@ static int vlclua_net_connect_tcp( lua_State *L )
static int vlclua_net_close( lua_State *L )
{
- int i_fd = (int)luaL_checkinteger( L, 1 );
+ int i_fd = luaL_checkint( L, 1 );
vlclua_fd_unmap_safe( L, i_fd );
return 0;
}
static int vlclua_net_send( lua_State *L )
{
- int fd = vlclua_fd_get( L, (unsigned)luaL_checkinteger( L, 1 ) );
+ int fd = vlclua_fd_get( L, luaL_checkint( L, 1 ) );
size_t i_len;
const char *psz_buffer = luaL_checklstring( L, 2, &i_len );
@@ -309,7 +309,7 @@ static int vlclua_net_send( lua_State *L )
static int vlclua_net_recv( lua_State *L )
{
- int fd = vlclua_fd_get( L, (unsigned)luaL_checkinteger( L, 1 ) );
+ int fd = vlclua_fd_get( L, luaL_checkint( L, 1 ) );
size_t i_len = (size_t)luaL_optinteger( L, 2, 1 );
char psz_buffer[i_len];
@@ -343,7 +343,7 @@ static int vlclua_net_poll( lua_State *L )
lua_pushnil( L );
for( int i = 0; lua_next( L, 1 ); i++ )
{
- luafds[i] = luaL_checkinteger( L, -2 );
+ luafds[i] = luaL_checkint( L, -2 );
p_fds[i].fd = vlclua_fd_get( L, luafds[i] );
p_fds[i].events = luaL_checkinteger( L, -1 );
p_fds[i].events &= POLLIN | POLLOUT | POLLPRI;
@@ -391,7 +391,7 @@ static int vlclua_fd_open( lua_State *L )
#ifndef _WIN32
static int vlclua_fd_write( lua_State *L )
{
- int fd = vlclua_fd_get( L, (unsigned)luaL_checkinteger( L, 1 ) );
+ int fd = vlclua_fd_get( L, luaL_checkint( L, 1 ) );
size_t i_len;
const char *psz_buffer = luaL_checklstring( L, 2, &i_len );
@@ -402,7 +402,7 @@ static int vlclua_fd_write( lua_State *L )
static int vlclua_fd_read( lua_State *L )
{
- int fd = vlclua_fd_get( L, (unsigned)luaL_checkinteger( L, 1 ) );
+ int fd = vlclua_fd_get( L, luaL_checkint( L, 1 ) );
size_t i_len = (size_t)luaL_optinteger( L, 2, 1 );
char psz_buffer[i_len];
diff --git a/modules/lua/libs/osd.c b/modules/lua/libs/osd.c
index e8d8ea7..9a4e0ae 100644
--- a/modules/lua/libs/osd.c
+++ b/modules/lua/libs/osd.c
@@ -154,7 +154,7 @@ static int vlc_osd_slider_type_from_string( const char *psz_name )
static int vlclua_osd_slider( lua_State *L )
{
- int i_position = (int)luaL_checkinteger( L, 1 );
+ int i_position = luaL_checkint( L, 1 );
const char *psz_type = luaL_checkstring( L, 2 );
int i_type = vlc_osd_slider_type_from_string( psz_type );
int i_chan = (int)luaL_optinteger( L, 3, SPU_DEFAULT_CHANNEL );
@@ -198,7 +198,7 @@ static int vlclua_spu_channel_register( lua_State *L )
static int vlclua_spu_channel_clear( lua_State *L )
{
- int i_chan = (int)luaL_checkinteger( L, 1 );
+ int i_chan = luaL_checkint( L, 1 );
input_thread_t *p_input = vlclua_get_input_internal( L );
if( !p_input )
return luaL_error( L, "Unable to find input." );
diff --git a/modules/lua/libs/playlist.c b/modules/lua/libs/playlist.c
index a6ef6cb..d4b07a5 100644
--- a/modules/lua/libs/playlist.c
+++ b/modules/lua/libs/playlist.c
@@ -69,7 +69,7 @@ static int vlclua_playlist_next( lua_State * L )
static int vlclua_playlist_skip( lua_State * L )
{
- int i_skip = (int)luaL_checkinteger( L, 1 );
+ int i_skip = luaL_checkint( L, 1 );
playlist_t *p_playlist = vlclua_get_playlist_internal( L );
playlist_Skip( p_playlist, i_skip );
return 0;
@@ -127,7 +127,7 @@ static int vlclua_playlist_random( lua_State * L )
static int vlclua_playlist_gotoitem( lua_State * L )
{
- int i_id = (int)luaL_checkinteger( L, 1 );
+ int i_id = luaL_checkint( L, 1 );
playlist_t *p_playlist = vlclua_get_playlist_internal( L );
PL_LOCK;
playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, true, NULL,
@@ -138,7 +138,7 @@ static int vlclua_playlist_gotoitem( lua_State * L )
static int vlclua_playlist_delete( lua_State * L )
{
- int i_id = (int)luaL_checkinteger( L, 1 );
+ int i_id = luaL_checkint( L, 1 );
playlist_t *p_playlist = vlclua_get_playlist_internal( L );
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
@@ -154,8 +154,8 @@ static int vlclua_playlist_delete( lua_State * L )
static int vlclua_playlist_move( lua_State * L )
{
- int i_item = (int)luaL_checkinteger( L, 1 );
- int i_target = (int)luaL_checkinteger( L, 2 );
+ int i_item = luaL_checkint( L, 1 );
+ int i_target = luaL_checkint( L, 2 );
playlist_t *p_playlist = vlclua_get_playlist_internal( L );
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_item );
diff --git a/modules/lua/libs/stream.c b/modules/lua/libs/stream.c
index fc58a0f..c0da3c8 100644
--- a/modules/lua/libs/stream.c
+++ b/modules/lua/libs/stream.c
@@ -101,7 +101,7 @@ static int vlclua_stream_read( lua_State *L )
{
int i_read;
stream_t **pp_stream = (stream_t **)luaL_checkudata( L, 1, "stream" );
- int n = (int)luaL_checkinteger( L, 2 );
+ int n = luaL_checkint( L, 2 );
uint8_t *p_read = malloc( n );
if( !p_read ) return vlclua_error( L );
diff --git a/modules/lua/libs/volume.c b/modules/lua/libs/volume.c
index 0fcbd24..81a6156 100644
--- a/modules/lua/libs/volume.c
+++ b/modules/lua/libs/volume.c
@@ -48,7 +48,7 @@
static int vlclua_volume_set( lua_State *L )
{
playlist_t *p_this = vlclua_get_playlist_internal( L );
- int i_volume = (int)luaL_checkinteger( L, 1 );
+ int i_volume = luaL_checkint( L, 1 );
if( i_volume < 0 )
i_volume = 0;
int i_ret = playlist_VolumeSet( p_this, i_volume/(float)AOUT_VOLUME_DEFAULT );
More information about the vlc-commits
mailing list