Problem
setRx() takes u1_t timeout[SX126X_TIMEOUT_LEN] as a parameter, and SX126X_TIMEOUT_LEN is used in three separate places to construct timeout arrays before calling setRx(). This has two problems:
- DRY violation: the timeout array construction is repeated at each call site.
- Array-as-parameter pitfall: C decays
u1_t timeout[SX126X_TIMEOUT_LEN] to u1_t *timeout, so sizeof(timeout) gives pointer size, not SX126X_TIMEOUT_LEN. This makes the code fragile if anyone adds a sizeof check or tries to validate the parameter.
Proposed fix
Define a struct:
```c
typedef struct {
u1_t bytes[SX126X_TIMEOUT_LEN];
} sx126x_timeout_t;
```
Change setRx() to take const sx126x_timeout_t *timeout, and update the three call sites. This makes the size self-documenting and prevents decay-to-pointer issues.
Files
src/lmic/radio_sx126x.c: setRx() definition and all call sites
Problem
setRx()takesu1_t timeout[SX126X_TIMEOUT_LEN]as a parameter, andSX126X_TIMEOUT_LENis used in three separate places to construct timeout arrays before callingsetRx(). This has two problems:u1_t timeout[SX126X_TIMEOUT_LEN]tou1_t *timeout, sosizeof(timeout)gives pointer size, notSX126X_TIMEOUT_LEN. This makes the code fragile if anyone adds asizeofcheck or tries to validate the parameter.Proposed fix
Define a struct:
```c
typedef struct {
u1_t bytes[SX126X_TIMEOUT_LEN];
} sx126x_timeout_t;
```
Change
setRx()to takeconst sx126x_timeout_t *timeout, and update the three call sites. This makes the size self-documenting and prevents decay-to-pointer issues.Files
src/lmic/radio_sx126x.c:setRx()definition and all call sites