From 380ec2ac46606c7fc2db796499e10f10076384f6 Mon Sep 17 00:00:00 2001 From: hedger Date: Wed, 31 Jul 2024 19:38:20 +0300 Subject: [PATCH] Added `-Wundef` to compiler options (#3815) * fbt: added -Wundef to compiler options; libs: various small fixes for missing defines; desktop: proper access to current RTOS config * apps: fixes for FURI_DEBUG handling * rpc: unified definition checks * Cleanup various defines use * Cleanup configs and move SVCall ISR priority configuration to furi_hal_interrupts Co-authored-by: Aleksandr Kutuzov --- applications/services/cli/cli_commands.c | 4 ++-- .../services/desktop/views/desktop_view_locked.c | 5 ++--- .../desktop/views/desktop_view_pin_timeout.c | 6 +----- applications/services/rpc/rpc.c | 8 ++++---- applications/settings/system/system_settings.c | 4 ++-- furi/furi.c | 7 ------- furi/furi.h | 2 +- lib/drivers/bq25896_reg.h | 4 ++-- lib/drivers/lp5562_reg.h | 4 ++-- site_scons/cc.scons | 1 + targets/f7/ble_glue/app_conf.h | 4 ++++ targets/f7/ble_glue/ble_conf.h | 12 ++++++++++++ targets/f7/furi_hal/furi_hal_interrupt.c | 1 + targets/f7/inc/FreeRTOSConfig.h | 3 ++- 14 files changed, 36 insertions(+), 29 deletions(-) diff --git a/applications/services/cli/cli_commands.c b/applications/services/cli/cli_commands.c index 5a1b11d803..b4eeebbe63 100644 --- a/applications/services/cli/cli_commands.c +++ b/applications/services/cli/cli_commands.c @@ -260,7 +260,7 @@ void cli_command_sysctl_heap_track(Cli* cli, FuriString* args, void* context) { } else if(!furi_string_cmp(args, "main")) { furi_hal_rtc_set_heap_track_mode(FuriHalRtcHeapTrackModeMain); printf("Heap tracking enabled for application main thread"); -#if FURI_DEBUG +#ifdef FURI_DEBUG } else if(!furi_string_cmp(args, "tree")) { furi_hal_rtc_set_heap_track_mode(FuriHalRtcHeapTrackModeTree); printf("Heap tracking enabled for application main and child threads"); @@ -279,7 +279,7 @@ void cli_command_sysctl_print_usage(void) { printf("Cmd list:\r\n"); printf("\tdebug <0|1>\t - Enable or disable system debug\r\n"); -#if FURI_DEBUG +#ifdef FURI_DEBUG printf("\theap_track \t - Set heap allocation tracking mode\r\n"); #else printf("\theap_track \t - Set heap allocation tracking mode\r\n"); diff --git a/applications/services/desktop/views/desktop_view_locked.c b/applications/services/desktop/views/desktop_view_locked.c index 81d3fc65f5..f3b001e1e0 100644 --- a/applications/services/desktop/views/desktop_view_locked.c +++ b/applications/services/desktop/views/desktop_view_locked.c @@ -1,12 +1,11 @@ -#include -#include #include + #include #include #include + #include -#include #include "../desktop_i.h" #include "desktop_view_locked.h" diff --git a/applications/services/desktop/views/desktop_view_pin_timeout.c b/applications/services/desktop/views/desktop_view_pin_timeout.c index 2811ba7d25..d7e5507a75 100644 --- a/applications/services/desktop/views/desktop_view_pin_timeout.c +++ b/applications/services/desktop/views/desktop_view_pin_timeout.c @@ -1,9 +1,5 @@ - #include -#include -#include -#include -#include + #include #include diff --git a/applications/services/rpc/rpc.c b/applications/services/rpc/rpc.c index 6ad16fbff4..00ec2259c7 100644 --- a/applications/services/rpc/rpc.c +++ b/applications/services/rpc/rpc.c @@ -228,7 +228,7 @@ bool rpc_pb_stream_read(pb_istream_t* istream, pb_byte_t* buf, size_t count) { } } -#if SRV_RPC_DEBUG +#ifdef SRV_RPC_DEBUG rpc_debug_print_data("INPUT", buf, bytes_received); #endif @@ -268,7 +268,7 @@ static int32_t rpc_session_worker(void* context) { bool message_decode_failed = false; if(pb_decode_ex(&istream, &PB_Main_msg, session->decoded_message, PB_DECODE_DELIMITED)) { -#if SRV_RPC_DEBUG +#ifdef SRV_RPC_DEBUG FURI_LOG_I(TAG, "INPUT:"); rpc_debug_print_message(session->decoded_message); #endif @@ -452,7 +452,7 @@ void rpc_send(RpcSession* session, PB_Main* message) { pb_ostream_t ostream = PB_OSTREAM_SIZING; -#if SRV_RPC_DEBUG +#ifdef SRV_RPC_DEBUG FURI_LOG_I(TAG, "OUTPUT:"); rpc_debug_print_message(message); #endif @@ -465,7 +465,7 @@ void rpc_send(RpcSession* session, PB_Main* message) { pb_encode_ex(&ostream, &PB_Main_msg, message, PB_ENCODE_DELIMITED); -#if SRV_RPC_DEBUG +#ifdef SRV_RPC_DEBUG rpc_debug_print_data("OUTPUT", buffer, ostream.bytes_written); #endif diff --git a/applications/settings/system/system_settings.c b/applications/settings/system/system_settings.c index 73969de31e..636d49b42a 100644 --- a/applications/settings/system/system_settings.c +++ b/applications/settings/system/system_settings.c @@ -92,7 +92,7 @@ static void debug_changed(VariableItem* item) { const char* const heap_trace_mode_text[] = { "None", "Main", -#if FURI_DEBUG +#ifdef FURI_DEBUG "Tree", "All", #endif @@ -101,7 +101,7 @@ const char* const heap_trace_mode_text[] = { const uint32_t heap_trace_mode_value[] = { FuriHalRtcHeapTrackModeNone, FuriHalRtcHeapTrackModeMain, -#if FURI_DEBUG +#ifdef FURI_DEBUG FuriHalRtcHeapTrackModeTree, FuriHalRtcHeapTrackModeAll, #endif diff --git a/furi/furi.c b/furi/furi.c index dca674da57..f4e64ee099 100644 --- a/furi/furi.c +++ b/furi/furi.c @@ -15,13 +15,6 @@ void furi_run(void) { furi_check(!furi_kernel_is_irq_or_masked()); furi_check(xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED); -#if(__ARM_ARCH_7A__ == 0U) - /* Service Call interrupt might be configured before kernel start */ - /* and when its priority is lower or equal to BASEPRI, svc instruction */ - /* causes a Hard Fault. */ - NVIC_SetPriority(SVCall_IRQn, 0U); -#endif - /* Start the kernel scheduler */ vTaskStartScheduler(); } diff --git a/furi/furi.h b/furi/furi.h index 80ee30457c..d75debe987 100644 --- a/furi/furi.h +++ b/furi/furi.h @@ -2,8 +2,8 @@ #include -#include "core/check.h" #include "core/common_defines.h" +#include "core/check.h" #include "core/event_loop.h" #include "core/event_loop_timer.h" #include "core/event_flag.h" diff --git a/lib/drivers/bq25896_reg.h b/lib/drivers/bq25896_reg.h index 23d094003a..baadf6df27 100644 --- a/lib/drivers/bq25896_reg.h +++ b/lib/drivers/bq25896_reg.h @@ -3,8 +3,8 @@ #include #include -#if BITS_BIG_ENDIAN == 1 -#error Bit structures defined in this file is not portable to BE +#if defined(BITS_BIG_ENDIAN) && BITS_BIG_ENDIAN == 1 +#error Bit structures defined in this file are not portable to BE #endif #define BQ25896_ADDRESS 0xD6 diff --git a/lib/drivers/lp5562_reg.h b/lib/drivers/lp5562_reg.h index 9103e5395f..a901cbada3 100644 --- a/lib/drivers/lp5562_reg.h +++ b/lib/drivers/lp5562_reg.h @@ -1,7 +1,7 @@ #pragma once -#if BITS_BIG_ENDIAN == 1 -#error Bit structures defined in this file is not portable to BE +#if defined(BITS_BIG_ENDIAN) && BITS_BIG_ENDIAN == 1 +#error Bit structures defined in this file are not portable to BE #endif #define LP5562_ADDRESS 0x60 diff --git a/site_scons/cc.scons b/site_scons/cc.scons index 603ec621c6..c5d99b8965 100644 --- a/site_scons/cc.scons +++ b/site_scons/cc.scons @@ -28,6 +28,7 @@ ENV.AppendUnique( "-Wno-address-of-packed-member", "-Wredundant-decls", "-Wdouble-promotion", + "-Wundef", "-fdata-sections", "-ffunction-sections", "-fsingle-precision-constant", diff --git a/targets/f7/ble_glue/app_conf.h b/targets/f7/ble_glue/app_conf.h index 43be8129dc..9ceb747c19 100644 --- a/targets/f7/ble_glue/app_conf.h +++ b/targets/f7/ble_glue/app_conf.h @@ -194,3 +194,7 @@ 255 /**< Set to 255 with the memory manager and the mailbox */ #define TL_BLE_EVENT_FRAME_SIZE (TL_EVT_HDR_SIZE + CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE) + +/* Various defines for compatibility with -Wundef - thanks, ST */ +#define CFG_DEBUG_TRACE_FULL 0 +#define CFG_DEBUG_TRACE_LIGHT 0 diff --git a/targets/f7/ble_glue/ble_conf.h b/targets/f7/ble_glue/ble_conf.h index 4c523a707e..c34c54de66 100644 --- a/targets/f7/ble_glue/ble_conf.h +++ b/targets/f7/ble_glue/ble_conf.h @@ -9,3 +9,15 @@ #define BLE_CFG_SVC_MAX_NBR_CB 0 #define BLE_CFG_CLT_MAX_NBR_CB 0 + +/* Various defines for compatibility with -Wundef - thanks, ST */ +#define BLE_CFG_BLS_INTERMEDIATE_CUFF_PRESSURE 0 +#define BLE_CFG_BLS_TIME_STAMP_FLAG 0 +#define BLE_CFG_BLS_PULSE_RATE_FLAG 0 +#define BLE_CFG_BLS_USER_ID_FLAG 0 +#define BLE_CFG_BLS_MEASUREMENT_STATUS_FLAG 0 +#define BLE_CFG_HRS_ENERGY_EXPENDED_INFO_FLAG 0 +#define BLE_CFG_HRS_ENERGY_RR_INTERVAL_FLAG 0 +#define BLE_CFG_HTS_MEASUREMENT_INTERVAL 0 +#define BLE_CFG_HTS_TIME_STAMP_FLAG 0 +#define BLE_CFG_HTS_TEMPERATURE_TYPE_VALUE_STATIC 0 diff --git a/targets/f7/furi_hal/furi_hal_interrupt.c b/targets/f7/furi_hal/furi_hal_interrupt.c index 35c40c2595..cf10c8d33d 100644 --- a/targets/f7/furi_hal/furi_hal_interrupt.c +++ b/targets/f7/furi_hal/furi_hal_interrupt.c @@ -120,6 +120,7 @@ void furi_hal_interrupt_init(void) { TAMP_STAMP_LSECSS_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); NVIC_EnableIRQ(TAMP_STAMP_LSECSS_IRQn); + NVIC_SetPriority(SVCall_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); NVIC_SetPriority(PendSV_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 15, 0)); NVIC_SetPriority(FPU_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 15, 0)); diff --git a/targets/f7/inc/FreeRTOSConfig.h b/targets/f7/inc/FreeRTOSConfig.h index 62310511d2..2948faef93 100644 --- a/targets/f7/inc/FreeRTOSConfig.h +++ b/targets/f7/inc/FreeRTOSConfig.h @@ -17,11 +17,13 @@ #define configUSE_PREEMPTION 1 #define configSUPPORT_STATIC_ALLOCATION 1 #define configSUPPORT_DYNAMIC_ALLOCATION 0 +#define configUSE_MALLOC_FAILED_HOOK 0 #define configUSE_IDLE_HOOK 0 #define configUSE_TICK_HOOK 0 #define configCPU_CLOCK_HZ (SystemCoreClock) #define configTICK_RATE_HZ_RAW 1000 #define configTICK_RATE_HZ ((TickType_t)configTICK_RATE_HZ_RAW) +#define configUSE_16_BIT_TICKS 0 #define configMAX_PRIORITIES (32) #define configMINIMAL_STACK_SIZE ((uint16_t)128) @@ -34,7 +36,6 @@ #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() #define configUSE_TRACE_FACILITY 1 -#define configUSE_16_BIT_TICKS 0 #define configUSE_MUTEXES 1 #define configQUEUE_REGISTRY_SIZE 0 #define configCHECK_FOR_STACK_OVERFLOW 0