style: subsys: comply with MISRA C:2012 Rule 15.6

Add missing braces to comply with MISRA C:2012 Rule 15.6 and
also following Zephyr's style guideline.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
This commit is contained in:
Pisit Sawangvonganan 2024-08-21 03:41:41 +07:00 committed by Anas Nashif
commit ead0dfc889
9 changed files with 30 additions and 15 deletions

View file

@ -2478,8 +2478,9 @@ static int att_change_security(struct bt_conn *conn, uint8_t err)
switch (err) {
case BT_ATT_ERR_INSUFFICIENT_ENCRYPTION:
if (conn->sec_level >= BT_SECURITY_L2)
if (conn->sec_level >= BT_SECURITY_L2) {
return -EALREADY;
}
sec = BT_SECURITY_L2;
break;
case BT_ATT_ERR_AUTHENTICATION:

View file

@ -828,8 +828,9 @@ static uint8_t gen_hash_m(const struct bt_gatt_attr *attr, uint16_t handle,
ssize_t len;
uint16_t value;
if (attr->uuid->type != BT_UUID_TYPE_16)
if (attr->uuid->type != BT_UUID_TYPE_16) {
return BT_GATT_ITER_CONTINUE;
}
u16 = (struct bt_uuid_16 *)attr->uuid;
@ -3780,8 +3781,9 @@ static void gatt_discover_next(struct bt_conn *conn, uint16_t last_handle,
struct bt_gatt_discover_params *params)
{
/* Skip if last_handle is not set */
if (!last_handle)
if (!last_handle) {
goto discover;
}
/* Continue from the last found handle */
params->start_handle = last_handle;

View file

@ -5232,11 +5232,13 @@ static int smp_f6_test(void)
int err;
err = bt_crypto_f6(w, n1, n2, r, io_cap, &a1, &a2, res);
if (err)
if (err) {
return err;
}
if (memcmp(res, exp, 16))
if (memcmp(res, exp, 16)) {
return -EINVAL;
}
return 0;
}

View file

@ -298,8 +298,9 @@ static bool data_cb(struct bt_data *data, void *user_data)
static void print_data_hex(const uint8_t *data, uint8_t len, enum shell_vt100_color color)
{
if (len == 0)
if (len == 0) {
return;
}
shell_fprintf(ctx_shell, color, "0x");
/* Reverse the byte order when printing as advertising data is LE

View file

@ -278,8 +278,9 @@ static int thread_analyzer_init(void)
}
snprintf(name, sizeof(name), "core %u thread analyzer", i);
ret = k_thread_name_set(tid, name);
if (ret < 0)
if (ret < 0) {
LOG_INF("k_thread_name_set failed: %d for %u", ret, i);
}
k_thread_start(tid);
LOG_DBG("Thread %p for core %u started", tid, i);

View file

@ -44,10 +44,12 @@ static size_t llext_file_offset(struct llext_loader *ldr, size_t offset)
{
unsigned int i;
for (i = 0; i < LLEXT_MEM_COUNT; i++)
for (i = 0; i < LLEXT_MEM_COUNT; i++) {
if (ldr->sects[i].sh_addr <= offset &&
ldr->sects[i].sh_addr + ldr->sects[i].sh_size > offset)
ldr->sects[i].sh_addr + ldr->sects[i].sh_size > offset) {
return offset - ldr->sects[i].sh_addr + ldr->sects[i].sh_offset;
}
}
return offset;
}

View file

@ -26,8 +26,9 @@ static inline bool in_text_region(uintptr_t addr)
*/
size_t arch_perf_current_stack_trace(uintptr_t *buf, size_t size)
{
if (size < 2U)
if (size < 2U) {
return 0;
}
size_t idx = 0;
@ -79,8 +80,9 @@ size_t arch_perf_current_stack_trace(uintptr_t *buf, size_t size)
fp = new_fp;
}
while (valid_stack((uintptr_t)fp, _current)) {
if (idx >= size)
if (idx >= size) {
return 0;
}
if (!in_text_region((uintptr_t)fp[-1])) {
break;

View file

@ -36,8 +36,9 @@ struct isf {
*/
size_t arch_perf_current_stack_trace(uintptr_t *buf, size_t size)
{
if (size < 1U)
if (size < 1U) {
return 0;
}
size_t idx = 0;
@ -67,8 +68,9 @@ size_t arch_perf_current_stack_trace(uintptr_t *buf, size_t size)
buf[idx++] = (uintptr_t)isf->eip;
while (valid_stack((uintptr_t)fp, _current)) {
if (idx >= size)
if (idx >= size) {
return 0;
}
if (!in_text_region((uintptr_t)fp[1])) {
break;

View file

@ -27,8 +27,9 @@ static inline bool in_text_region(uintptr_t addr)
*/
size_t arch_perf_current_stack_trace(uintptr_t *buf, size_t size)
{
if (size < 1U)
if (size < 1U) {
return 0;
}
size_t idx = 0;
@ -53,8 +54,9 @@ size_t arch_perf_current_stack_trace(uintptr_t *buf, size_t size)
* ....
*/
while (valid_stack((uintptr_t)fp, _current)) {
if (idx >= size)
if (idx >= size) {
return 0;
}
if (!in_text_region((uintptr_t)fp[1])) {
break;