99#include  "bh_platform.h" 
1010
1111static  sys_sensor_t  * g_sys_sensors  =  NULL ;
12- static  int  g_sensor_id_max  =  0 ;
12+ static  uint32  g_sensor_id_max  =  0 ;
1313
1414static  sensor_client_t  * 
1515find_sensor_client (sys_sensor_t  * sensor , unsigned int   client_id ,
@@ -85,8 +85,8 @@ wasm_sensor_callback(void *client, uint32 sensor_id, void *user_data)
8585}
8686
8787bool 
88- wasm_sensor_config (wasm_exec_env_t  exec_env , uint32  sensor , int  interval ,
89-                    int  bit_cfg , int  delay )
88+ wasm_sensor_config (wasm_exec_env_t  exec_env , uint32  sensor , uint32  interval ,
89+                    int  bit_cfg , uint32  delay )
9090{
9191    wasm_module_inst_t  module_inst  =  get_module_inst (exec_env );
9292    attr_container_t  * attr_cont ;
@@ -115,9 +115,9 @@ wasm_sensor_config(wasm_exec_env_t exec_env, uint32 sensor, int interval,
115115
116116    if  (s -> config  !=  NULL ) {
117117        attr_cont  =  attr_container_create ("config sensor" );
118-         attr_container_set_int (& attr_cont , "interval" , interval );
118+         attr_container_set_int (& attr_cont , "interval" , ( int ) interval );
119119        attr_container_set_int (& attr_cont , "bit_cfg" , bit_cfg );
120-         attr_container_set_int (& attr_cont , "delay" , delay );
120+         attr_container_set_int (& attr_cont , "delay" , ( int ) delay );
121121        s -> config (s , attr_cont );
122122        attr_container_destroy (attr_cont );
123123    }
@@ -138,7 +138,7 @@ wasm_sensor_open(wasm_exec_env_t exec_env, char *name, int instance)
138138        sensor_client_t  * c ;
139139        sys_sensor_t  * s  =  find_sys_sensor (name , instance );
140140        if  (s  ==  NULL )
141-             return  -1 ;
141+             return  ( uint32 ) - 1 ;
142142
143143        unsigned int   mod_id  = 
144144            app_manager_get_module_id (Module_WASM_App , module_inst );
@@ -150,14 +150,14 @@ wasm_sensor_open(wasm_exec_env_t exec_env, char *name, int instance)
150150        if  (c ) {
151151            // the app already opened this sensor 
152152            os_mutex_unlock (& s -> lock );
153-             return  -1 ;
153+             return  ( uint32 ) - 1 ;
154154        }
155155
156156        sensor_client_t  * client  = 
157157            (sensor_client_t  * )wasm_runtime_malloc (sizeof (sensor_client_t ));
158158        if  (client  ==  NULL ) {
159159            os_mutex_unlock (& s -> lock );
160-             return  -1 ;
160+             return  ( uint32 ) - 1 ;
161161        }
162162
163163        memset (client , 0 , sizeof (sensor_client_t ));
@@ -176,7 +176,7 @@ wasm_sensor_open(wasm_exec_env_t exec_env, char *name, int instance)
176176        return  s -> sensor_id ;
177177    }
178178
179-     return  -1 ;
179+     return  ( uint32 ) - 1 ;
180180}
181181
182182bool 
@@ -294,7 +294,7 @@ add_sys_sensor(char *name, char *description, int instance,
294294    }
295295
296296    g_sensor_id_max ++ ;
297-     if  (g_sensor_id_max  ==  -1 )
297+     if  (g_sensor_id_max  ==  UINT32_MAX )
298298        g_sensor_id_max ++ ;
299299    s -> sensor_id  =  g_sensor_id_max ;
300300
@@ -366,10 +366,10 @@ find_sensor_client(sys_sensor_t *sensor, unsigned int client_id,
366366}
367367
368368// return the milliseconds to next check 
369- int 
369+ uint32 
370370check_sensor_timers ()
371371{
372-     int  ms_to_next_check  =  -1 ;
372+     uint32  ms_to_next_check  =  UINT32_MAX ;
373373    uint32  now  =  (uint32 )bh_get_tick_ms ();
374374
375375    sys_sensor_t  * s  =  g_sys_sensors ;
@@ -395,12 +395,12 @@ check_sensor_timers()
395395
396396            s -> last_read  =  now ;
397397
398-             if  (ms_to_next_check   ==   -1   ||  ( ms_to_next_check   <   s -> read_interval ) )
398+             if  (s -> read_interval   <   ms_to_next_check )
399399                ms_to_next_check  =  s -> read_interval ;
400400        }
401401        else  {
402-             int  remaining  =  s -> read_interval  -  elpased_ms ;
403-             if  (ms_to_next_check   ==   -1   ||  ( ms_to_next_check   <   remaining ) )
402+             uint32  remaining  =  s -> read_interval  -  elpased_ms ;
403+             if  (remaining   <   ms_to_next_check )
404404                ms_to_next_check  =  remaining ;
405405        }
406406
0 commit comments