[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

@@ -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;
}