diff --git a/lib/libx52/x52_control.c b/lib/libx52/x52_control.c index c42f50c..6cbadbb 100644 --- a/lib/libx52/x52_control.c +++ b/lib/libx52/x52_control.c @@ -262,6 +262,7 @@ static int _x52_write_time(libx52_device *x52, uint32_t bit) uint16_t value = 0; uint16_t index; libx52_clock_id clock; + uint16_t h24; switch (bit) { case X52_BIT_MFD_TIME: @@ -276,9 +277,12 @@ static int _x52_write_time(libx52_device *x52, uint32_t bit) clock = LIBX52_CLOCK_3; index = X52_OFFS_CLOCK3; break; + default: + /* We should never get here, but put in a dummy case to satisfy the compiler */ + return LIBX52_ERROR_INVALID_PARAM; } - uint16_t h24 = !!(x52->time_format[clock]); + h24 = !!(x52->time_format[clock]); if (clock != LIBX52_CLOCK_1) { value = libx52_calculate_clock_offset(x52, clock, h24); diff --git a/lib/libx52/x52_core.c b/lib/libx52/x52_core.c index 0d345d4..fe42c58 100644 --- a/lib/libx52/x52_core.c +++ b/lib/libx52/x52_core.c @@ -32,6 +32,8 @@ static int libx52_check_product(uint16_t idVendor, uint16_t idProduct) case X52_PROD_X52_2: case X52_PROD_X52PRO: return 1; + default: + return 0; } } @@ -190,6 +192,8 @@ int libx52_check_feature(libx52_device *dev, libx52_feature feature) return tst_bit(&(dev->flags), X52_FLAG_IS_PRO) ? LIBX52_SUCCESS : LIBX52_ERROR_NOT_SUPPORTED; + default: + return LIBX52_ERROR_INVALID_PARAM; } return LIBX52_ERROR_INVALID_PARAM; diff --git a/lib/libx52/x52_date_time.c b/lib/libx52/x52_date_time.c index fb732aa..abb40a6 100644 --- a/lib/libx52/x52_date_time.c +++ b/lib/libx52/x52_date_time.c @@ -168,8 +168,11 @@ int libx52_set_clock_timezone(libx52_device *x52, libx52_clock_id clock, int off set_bit(&x52->update_mask, X52_BIT_MFD_OFFS2); break; - default: + case LIBX52_CLOCK_1: return LIBX52_ERROR_NOT_SUPPORTED; + + default: + return LIBX52_ERROR_INVALID_PARAM; } return LIBX52_SUCCESS; diff --git a/lib/libx52/x52_mfd_led.c b/lib/libx52/x52_mfd_led.c index 4d9023f..a7f8074 100644 --- a/lib/libx52/x52_mfd_led.c +++ b/lib/libx52/x52_mfd_led.c @@ -58,7 +58,15 @@ static int x52pro_set_led_state(libx52_device *x52, libx52_led_id led, libx52_le } break; - default: + case LIBX52_LED_A: + case LIBX52_LED_B: + case LIBX52_LED_D: + case LIBX52_LED_E: + case LIBX52_LED_T1: + case LIBX52_LED_T2: + case LIBX52_LED_T3: + case LIBX52_LED_POV: + case LIBX52_LED_CLUTCH: /* All other LEDs support OFF, RED, AMBER and GREEN states * However, they are composed of individual RED and GREEN LEDs which * must be turned on or off individually. @@ -84,15 +92,23 @@ static int x52pro_set_led_state(libx52_device *x52, libx52_led_id led, libx52_le set_bit(&x52->led_mask, led + 1); // Green break; - default: + case LIBX52_LED_STATE_ON: /* Cannot set the LED to "ON" */ return LIBX52_ERROR_NOT_SUPPORTED; + + default: + /* Any other state is not valid */ + return LIBX52_ERROR_INVALID_PARAM; } /* Set the update mask bits */ set_bit(&x52->update_mask, led + 0); // Red set_bit(&x52->update_mask, led + 1); // Green break; + + default: + /* Any other LED is not valid */ + return LIBX52_ERROR_INVALID_PARAM; } return LIBX52_SUCCESS;