maintenance: constify some read only things
What changed, and why it matters
This commit is a routine code-quality cleanup. It marks several function parameters as 'read-only' (const) to make the code clearer and prevent accidental modification. There is no change to program logic, no bug fix, and no security-relevant behavior change.
No action required. This is a non-functional maintenance change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds the const qualifier to pointer parameters in da14531_handler.c/h and memory_shared.c/h. Functions _ctrl_handler, _hww_handler, da14531_handler, and memory_set_ble_bond_db now accept const pointers. The internal cast in da14531_handler is updated to const struct da14531_ctrl_frame*. No logic, validation, or memory-access patterns are altered.
Changed components
src/da14531/da14531_handler.csrc/da14531/da14531_handler.hsrc/memory/memory_shared.csrc/memory/memory_shared.hInspect captured patch +7 / −7
diff --git a/src/da14531/da14531_handler.c b/src/da14531/da14531_handler.c
index c15e49a..76460c2 100644
--- a/src/da14531/da14531_handler.c
+++ b/src/da14531/da14531_handler.c
@@ -72,7 +72,7 @@ bool da14531_handler_bond_db_set(void)
}
#endif
-static void _ctrl_handler(struct da14531_ctrl_frame* frame, struct ringbuffer* queue)
+static void _ctrl_handler(const struct da14531_ctrl_frame* frame, struct ringbuffer* queue)
{
switch (frame->cmd) {
case CTRL_CMD_DEVICE_NAME: {
@@ -267,7 +267,7 @@ static void _ctrl_handler(struct da14531_ctrl_frame* frame, struct ringbuffer* q
}
}
-static void _hww_handler(struct da14531_protocol_frame* frame, struct ringbuffer* queue)
+static void _hww_handler(const struct da14531_protocol_frame* frame, struct ringbuffer* queue)
{
// util_log(" in: %s", util_dbg_hex(frame->payload, 64));
(void)queue;
@@ -281,12 +281,12 @@ static void _hww_handler(struct da14531_protocol_frame* frame, struct ringbuffer
}
// Handler must not use the frame pointer after it has returned
-void da14531_handler(struct da14531_protocol_frame* frame, struct ringbuffer* queue)
+void da14531_handler(const struct da14531_protocol_frame* frame, struct ringbuffer* queue)
{
// util_log("handler called");
switch (frame->type) {
case DA14531_PROTOCOL_PACKET_TYPE_CTRL_DATA:
- _ctrl_handler((struct da14531_ctrl_frame*)frame, queue);
+ _ctrl_handler((const struct da14531_ctrl_frame*)frame, queue);
break;
case DA14531_PROTOCOL_PACKET_TYPE_BLE_DATA:
_hww_handler(frame, queue);
diff --git a/src/da14531/da14531_handler.h b/src/da14531/da14531_handler.h
index 6807ee5..5a45fac 100644
--- a/src/da14531/da14531_handler.h
+++ b/src/da14531/da14531_handler.h
@@ -14,6 +14,6 @@ extern uint16_t da14531_handler_current_product_len;
bool da14531_handler_bond_db_set(void);
#endif
-void da14531_handler(struct da14531_protocol_frame* frame, struct ringbuffer* queue);
+void da14531_handler(const struct da14531_protocol_frame* frame, struct ringbuffer* queue);
#endif
diff --git a/src/memory/memory_shared.c b/src/memory/memory_shared.c
index 449d973..c5aa24b 100644
--- a/src/memory/memory_shared.c
+++ b/src/memory/memory_shared.c
@@ -170,7 +170,7 @@ int16_t memory_get_ble_bond_db(uint8_t* data)
return len;
}
-bool memory_set_ble_bond_db(uint8_t* data, int16_t data_len)
+bool memory_set_ble_bond_db(const uint8_t* data, int16_t data_len)
{
ASSERT(data_len <= MEMORY_BLE_BOND_DB_LEN);
if (data_len > MEMORY_BLE_BOND_DB_LEN) {
diff --git a/src/memory/memory_shared.h b/src/memory/memory_shared.h
index 88974f9..68f81e8 100644
--- a/src/memory/memory_shared.h
+++ b/src/memory/memory_shared.h
@@ -144,7 +144,7 @@ void memory_get_ble_irk(uint8_t* data);
void memory_get_ble_identity_address(uint8_t* data);
// data_len can be at most MEMORY_BLE_BOND_DB_LEN
-bool memory_set_ble_bond_db(uint8_t* data, int16_t data_len);
+bool memory_set_ble_bond_db(const uint8_t* data, int16_t data_len);
typedef struct {
uint8_t allowed_firmware_hash[32];
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.