Skip to content

Commit d27d298

Browse files
luismarquestimothytrippel
authored andcommitted
[sw] Fix missing switch default label problems
Starting with version 18, Clang now actually respects -Wswitch-default instead of silently ignoring it. This patch fixes several cases of switch statements with a missing default label, to avoid warnings when compiling with recent versions of Clang. Signed-off-by: Luís Marques <[email protected]>
1 parent 3d07399 commit d27d298

File tree

6 files changed

+14
-4
lines changed

6 files changed

+14
-4
lines changed

sw/device/lib/testing/i2c_testutils.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ status_t i2c_testutils_set_speed(const dif_i2c_t *i2c, dif_i2c_speed_t speed) {
390390
LOG_INFO("Setting i2c to %s mode.", "FastPlus (1000kHz)");
391391
speed_khz = 1000;
392392
break;
393+
default:
394+
break;
393395
}
394396
// I2C speed parameters.
395397
dif_i2c_timing_config_t timing_config = {

sw/device/lib/testing/spi_flash_testutils.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ status_t spi_flash_testutils_quad_enable(dif_spi_host_t *spih, uint8_t method,
389389
// Reserved.
390390
return INVALID_ARGUMENT();
391391
break;
392+
default:
393+
break;
392394
}
393395
return OK_STATUS();
394396
}

sw/device/lib/testing/usb_testutils_controlep.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ static usb_testutils_ctstate_t setup_req(usb_testutils_controlep_ctx_t *ctctx,
282282
case kVendorSetupReqTestStatus: {
283283
// TODO - pass the received test status to the OTTF directly?
284284
} break;
285+
default:
286+
break;
285287
}
286288
}
287289
return kUsbTestutilsCtError;

sw/device/silicon_creator/lib/drivers/keymgr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ static rom_error_t keymgr_wait_until_done(void) {
196196
abs_mmio_write32(kBase + KEYMGR_ERR_CODE_REG_OFFSET, err_code);
197197
return kErrorKeymgrInternal;
198198
}
199+
default:
200+
// Should be unreachable.
201+
HARDENED_TRAP();
202+
return kErrorKeymgrInternal;
199203
}
200-
201-
// Should be unreachable.
202-
HARDENED_TRAP();
203-
return kErrorKeymgrInternal;
204204
}
205205

206206
rom_error_t sc_keymgr_generate_key(

sw/device/tests/aes_interrupt_encryption_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ status_t execute_test(void) {
7171
aes_mode = kDifAesModeCtr;
7272
memcpy(iv_mode.iv, kAesModesIvCtr, sizeof(kAesModesIvCtr));
7373
break;
74+
default:
75+
break;
7476
}
7577
// Initialise AES.
7678
dif_aes_t aes;

sw/device/tests/power_virus_systemtest.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ static void log_entropy_src_alert_failures(void) {
321321
LOG_INFO("High Fails (Mailbox): %d", counts.high_fails[i]);
322322
LOG_INFO("Low Fails (Mailbox): %d", counts.low_fails[i]);
323323
break;
324+
default:
325+
break;
324326
}
325327
}
326328
}

0 commit comments

Comments
 (0)