From 8f197c955d22633b1891c2027f5a07106bbfff94 Mon Sep 17 00:00:00 2001 From: Pisit Sawangvonganan Date: Fri, 16 Aug 2024 13:34:07 +0700 Subject: [PATCH] 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 --- .../coredump_backend_intel_adsp_mem_window.c | 3 ++- subsys/debug/thread_analyzer.c | 18 +++++++++++------- subsys/fs/fat_fs.c | 5 +++-- subsys/ipc/ipc_service/lib/ipc_static_vrings.c | 3 ++- subsys/llext/llext_link.c | 3 ++- .../logging/backends/log_backend_adsp_mtrace.c | 3 ++- .../backends/ec_host_cmd_backend_espi.c | 3 ++- subsys/net/ip/net_pkt.c | 3 ++- subsys/net/lib/zperf/zperf_udp_receiver.c | 12 ++++++++---- .../tracing_backend_adsp_memory_window.c | 3 ++- 10 files changed, 36 insertions(+), 20 deletions(-) diff --git a/subsys/debug/coredump/coredump_backend_intel_adsp_mem_window.c b/subsys/debug/coredump/coredump_backend_intel_adsp_mem_window.c index 2a8525d2147..06f1e5a8f6a 100644 --- a/subsys/debug/coredump/coredump_backend_intel_adsp_mem_window.c +++ b/subsys/debug/coredump/coredump_backend_intel_adsp_mem_window.c @@ -57,8 +57,9 @@ static void coredump_mem_window_backend_buffer_output(uint8_t *buf, size_t bufle /* skip the overflow data. Don't wrap around to keep the most important data * such as registers and call stack in the beginning of mem window. */ - if (mem_wptr >= ADSP_DW_SLOT_SIZE - 4) + if (mem_wptr >= ADSP_DW_SLOT_SIZE - 4) { return; + } if (buf) { for (data_left = buflen; data_left > 0; data_left--) { diff --git a/subsys/debug/thread_analyzer.c b/subsys/debug/thread_analyzer.c index f61f44d8344..9b161cbc52b 100644 --- a/subsys/debug/thread_analyzer.c +++ b/subsys/debug/thread_analyzer.c @@ -164,8 +164,9 @@ static void isr_stacks(void) { unsigned int num_cpus = arch_num_cpus(); - for (int i = 0; i < num_cpus; i++) + for (int i = 0; i < num_cpus; i++) { isr_stack(i); + } } void thread_analyzer_run(thread_analyzer_cb cb, unsigned int cpu) @@ -173,22 +174,25 @@ void thread_analyzer_run(thread_analyzer_cb cb, unsigned int cpu) struct ta_cb_user_data ud = { .cb = cb, .cpu = cpu }; if (IS_ENABLED(CONFIG_THREAD_ANALYZER_RUN_UNLOCKED)) { - if (IS_ENABLED(CONFIG_THREAD_ANALYZER_AUTO_SEPARATE_CORES)) + if (IS_ENABLED(CONFIG_THREAD_ANALYZER_AUTO_SEPARATE_CORES)) { k_thread_foreach_unlocked_filter_by_cpu(cpu, thread_analyze_cb, &ud); - else + } else { k_thread_foreach_unlocked(thread_analyze_cb, &ud); + } } else { - if (IS_ENABLED(CONFIG_THREAD_ANALYZER_AUTO_SEPARATE_CORES)) + if (IS_ENABLED(CONFIG_THREAD_ANALYZER_AUTO_SEPARATE_CORES)) { k_thread_foreach_filter_by_cpu(cpu, thread_analyze_cb, &ud); - else + } else { k_thread_foreach(thread_analyze_cb, &ud); + } } if (IS_ENABLED(CONFIG_THREAD_ANALYZER_ISR_STACK_USAGE)) { - if (IS_ENABLED(CONFIG_THREAD_ANALYZER_AUTO_SEPARATE_CORES)) + if (IS_ENABLED(CONFIG_THREAD_ANALYZER_AUTO_SEPARATE_CORES)) { isr_stack(cpu); - else + } else { isr_stacks(); + } } } diff --git a/subsys/fs/fat_fs.c b/subsys/fs/fat_fs.c index 2a0b7b7d486..20367a811a3 100644 --- a/subsys/fs/fat_fs.c +++ b/subsys/fs/fat_fs.c @@ -176,10 +176,11 @@ static int fatfs_rename(struct fs_mount_t *mountp, const char *from, /* Check if 'to' path exists; remove it if it does */ res = f_stat(translate_path(to), &fno); - if (FR_OK == res) { + if (res == FR_OK) { res = f_unlink(translate_path(to)); - if (FR_OK != res) + if (res != FR_OK) { return translate_error(res); + } } res = f_rename(translate_path(from), translate_path(to)); diff --git a/subsys/ipc/ipc_service/lib/ipc_static_vrings.c b/subsys/ipc/ipc_service/lib/ipc_static_vrings.c index e23c5deafd5..4daac52f575 100644 --- a/subsys/ipc/ipc_service/lib/ipc_static_vrings.c +++ b/subsys/ipc/ipc_service/lib/ipc_static_vrings.c @@ -166,8 +166,9 @@ int ipc_static_vrings_init(struct ipc_static_vrings *vr, unsigned int role) return -EINVAL; } - if (!vr->shm_device.name) + if (!vr->shm_device.name) { vr->shm_device.name = SHM_DEVICE_DEFAULT_NAME; + } vr->shm_device.num_regions = 1; vr->shm_physmap[0] = vr->shm_addr; diff --git a/subsys/llext/llext_link.c b/subsys/llext/llext_link.c index dcbd441d0e1..4ee19f57583 100644 --- a/subsys/llext/llext_link.c +++ b/subsys/llext/llext_link.c @@ -144,8 +144,9 @@ static void llext_link_plt(struct llext_loader *ldr, struct llext *ext, link_addr = llext_find_sym(NULL, SYM_NAME_OR_SLID(name, sym_tbl.st_value)); - if (!link_addr) + if (!link_addr) { link_addr = llext_find_sym(&ext->sym_tab, name); + } if (!link_addr) { LOG_WRN("PLT: cannot find idx %u name %s", j, name); diff --git a/subsys/logging/backends/log_backend_adsp_mtrace.c b/subsys/logging/backends/log_backend_adsp_mtrace.c index 1eaeb2050ea..d18ae6e52b1 100644 --- a/subsys/logging/backends/log_backend_adsp_mtrace.c +++ b/subsys/logging/backends/log_backend_adsp_mtrace.c @@ -133,8 +133,9 @@ static int char_out(uint8_t *data, size_t length, void *ctx) if (mtrace_active && mtrace_hook) { /* if we are in panic mode, need to flush out asap */ - if (unlikely(mtrace_panic_mode)) + if (unlikely(mtrace_panic_mode)) { space_left = 0; + } mtrace_hook(out, space_left); } diff --git a/subsys/mgmt/ec_host_cmd/backends/ec_host_cmd_backend_espi.c b/subsys/mgmt/ec_host_cmd/backends/ec_host_cmd_backend_espi.c index 09224ffdac2..b64bd401b18 100644 --- a/subsys/mgmt/ec_host_cmd/backends/ec_host_cmd_backend_espi.c +++ b/subsys/mgmt/ec_host_cmd/backends/ec_host_cmd_backend_espi.c @@ -131,8 +131,9 @@ static int ec_host_cmd_espi_send(const struct ec_host_cmd_backend *backend) int ret; /* Ignore in-progress on eSPI since interface is synchronous anyway */ - if (result == EC_HOST_CMD_IN_PROGRESS) + if (result == EC_HOST_CMD_IN_PROGRESS) { return 0; + } hc_espi->state = ESPI_STATE_SENDING; diff --git a/subsys/net/ip/net_pkt.c b/subsys/net/ip/net_pkt.c index 83e92305a19..9faf8305939 100644 --- a/subsys/net/ip/net_pkt.c +++ b/subsys/net/ip/net_pkt.c @@ -1835,8 +1835,9 @@ static void clone_pkt_lladdr(struct net_pkt *pkt, struct net_pkt *clone_pkt, { int32_t ll_addr_offset; - if (!lladdr->addr) + if (!lladdr->addr) { return; + } ll_addr_offset = net_pkt_find_offset(pkt, lladdr->addr); diff --git a/subsys/net/lib/zperf/zperf_udp_receiver.c b/subsys/net/lib/zperf/zperf_udp_receiver.c index 9991cf50fcc..0f7e1e4f077 100644 --- a/subsys/net/lib/zperf/zperf_udp_receiver.c +++ b/subsys/net/lib/zperf/zperf_udp_receiver.c @@ -236,8 +236,9 @@ static void zperf_udp_join_mcast_ipv4(char *if_name, struct in_addr *addr) if (if_name[0]) { iface = net_if_get_by_index(net_if_get_by_name(if_name)); - if (iface == NULL) + if (iface == NULL) { iface = net_if_get_default(); + } } else { iface = net_if_get_default(); } @@ -253,8 +254,9 @@ static void zperf_udp_join_mcast_ipv6(char *if_name, struct in6_addr *addr) if (if_name[0]) { iface = net_if_get_by_index(net_if_get_by_name(if_name)); - if (iface == NULL) + if (iface == NULL) { iface = net_if_get_default(); + } } else { iface = net_if_get_default(); } @@ -275,15 +277,17 @@ static void zperf_udp_leave_mcast(int sock) if (IS_ENABLED(CONFIG_NET_IPV4) && addr.sa_family == AF_INET) { struct sockaddr_in *addr4 = (struct sockaddr_in *)&addr; - if (net_ipv4_is_addr_mcast(&addr4->sin_addr)) + if (net_ipv4_is_addr_mcast(&addr4->sin_addr)) { net_ipv4_igmp_leave(iface, &addr4->sin_addr); + } } if (IS_ENABLED(CONFIG_NET_IPV6) && addr.sa_family == AF_INET6) { struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&addr; - if (net_ipv6_is_addr_mcast(&addr6->sin6_addr)) + if (net_ipv6_is_addr_mcast(&addr6->sin6_addr)) { net_ipv6_mld_leave(iface, &addr6->sin6_addr); + } } } diff --git a/subsys/tracing/tracing_backend_adsp_memory_window.c b/subsys/tracing/tracing_backend_adsp_memory_window.c index 2efcb6477f3..43f8229ad96 100644 --- a/subsys/tracing/tracing_backend_adsp_memory_window.c +++ b/subsys/tracing/tracing_backend_adsp_memory_window.c @@ -41,8 +41,9 @@ static void tracing_backend_adsp_memory_window_output( if (length) { memcpy((void *)mem_window->data, data + to_copy, length); mem_window->head_offset = length; - } else + } else { mem_window->head_offset += to_copy; + } } static void tracing_backend_adsp_memory_window_init(void)