1
0
mirror of https://github.com/elua/elua.git synced 2025-01-25 01:02:54 +08:00

Fix to previous commit: unsigned values never look negative!

This commit is contained in:
Martin Guy 2012-01-21 20:00:34 +01:00
parent 84a17973fb
commit b72f620aed

View File

@ -28,14 +28,16 @@ static int adc_maxval( lua_State* L )
// Lua: realclock = setclock( id, freq, [timer_id] ) // Lua: realclock = setclock( id, freq, [timer_id] )
static int adc_setclock( lua_State* L ) static int adc_setclock( lua_State* L )
{ {
s32 sfreq; // signed version for negative checking
u32 freq; u32 freq;
unsigned id, timer_id = 0; unsigned id, timer_id = 0;
id = luaL_checkinteger( L, 1 ); id = luaL_checkinteger( L, 1 );
MOD_CHECK_ID( adc, id ); MOD_CHECK_ID( adc, id );
freq = luaL_checkinteger( L, 2 ); sfreq = luaL_checkinteger( L, 2 );
if ( freq < 0 ) if ( sfreq < 0 )
return luaL_error( L, "frequency must be 0 or positive" ); return luaL_error( L, "frequency must be 0 or positive" );
freq = ( u32 ) sfreq;
if ( freq > 0 ) if ( freq > 0 )
{ {
timer_id = luaL_checkinteger( L, 3 ); timer_id = luaL_checkinteger( L, 3 );