[FL-2520] FW build with -Wextra (#1185)

* Fixing compiler warnings with -Wextra
* More warnings suppression, WIP
* Even more warning fixes
* Added new lines at end of text files.
* Padding fix
* Additional fixes to warnings on different build configurations; added -Wextra to default build pipeline
* Fixes for Secplus v1
* -additional warnings
* +-Wredundant-decls fixes
* FuriHal: print stack overflow task name in console
* FuriHal: add missing include

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
hedger
2022-05-06 16:37:10 +03:00
committed by GitHub
parent 1ca98170d9
commit 4d6b170769
461 changed files with 940 additions and 519 deletions

View File

@@ -2,6 +2,7 @@
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
#include <stdint.h>
#pragma GCC diagnostic ignored "-Wredundant-decls"
extern uint32_t SystemCoreClock;
#endif

View File

@@ -0,0 +1,52 @@
/**
******************************************************************************
* @file stm32_assert.h
* @author MCD Application Team
* @brief STM32 assert template file.
* This file should be copied to the application folder and renamed
* to stm32_assert.h.
******************************************************************************
* @attention
*
* Copyright (c) 2019 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef STM32_ASSERT_H
#define STM32_ASSERT_H
#include <furi/check.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Includes ------------------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* We're confident in the parameters we pass to LL functions, so we can skip asserts
* since they introduce significant bloat to debug builds */
#ifdef FURI_LL_DEBUG
#define assert_param furi_assert
#else
#define assert_param(__e) \
do { \
((void)(__e)); \
} while(0)
#endif
#ifdef __cplusplus
}
#endif
#endif /* STM32_ASSERT_H */

View File

