da14531: simplify da14531_set_name by dropping len param
What changed, and why it matters
This is a small code cleanup change. A function that sends the device's Bluetooth name to a wireless chip is simplified by removing an unnecessary length parameter. The function now figures out the string length itself using strlen(), which is exactly what every caller was already doing. There is no security issue visible in this change.
No security action required. This is a routine refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors da14531_set_name() to drop the explicit name_len parameter and instead compute it internally with strlen(name). Callers in startup.c and firmware_main_loop.c are updated accordingly. The function’s behavior is unchanged: it still copies at most sizeof(payload)-1 bytes into a 64-byte local payload buffer using MIN(name_len, sizeof(payload) - 1). The input buffers are fixed-size stack arrays populated by memory_random_name() and memory_get_device_name(), and the function does not introduce new trust boundaries, parsing, or memory operations.
Changed components
src/da14531/da14531.csrc/da14531/da14531.hsrc/bootloader/startup.csrc/firmware_main_loop.cInspect captured patch +5 / −4
diff --git a/src/bootloader/startup.c b/src/bootloader/startup.c
index fb39534..5ab51d2 100644
--- a/src/bootloader/startup.c
+++ b/src/bootloader/startup.c
@@ -101,7 +101,7 @@ int main(void)
// only the MCU.
char buf[MEMORY_DEVICE_NAME_MAX_LEN] = {0};
memory_random_name(buf);
- da14531_set_name(buf, strlen(buf), &uart_write_queue);
+ da14531_set_name(buf, &uart_write_queue);
// Ask for the current conection state
da14531_get_connection_state(&uart_write_queue);
diff --git a/src/da14531/da14531.c b/src/da14531/da14531.c
index a00eb45..87e5570 100644
--- a/src/da14531/da14531.c
+++ b/src/da14531/da14531.c
@@ -60,8 +60,9 @@ void da14531_set_product(
}
}
-void da14531_set_name(const char* name, size_t name_len, struct ringbuffer* uart_out)
+void da14531_set_name(const char* name, struct ringbuffer* uart_out)
{
+ size_t name_len = strlen(name);
uint8_t payload[64] = {0};
payload[0] = CTRL_CMD_DEVICE_NAME;
memcpy(&payload[1], name, MIN(name_len, sizeof(payload) - 1));
diff --git a/src/da14531/da14531.h b/src/da14531/da14531.h
index dab8fad..6b6e3d0 100644
--- a/src/da14531/da14531.h
+++ b/src/da14531/da14531.h
@@ -40,7 +40,7 @@ void da14531_set_product(
volatile uint16_t product_len,
struct ringbuffer* uart_out);
-void da14531_set_name(const char* name, size_t name_len, struct ringbuffer* uart_out);
+void da14531_set_name(const char* name, struct ringbuffer* uart_out);
void da14531_get_connection_state(struct ringbuffer* uart_out);
diff --git a/src/firmware_main_loop.c b/src/firmware_main_loop.c
index bc57cfe..7305c11 100644
--- a/src/firmware_main_loop.c
+++ b/src/firmware_main_loop.c
@@ -68,7 +68,7 @@ void firmware_main_loop(void)
/// the fw. Send it over.
char buf[MEMORY_DEVICE_NAME_MAX_LEN] = {0};
memory_get_device_name(buf);
- da14531_set_name(buf, strlen(buf), &uart_write_queue);
+ da14531_set_name(buf, &uart_write_queue);
// This starts the async orientation screen workflow, which is processed by the loop below.
rust_workflow_spawn_orientation_screen();
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.