[sw] Fix print statements using incorrect width specs
Signed-off-by: Miguel Young de la Sota <mcyoung@google.com>
diff --git a/sw/device/examples/hello_usbdev/hello_usbdev.c b/sw/device/examples/hello_usbdev/hello_usbdev.c
index ea779c5..eefb904 100644
--- a/sw/device/examples/hello_usbdev/hello_usbdev.c
+++ b/sw/device/examples/hello_usbdev/hello_usbdev.c
@@ -206,7 +206,7 @@
uint32_t usb_irq_state =
REG32(USBDEV_BASE_ADDR + USBDEV_INTR_STATE_REG_OFFSET);
uint32_t usb_stat = REG32(USBDEV_BASE_ADDR + USBDEV_USBSTAT_REG_OFFSET);
- LOG_INFO("I%4x-%8x", usb_irq_state, usb_stat);
+ LOG_INFO("I%04x-%08x", usb_irq_state, usb_stat);
} else {
usb_simpleserial_send_byte(&simple_serial0, rcv_char);
usb_simpleserial_send_byte(&simple_serial1, rcv_char + 1);
diff --git a/sw/device/lib/runtime/log.c b/sw/device/lib/runtime/log.c
index 1709d44..b442b39 100644
--- a/sw/device/lib/runtime/log.c
+++ b/sw/device/lib/runtime/log.c
@@ -59,7 +59,7 @@
// nothing was printed for some time.
static uint16_t global_log_counter = 0;
- base_printf("%s%5d %s:%d] ", stringify_severity(log.severity),
+ base_printf("%s%05d %s:%d] ", stringify_severity(log.severity),
global_log_counter, base_name, log.line);
++global_log_counter;
diff --git a/sw/device/lib/testing/test_framework/test_coverage_llvm.c b/sw/device/lib/testing/test_framework/test_coverage_llvm.c
index 6206120..4376488 100644
--- a/sw/device/lib/testing/test_framework/test_coverage_llvm.c
+++ b/sw/device/lib/testing/test_framework/test_coverage_llvm.c
@@ -49,7 +49,7 @@
*/
static void send_buffer(uint8_t *buf, size_t len) {
for (uint32_t i = 0; i < len; ++i) {
- base_printf("%2X", buf[i]);
+ base_printf("%02X", buf[i]);
}
}
diff --git a/sw/device/sca/lib/simple_serial.c b/sw/device/sca/lib/simple_serial.c
index 1d48a36..ca8a8af 100644
--- a/sw/device/sca/lib/simple_serial.c
+++ b/sw/device/sca/lib/simple_serial.c
@@ -222,7 +222,7 @@
void simple_serial_print_hex(const uint8_t *data, size_t data_len) {
char buf[2];
for (size_t i = 0; i < data_len; ++i) {
- base_snprintf(&buf[0], 2, "%2x", data[i]);
+ base_snprintf(&buf[0], 2, "%02x", data[i]);
IGNORE_RESULT(dif_uart_byte_send_polled(uart, buf[0]));
IGNORE_RESULT(dif_uart_byte_send_polled(uart, buf[1]));
}
diff --git a/sw/device/tests/otp_ctrl_smoketest.c b/sw/device/tests/otp_ctrl_smoketest.c
index cfce829..547558f 100644
--- a/sw/device/tests/otp_ctrl_smoketest.c
+++ b/sw/device/tests/otp_ctrl_smoketest.c
@@ -46,7 +46,7 @@
otp_ctrl_testutils_wait_for_dai(&otp);
CHECK_DIF_OK(dif_otp_ctrl_dai_program32(
&otp, kDifOtpCtrlPartitionVendorTest, 0x10 + i, word),
- "Failed to program word kTestData[%d] = 0x%8x.", i, word);
+ "Failed to program word kTestData[%d] = 0x%08x.", i, word);
}
uint32_t readout[ARRAYSIZE(kTestData) / sizeof(uint32_t)] = {0};
diff --git a/sw/device/tests/sim_dv/pwrmgr_usbdev_smoketest.c b/sw/device/tests/sim_dv/pwrmgr_usbdev_smoketest.c
index 439592b..949556a 100644
--- a/sw/device/tests/sim_dv/pwrmgr_usbdev_smoketest.c
+++ b/sw/device/tests/sim_dv/pwrmgr_usbdev_smoketest.c
@@ -57,7 +57,7 @@
low_power_exit = true;
LOG_INFO("USB wakeup detected");
} else {
- LOG_ERROR("Unexpected wakeup reason (types: %2x, sources: %8x)",
+ LOG_ERROR("Unexpected wakeup reason (types: %02x, sources: %08x)",
wakeup_reason.types, wakeup_reason.request_sources);
return false;
}
diff --git a/sw/device/tests/sim_dv/uart_tx_rx_test.c b/sw/device/tests/sim_dv/uart_tx_rx_test.c
index fdc046f..a85aac2 100644
--- a/sw/device/tests/sim_dv/uart_tx_rx_test.c
+++ b/sw/device/tests/sim_dv/uart_tx_rx_test.c
@@ -528,7 +528,7 @@
bool test_main(void) {
update_uart_base_addr_and_irq_id();
- LOG_INFO("Test UART%d with base_addr: %8x", kUartIdx, uart_base_addr);
+ LOG_INFO("Test UART%d with base_addr: %08x", kUartIdx, uart_base_addr);
// TODO, remove thse once pinout configuration is provided
pinmux_connect_uart_to_pads(
diff --git a/sw/device/tests/sram_ctrl_smoketest.c b/sw/device/tests/sram_ctrl_smoketest.c
index 2843f9b..e50c4d0 100644
--- a/sw/device/tests/sram_ctrl_smoketest.c
+++ b/sw/device/tests/sram_ctrl_smoketest.c
@@ -42,8 +42,8 @@
mmio_region_write32(base_addr_region, i * sizeof(uint32_t), kRandomData[i]);
rw_data_32 = mmio_region_read32(base_addr_region, i * sizeof(uint32_t));
CHECK(rw_data_32 == kRandomData[i],
- "Memory Write/Read Mismatch for %s, index %d, data read = %8x "
- "data_expected = %8x.",
+ "Memory Write/Read Mismatch for %s, index %d, data read = %08x "
+ "data_expected = %08x.",
sram_name, i, rw_data_32, kRandomData[i]);
}
}
@@ -67,9 +67,9 @@
CHECK_DIF_OK(dif_sram_ctrl_get_status(&sram_ctrl_main, &status_main));
CHECK((status_main & kStatusRegMask) == 0x0,
- "SRAM main status error bits set, status = %8x.", status_main);
+ "SRAM main status error bits set, status = %08x.", status_main);
CHECK((status_ret & kStatusRegMask) == 0x0,
- "SRAM ret status error bits set, status = %8x.", status_ret);
+ "SRAM ret status error bits set, status = %08x.", status_ret);
// Read and Write to/from SRAMs. Main SRAM will use the address of the
// buffer that has been allocated. Ret SRAM can start at the base address.