Skip to content

Commit

Permalink
Merge pull request contiki-os#2423 from IVOES/fix-const-comparison
Browse files Browse the repository at this point in the history
Fix incorrect comparisons
  • Loading branch information
nvt authored Jun 7, 2023
2 parents 86b82ac + 6656674 commit baca8eb
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion arch/platform/zoul/dev/grove-gyro.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ configure(int type, int value)
return grove_gyro_dlpf(value);

case GROVE_GYRO_SAMPLE_RATE_DIVIDER:
if((value < 0) && (value > 0xFF)) {
if((value < 0) || (value > 0xFF)) {
PRINTF("Gyro: invalid sampling rate div, it must be an 8-bit value\n");
return GROVE_GYRO_ERROR;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/platform/zoul/dev/rtcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ rtcc_set_alarm_time_date(simple_td_map *data, uint8_t state, uint8_t repeat,
return AB08_ERROR;
}

if((state >= RTCC_ALARM_MAX) || (repeat >= RTCC_REPEAT_100THS)) {
if((state >= RTCC_ALARM_MAX) || (repeat > RTCC_REPEAT_100THS)) {
PRINTF("RTC: invalid alarm config type or state\n");
return AB08_ERROR;
}
Expand Down
4 changes: 2 additions & 2 deletions arch/platform/zoul/dev/servo.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ servo_position(uint16_t gptab, uint8_t port, uint8_t pin, uint16_t pos)
uint8_t gpt_ab;
uint32_t count = 0;

if((gptab < SERVO_CHANNEL_1) && (gptab > SERVO_CHANNEL_7)) {
if((gptab < SERVO_CHANNEL_1) || (gptab > SERVO_CHANNEL_7)) {
PRINTF("Servo: invalid servo channel\n");
return SERVO_ERROR;
}
Expand Down Expand Up @@ -107,7 +107,7 @@ servo_stop(uint16_t gptab, uint8_t port, uint8_t pin)
uint8_t gpt_num;
uint8_t gpt_ab;

if((gptab < SERVO_CHANNEL_1) && (gptab > SERVO_CHANNEL_7)) {
if((gptab < SERVO_CHANNEL_1) || (gptab > SERVO_CHANNEL_7)) {
PRINTF("Servo: invalid servo channel\n");
return SERVO_ERROR;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/platform-specific/zoul/test-bmp085-bmp180.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static struct etimer et;
PROCESS_THREAD(remote_bmpx8x_process, ev, data)
{
PROCESS_BEGIN();
static uint16_t pressure;
static int pressure;
static int16_t temperature;

/* Use Contiki's sensor macro to enable the sensor */
Expand Down
2 changes: 1 addition & 1 deletion examples/platform-specific/zoul/test-grove-light-sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ PROCESS_THREAD(remote_grove_light_process, ev, data)
{
PROCESS_BEGIN();

uint16_t ldr;
int ldr;

/* Use pin number not mask, for example if using the PA5 pin then use 5 */
adc_sensors.configure(ANALOG_GROVE_LIGHT, 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ PROCESS_THREAD(remote_grove_loudness_process, ev, data)
{
PROCESS_BEGIN();

uint16_t loudness;
int loudness;

/* Use pin number not mask, for example if using the PA5 pin then use 5 */
adc_sensors.configure(ANALOG_GROVE_LOUDNESS, ADC_PIN);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform-specific/zoul/test-pm10-sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ PROCESS_THREAD(test_pm10_sensor_process, ev, data)
{
PROCESS_BEGIN();

static uint16_t pm10_value;
static int pm10_value;

/* Use pin number not mask, for example if using the PA5 pin then use 2 */
pm10.configure(SENSORS_ACTIVE, ADC_PIN);
Expand Down
2 changes: 1 addition & 1 deletion examples/platform-specific/zoul/test-rotation-sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ PROCESS_THREAD(remote_rotation_process, ev, data)
{
PROCESS_BEGIN();

uint16_t rotation;
int rotation;

/* Use pin number not mask, for example if using the PA5 pin then use 5 */
adc_sensors.configure(ANALOG_PHIDGET_ROTATION_1109, 5);
Expand Down

0 comments on commit baca8eb

Please sign in to comment.