@@ -68,16 +68,3 @@ void Error_Handler(void) {
void abort() {
furi_crash("AbortHandler");
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line) {
furi_crash("HAL assert failed");
}
#endif /* USE_FULL_ASSERT */

View File

@@ -35,4 +35,4 @@ void APPD_EnableCPU2(void);
#endif /*__APP_DEBUG_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -121,6 +121,7 @@ void ble_app_thread_stop() {
}
static int32_t ble_app_hci_thread(void* arg) {
UNUSED(arg);
uint32_t flags = 0;
while(1) {
@@ -138,6 +139,7 @@ static int32_t ble_app_hci_thread(void* arg) {
// Called by WPAN lib
void hci_notify_asynch_evt(void* pdata) {
UNUSED(pdata);
if(ble_app) {
osThreadId_t thread_id = furi_thread_get_thread_id(ble_app->thread);
furi_assert(thread_id);
@@ -146,12 +148,14 @@ void hci_notify_asynch_evt(void* pdata) {
}
void hci_cmd_resp_release(uint32_t flag) {
UNUSED(flag);
if(ble_app) {
osSemaphoreRelease(ble_app->hci_sem);
}
}
void hci_cmd_resp_wait(uint32_t timeout) {
UNUSED(timeout);
if(ble_app) {
osSemaphoreAcquire(ble_app->hci_sem, osWaitForever);
}

View File

@@ -349,6 +349,7 @@ void ble_glue_thread_stop() {
// Wrap functions
static int32_t ble_glue_shci_thread(void* context) {
UNUSED(context);
uint32_t flags = 0;
while(true) {

View File

@@ -121,4 +121,4 @@ BleGlueCommandResult ble_glue_fus_wait_operation();
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -489,6 +489,7 @@ void gap_stop_advertising() {
}
static void gap_advetise_timer_callback(void* context) {
UNUSED(context);
GapCommand command = GapCommandAdvLowPower;
furi_check(osMessageQueuePut(gap->command_queue, &command, 0, 0) == osOK);
}
@@ -587,6 +588,7 @@ void gap_thread_stop() {
}
static int32_t gap_app(void* context) {
UNUSED(context);
GapCommand command;
while(1) {
osStatus_t status = osMessageQueueGet(gap->command_queue, &command, NULL, osWaitForever);

View File

@@ -419,6 +419,7 @@ uint8_t BSP_SD_GetCardInfo(SD_CardInfo* pCardInfo) {
*/
uint8_t
BSP_SD_ReadBlocks(uint32_t* pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout) {
UNUSED(Timeout); // FIXME!
uint32_t offset = 0;
uint32_t addr;
uint8_t retr = BSP_SD_ERROR;
@@ -500,6 +501,7 @@ uint8_t BSP_SD_WriteBlocks(
uint32_t WriteAddr,
uint32_t NumOfBlocks,
uint32_t Timeout) {
UNUSED(Timeout); // FIXME!
uint32_t offset = 0;
uint32_t addr;
uint8_t retr = BSP_SD_ERROR;

View File

@@ -44,6 +44,7 @@
static volatile DSTATUS Stat = STA_NOINIT;
static DSTATUS User_CheckStatus(BYTE lun) {
UNUSED(lun);
Stat = STA_NOINIT;
if(BSP_SD_GetCardState() == MSD_OK) {
Stat &= ~STA_NOINIT;
@@ -106,6 +107,7 @@ DSTATUS USER_initialize(BYTE pdrv) {
*/
DSTATUS USER_status(BYTE pdrv) {
/* USER CODE BEGIN STATUS */
UNUSED(pdrv);
return Stat;
/* USER CODE END STATUS */
}
@@ -120,6 +122,7 @@ DSTATUS USER_status(BYTE pdrv) {
*/
DRESULT USER_read(BYTE pdrv, BYTE* buff, DWORD sector, UINT count) {
/* USER CODE BEGIN READ */
UNUSED(pdrv);
DRESULT res = RES_ERROR;
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_sd_fast);
@@ -151,6 +154,7 @@ DRESULT USER_read(BYTE pdrv, BYTE* buff, DWORD sector, UINT count) {
DRESULT USER_write(BYTE pdrv, const BYTE* buff, DWORD sector, UINT count) {
/* USER CODE BEGIN WRITE */
/* USER CODE HERE */
UNUSED(pdrv);
DRESULT res = RES_ERROR;
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_sd_fast);
@@ -181,6 +185,7 @@ DRESULT USER_write(BYTE pdrv, const BYTE* buff, DWORD sector, UINT count) {
#if _USE_IOCTL == 1
DRESULT USER_ioctl(BYTE pdrv, BYTE cmd, void* buff) {
/* USER CODE BEGIN IOCTL */
UNUSED(pdrv);
DRESULT res = RES_ERROR;
BSP_SD_CardInfo CardInfo;
@@ -228,4 +233,4 @@ DRESULT USER_ioctl(BYTE pdrv, BYTE cmd, void* buff) {
}
#endif /* _USE_IOCTL == 1 */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -32,4 +32,4 @@ uint32_t furi_hal_crc_feed(void* data, uint16_t length);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -28,4 +28,4 @@ extern FuriHalI2cBusHandle furi_hal_i2c_handle_external;
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -48,4 +48,4 @@ struct FuriHalI2cBusHandle {
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -132,4 +132,4 @@ void furi_hal_info_get(FuriHalInfoValueCallback out, void* context) {
out("protobuf_version_minor", string_get_cstr(value), true, context);
string_clear(value);
}
}

View File

@@ -240,6 +240,7 @@ void rfal_interrupt_callback_handler() {
}
void rfal_state_changed_callback(void* context) {
UNUSED(context);
osEventFlagsSet(event, EVENT_FLAG_STATE_CHANGED);
}
@@ -289,7 +290,7 @@ bool furi_hal_nfc_emulate_nfca(
buff_rx_len = 0;
buff_tx_len = 0;
uint32_t flag = osEventFlagsWait(event, EVENT_FLAG_ALL, osFlagsWaitAny, timeout);
if(flag == osErrorTimeout || flag == EVENT_FLAG_STOP) {
if(flag == osFlagsErrorTimeout || flag == EVENT_FLAG_STOP) {
break;
}
bool data_received = false;

View File

@@ -1,5 +1,6 @@
#include <furi_hal_os.h>
#include <furi_hal_clock.h>
#include <furi_hal_console.h>
#include <furi_hal_power.h>
#include <furi_hal_gpio.h>
#include <furi_hal_resources.h>
@@ -178,5 +179,9 @@ void vPortSuppressTicksAndSleep(TickType_t expected_idle_ticks) {
}
void vApplicationStackOverflowHook(TaskHandle_t xTask, char* pcTaskName) {
UNUSED(xTask);
furi_hal_console_puts("\r\n\r\n stack overflow in ");
furi_hal_console_puts(pcTaskName);
furi_hal_console_puts("\r\n\r\n");
furi_crash("StackOverflow");
}

View File

@@ -51,6 +51,7 @@ void furi_hal_random_fill_buf(uint8_t* buf, uint32_t len) {
}
void srand(unsigned seed) {
UNUSED(seed); // FIXME!
}
int rand() {

View File

@@ -152,6 +152,7 @@ void furi_hal_rfid_tim_read_stop() {
}
void furi_hal_rfid_tim_emulate(float freq) {
UNUSED(freq); // FIXME
// basic PWM setup with needed freq and internal clock
FURI_CRITICAL_ENTER();
LL_TIM_DeInit(FURI_HAL_RFID_EMULATE_TIMER);

View File

@@ -83,6 +83,7 @@ void furi_hal_spi_release(FuriHalSpiBusHandle* handle) {
}
static void furi_hal_spi_bus_end_txrx(FuriHalSpiBusHandle* handle, uint32_t timeout) {
UNUSED(timeout); // FIXME
while(LL_SPI_GetTxFIFOLevel(handle->bus->spi) != LL_SPI_TX_FIFO_EMPTY)
;
while(LL_SPI_IsActiveFlag_BSY(handle->bus->spi))

View File

@@ -58,4 +58,4 @@ extern FuriHalSpiBusHandle furi_hal_spi_bus_handle_sd_slow;
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -61,4 +61,4 @@ struct FuriHalSpiBusHandle {
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -189,6 +189,9 @@ void furi_hal_usb_set_state_callback(FuriHalUsbStateCallback cb, void* ctx) {
}
static void reset_evt(usbd_device* dev, uint8_t event, uint8_t ep) {
UNUSED(dev);
UNUSED(event);
UNUSED(ep);
osThreadFlagsSet(furi_thread_get_thread_id(usb.thread), EventReset);
if(usb.callback != NULL) {
usb.callback(FuriHalUsbStateEventReset, usb.cb_ctx);
@@ -196,6 +199,9 @@ static void reset_evt(usbd_device* dev, uint8_t event, uint8_t ep) {
}
static void susp_evt(usbd_device* dev, uint8_t event, uint8_t ep) {
UNUSED(dev);
UNUSED(event);
UNUSED(ep);
if((usb.if_cur != NULL) && (usb.connected == true)) {
usb.connected = false;
usb.if_cur->suspend(&udev);
@@ -208,6 +214,9 @@ static void susp_evt(usbd_device* dev, uint8_t event, uint8_t ep) {
}
static void wkup_evt(usbd_device* dev, uint8_t event, uint8_t ep) {
UNUSED(dev);
UNUSED(event);
UNUSED(ep);
if((usb.if_cur != NULL) && (usb.connected == false)) {
usb.connected = true;
usb.if_cur->wakeup(&udev);
@@ -220,6 +229,7 @@ static void wkup_evt(usbd_device* dev, uint8_t event, uint8_t ep) {
}
static int32_t furi_hal_usb_thread(void* context) {
UNUSED(context);
bool usb_request_pending = false;
uint8_t usb_wait_time = 0;
FuriHalUsbInterface* if_new = NULL;

View File

@@ -429,6 +429,7 @@ FuriHalUsbInterface usb_cdc_dual = {
};
static void cdc_init(usbd_device* dev, FuriHalUsbInterface* intf, void* ctx) {
UNUSED(ctx);
usb_dev = dev;
cdc_if_cur = intf;
@@ -515,6 +516,7 @@ int32_t furi_hal_cdc_receive(uint8_t if_num, uint8_t* buf, uint16_t max_len) {
}
static void cdc_on_wakeup(usbd_device* dev) {
UNUSED(dev);
connected = true;
for(uint8_t i = 0; i < IF_NUM_MAX; i++) {
if(callbacks[i] != NULL) {
@@ -524,6 +526,7 @@ static void cdc_on_wakeup(usbd_device* dev) {
}
static void cdc_on_suspend(usbd_device* dev) {
UNUSED(dev);
connected = false;
for(uint8_t i = 0; i < IF_NUM_MAX; i++) {
cdc_ctrl_line_state[i] = 0;
@@ -534,6 +537,8 @@ static void cdc_on_suspend(usbd_device* dev) {
}
static void cdc_rx_ep_callback(usbd_device* dev, uint8_t event, uint8_t ep) {
UNUSED(dev);
UNUSED(event);
uint8_t if_num = 0;
if(ep == CDC0_RXD_EP)
if_num = 0;
@@ -547,6 +552,8 @@ static void cdc_rx_ep_callback(usbd_device* dev, uint8_t event, uint8_t ep) {
}
static void cdc_tx_ep_callback(usbd_device* dev, uint8_t event, uint8_t ep) {
UNUSED(dev);
UNUSED(event);
uint8_t if_num = 0;
if(ep == CDC0_TXD_EP)
if_num = 0;
@@ -629,6 +636,7 @@ static usbd_respond cdc_ep_config(usbd_device* dev, uint8_t cfg) {
/* Control requests handler */
static usbd_respond cdc_control(usbd_device* dev, usbd_ctlreq* req, usbd_rqc_callback* callback) {
UNUSED(callback);
/* CDC control requests */
uint8_t if_num = 0;
if(((USB_REQ_RECIPIENT | USB_REQ_TYPE) & req->bmRequestType) ==

View File

@@ -375,6 +375,7 @@ static void* hid_set_string_descr(char* str) {
}
static void hid_init(usbd_device* dev, FuriHalUsbInterface* intf, void* ctx) {
UNUSED(intf);
FuriHalUsbHidConfig* cfg = (FuriHalUsbHidConfig*)ctx;
if(hid_semaphore == NULL) hid_semaphore = osSemaphoreNew(1, 1, NULL);
usb_dev = dev;
@@ -419,17 +420,23 @@ static void hid_deinit(usbd_device* dev) {
}
static void hid_on_wakeup(usbd_device* dev) {
if(hid_connected == false) {
UNUSED(dev);
if(!hid_connected) {
hid_connected = true;
if(callback != NULL) callback(true, cb_ctx);
if(callback != NULL) {
callback(true, cb_ctx);
}
}
}
static void hid_on_suspend(usbd_device* dev) {
if(hid_connected == true) {
UNUSED(dev);
if(hid_connected) {
hid_connected = false;
osSemaphoreRelease(hid_semaphore);
if(callback != NULL) callback(false, cb_ctx);
if(callback != NULL) {
callback(false, cb_ctx);
}
}
}
@@ -450,6 +457,7 @@ static bool hid_send_report(uint8_t report_id) {
}
static void hid_txrx_ep_callback(usbd_device* dev, uint8_t event, uint8_t ep) {
UNUSED(dev);
if(event == usbd_evt_eptx) {
osSemaphoreRelease(hid_semaphore);
} else {
@@ -484,6 +492,7 @@ static usbd_respond hid_ep_config(usbd_device* dev, uint8_t cfg) {
/* Control requests handler */
static usbd_respond hid_control(usbd_device* dev, usbd_ctlreq* req, usbd_rqc_callback* callback) {
UNUSED(callback);
/* HID control requests */
if(((USB_REQ_RECIPIENT | USB_REQ_TYPE) & req->bmRequestType) ==
(USB_REQ_INTERFACE | USB_REQ_CLASS) &&

View File

@@ -159,14 +159,18 @@ bool furi_hal_hid_u2f_is_connected() {
void furi_hal_hid_u2f_set_callback(HidU2fCallback cb, void* ctx) {
if(callback != NULL) {
if(hid_u2f_connected == true) callback(HidU2fDisconnected, cb_ctx);
if(hid_u2f_connected == true) {
callback(HidU2fDisconnected, cb_ctx);
}
}
callback = cb;
cb_ctx = ctx;
if(callback != NULL) {
if(hid_u2f_connected == true) callback(HidU2fConnected, cb_ctx);
if(hid_u2f_connected == true) {
callback(HidU2fConnected, cb_ctx);
}
}
}
@@ -186,7 +190,11 @@ FuriHalUsbInterface usb_hid_u2f = {
};
static void hid_u2f_init(usbd_device* dev, FuriHalUsbInterface* intf, void* ctx) {
if(hid_u2f_semaphore == NULL) hid_u2f_semaphore = osSemaphoreNew(1, 1, NULL);
UNUSED(intf);
UNUSED(ctx);
if(hid_u2f_semaphore == NULL) {
hid_u2f_semaphore = osSemaphoreNew(1, 1, NULL);
}
usb_dev = dev;
usbd_reg_config(dev, hid_u2f_ep_config);
@@ -201,15 +209,21 @@ static void hid_u2f_deinit(usbd_device* dev) {
}
static void hid_u2f_on_wakeup(usbd_device* dev) {
UNUSED(dev);
hid_u2f_connected = true;
if(callback != NULL) callback(HidU2fConnected, cb_ctx);
if(callback != NULL) {
callback(HidU2fConnected, cb_ctx);
}
}
static void hid_u2f_on_suspend(usbd_device* dev) {
if(hid_u2f_connected == true) {
UNUSED(dev);
if(hid_u2f_connected) {
hid_u2f_connected = false;
osSemaphoreRelease(hid_u2f_semaphore);
if(callback != NULL) callback(HidU2fDisconnected, cb_ctx);
if(callback != NULL) {
callback(HidU2fDisconnected, cb_ctx);
}
}
}
@@ -227,10 +241,18 @@ uint32_t furi_hal_hid_u2f_get_request(uint8_t* data) {
}
static void hid_u2f_rx_ep_callback(usbd_device* dev, uint8_t event, uint8_t ep) {
if(callback != NULL) callback(HidU2fRequest, cb_ctx);
UNUSED(dev);
UNUSED(event);
UNUSED(ep);
if(callback != NULL) {
callback(HidU2fRequest, cb_ctx);
}
}
static void hid_u2f_tx_ep_callback(usbd_device* dev, uint8_t event, uint8_t ep) {
UNUSED(dev);
UNUSED(event);
UNUSED(ep);
osSemaphoreRelease(hid_u2f_semaphore);
}
@@ -268,6 +290,7 @@ static usbd_respond hid_u2f_ep_config(usbd_device* dev, uint8_t cfg) {
/* Control requests handler */
static usbd_respond
hid_u2f_control(usbd_device* dev, usbd_ctlreq* req, usbd_rqc_callback* callback) {
UNUSED(callback);
/* HID control requests */
if(((USB_REQ_RECIPIENT | USB_REQ_TYPE) & req->bmRequestType) ==
(USB_REQ_INTERFACE | USB_REQ_CLASS) &&

View File

@@ -205,7 +205,7 @@ const char* furi_hal_version_get_model_name() {
return "Flipper Zero";
}
const FuriHalVersionOtpVersion furi_hal_version_get_otp_version() {
FuriHalVersionOtpVersion furi_hal_version_get_otp_version() {
if(*(uint64_t*)FURI_HAL_VERSION_OTP_ADDRESS == 0xFFFFFFFF) {
return FuriHalVersionOtpVersionEmpty;
} else {
@@ -228,27 +228,27 @@ const FuriHalVersionOtpVersion furi_hal_version_get_otp_version() {
}
}
const uint8_t furi_hal_version_get_hw_version() {
uint8_t furi_hal_version_get_hw_version() {
return furi_hal_version.board_version;
}
const uint8_t furi_hal_version_get_hw_target() {
uint8_t furi_hal_version_get_hw_target() {
return furi_hal_version.board_target;
}
const uint8_t furi_hal_version_get_hw_body() {
uint8_t furi_hal_version_get_hw_body() {
return furi_hal_version.board_body;
}
const FuriHalVersionColor furi_hal_version_get_hw_color() {
FuriHalVersionColor furi_hal_version_get_hw_color() {
return furi_hal_version.board_color;
}
const uint8_t furi_hal_version_get_hw_connect() {
uint8_t furi_hal_version_get_hw_connect() {
return furi_hal_version.board_connect;
}
const FuriHalVersionRegion furi_hal_version_get_hw_region() {
FuriHalVersionRegion furi_hal_version_get_hw_region() {
return furi_hal_version.board_region;
}
@@ -266,11 +266,11 @@ const char* furi_hal_version_get_hw_region_name() {
return "R??";
}
const FuriHalVersionDisplay furi_hal_version_get_hw_display() {
FuriHalVersionDisplay furi_hal_version_get_hw_display() {
return furi_hal_version.board_display;
}
const uint32_t furi_hal_version_get_hw_timestamp() {
uint32_t furi_hal_version_get_hw_timestamp() {
return furi_hal_version.timestamp;
}

View File

@@ -18,7 +18,10 @@ endif
MCU_FLAGS = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard
CFLAGS += $(MCU_FLAGS) -DSTM32WB55xx -Wall -fdata-sections -ffunction-sections
# Warnings configuration
CFLAGS += -Wall -Wextra -Wredundant-decls
CFLAGS += $(MCU_FLAGS) -DSTM32WB55xx -fdata-sections -ffunction-sections
LDFLAGS += $(MCU_FLAGS) -specs=nosys.specs -specs=nano.specs
CPPFLAGS += -fno-rtti -fno-use-cxa-atexit -fno-exceptions
@@ -35,6 +38,7 @@ ASM_SOURCES += $(MXPROJECT_DIR)/startup_stm32wb55xx_cm4.s
CUBE_DIR = ../lib/STM32CubeWB
CFLAGS += \
-DUSE_FULL_LL_DRIVER \
-DUSE_FULL_ASSERT \
-DHAVE_FREERTOS
CFLAGS += \
-I$(CUBE_DIR)/Drivers/STM32WBxx_HAL_Driver/Inc \

View File

@@ -21,4 +21,4 @@ void furi_hal_random_fill_buf(uint8_t* buf, uint32_t len);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,3 +1,4 @@
#pragma once
/**
* @file furi_hal_sd.h
* SD Card HAL API

View File

@@ -347,4 +347,4 @@ bool furi_hal_hid_consumer_key_press(uint16_t button);
*
* @param button key code
*/
bool furi_hal_hid_consumer_key_release(uint16_t button);
bool furi_hal_hid_consumer_key_release(uint16_t button);