Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable user_alarm_in_seconds will never be negative in modem_supervisor_engine #26

Closed
EduardoPfeifer opened this issue Nov 14, 2023 · 0 comments

Comments

@EduardoPfeifer
Copy link

EduardoPfeifer commented Nov 14, 2023

The var user_alarm_in_seconds will never be negative in modem_supervisor_engine because is unsigned.

uint32_t alarm = modem_get_user_alarm( );
uint32_t user_alarm_in_seconds = MODEM_MAX_ALARM_S / 1000;
if( alarm != 0 )
{
user_alarm_in_seconds = ( int32_t )( alarm - smtc_modem_hal_get_time_in_s( ) );
if( user_alarm_in_seconds <= 0 )
{
user_alarm_in_seconds = 0;
}
}

Here the type of user_alarm_in_seconds is signed

static uint32_t supervisor_check_user_alarm( void )
{
uint32_t alarm = modem_get_user_alarm( );
int32_t user_alarm_in_seconds = MODEM_MAX_ALARM_S;
// manage the user alarm
if( alarm != 0 )
{
user_alarm_in_seconds = ( int32_t )( alarm - smtc_modem_hal_get_time_in_s( ) );
if( user_alarm_in_seconds <= 0 )
{
modem_set_user_alarm( 0 );
user_alarm_in_seconds = MODEM_MAX_ALARM_S;
increment_asynchronous_msgnumber( SMTC_MODEM_EVENT_ALARM, 0, 0xFF );
}
}
return ( uint32_t ) user_alarm_in_seconds;
}

@lbm-team lbm-team closed this as completed May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants