cmake: added more warnings and propagated them to all core components

This commit is contained in:
Dirk Helbig 2023-11-28 15:13:41 +01:00
parent 6269f47e07
commit dac1064e3d
16 changed files with 119 additions and 103 deletions

View File

@ -9,14 +9,33 @@ file(GLOB SOURCE_LIST
# Make an automatic library - will be static or dynamic based on user setting
add_library(btstack_core ${SOURCE_LIST} ${HEADER_LIST})
target_compile_options(btstack_core PRIVATE
set(WARNING_FLAGS
$<$<OR:$<C_COMPILER_ID:Clang>,$<C_COMPILER_ID:AppleClang>>:
-Wunused-variable -Wswitch-default -Werror>
-Wall -Wextra -fno-common -Wshadow -Wformat=2 -Wdouble-promotion -Wunused-variable -Wswitch-default -Werror
-Wunused-parameter -Wnull-dereference -Wsign-compare -Wsign-compare -Wunused -Wmissing-format-attribute>
$<$<C_COMPILER_ID:GNU>:
-Wall -Wextra -Wunused-but-set-variable -Wunused-variable -Wswitch-default -Werror>
-Wall -Wextra -fno-common -Wshadow -Wformat=2 -Wformat-truncation -Wdouble-promotion -Wunused-but-set-variable
-Wunused-variable -Wswitch-default -Werror
-Wunused-parameter -Wnull-dereference -Wsign-compare -Wsign-compare -Wunused -Wmissing-format-attribute>
$<$<C_COMPILER_ID:MSVC>:
/WX /W4>)
set( DEFAULT_C_LEVEL c_std_99 )
add_subdirectory( ble )
add_subdirectory( classic )
add_subdirectory( mesh )
target_compile_options( btstack_core PRIVATE ${WARNING_FLAGS} )
target_compile_options( ble PRIVATE ${WARNING_FLAGS} )
target_compile_options( classic PRIVATE ${WARNING_FLAGS} )
target_compile_options( mesh PRIVATE ${WARNING_FLAGS} )
target_compile_features( btstack_core PRIVATE ${DEFAULT_C_LEVEL} )
target_compile_features( ble PRIVATE ${DEFAULT_C_LEVEL} )
target_compile_features( classic PRIVATE ${DEFAULT_C_LEVEL} )
target_compile_features( mesh PRIVATE ${DEFAULT_C_LEVEL} )
target_link_libraries( btstack_core PRIVATE btstack_config )
target_link_libraries( btstack_core PRIVATE rijndael )
target_link_libraries( btstack_core PRIVATE uecc )
@ -27,11 +46,6 @@ target_link_libraries( btstack_core PUBLIC classic )
# We need this directory, and users of our library will need it too
target_include_directories( btstack_core PUBLIC . )
target_compile_features( btstack_core PRIVATE c_std_99 )
add_subdirectory( ble )
add_subdirectory( classic )
add_subdirectory( mesh )
# IDEs should put the headers in a nice place
source_group(

View File

@ -486,6 +486,7 @@ static void att_server_event_packet_handler (uint8_t packet_type, uint16_t chann
static uint8_t
att_server_send_prepared(const att_server_t *att_server, const att_connection_t *att_connection, uint8_t *buffer,
uint16_t size) {
UNUSED(buffer);
uint8_t status = ERROR_CODE_SUCCESS;
switch (att_server->bearer_type) {
case ATT_BEARER_UNENHANCED_LE:

View File

@ -1554,7 +1554,7 @@ static int sm_le_device_db_index_lookup(bd_addr_type_t address_type, bd_addr_t a
le_device_db_info(i, &db_address_type, db_address, NULL);
// skip unused entries
if (address_type == BD_ADDR_TYPE_UNKNOWN) continue;
if ((address_type == db_address_type) && (memcmp(address, db_address, 6) == 0)){
if ((address_type == (unsigned int)db_address_type) && (memcmp(address, db_address, 6) == 0)){
return i;
}
}

View File

@ -110,7 +110,7 @@ static float btstack_cvsd_plc_cross_correlation(BTSTACK_CVSD_PLC_SAMPLE_FORMAT *
}
int btstack_cvsd_plc_pattern_match(BTSTACK_CVSD_PLC_SAMPLE_FORMAT *y){
float maxCn = -999999.0; // large negative number
float maxCn = -999999.f; // large negative number
int bestmatch = 0;
float Cn;
int n;
@ -127,7 +127,7 @@ int btstack_cvsd_plc_pattern_match(BTSTACK_CVSD_PLC_SAMPLE_FORMAT *y){
float btstack_cvsd_plc_amplitude_match(btstack_cvsd_plc_state_t *plc_state, uint16_t num_samples, BTSTACK_CVSD_PLC_SAMPLE_FORMAT *y, BTSTACK_CVSD_PLC_SAMPLE_FORMAT bestmatch){
UNUSED(plc_state);
int i;
float sumx = 0;
float sumx = 0.f;
float sumy = 0.000001f;
float sf;
@ -138,14 +138,14 @@ float btstack_cvsd_plc_amplitude_match(btstack_cvsd_plc_state_t *plc_state, uint
sf = sumx/sumy;
// This is not in the paper, but limit the scaling factor to something reasonable to avoid creating artifacts
if (sf<0.75f) sf=0.75f;
if (sf>1.0) sf=1.0f;
if (sf>1.f) sf=1.f;
return sf;
}
BTSTACK_CVSD_PLC_SAMPLE_FORMAT btstack_cvsd_plc_crop_sample(float val){
float croped_val = val;
if (croped_val > 32767.0) croped_val= 32767.0;
if (croped_val < -32768.0) croped_val=-32768.0;
if (croped_val > 32767.f) croped_val= 32767.f;
if (croped_val < -32768.f) croped_val=-32768.f;
return (BTSTACK_CVSD_PLC_SAMPLE_FORMAT) croped_val;
}

View File

@ -147,8 +147,8 @@ static float AmplitudeMatch(SAMPLE_FORMAT *y, SAMPLE_FORMAT bestmatch) {
static SAMPLE_FORMAT crop_sample(float val){
float croped_val = val;
if (croped_val > 32767.0) croped_val= 32767.0;
if (croped_val < -32768.0) croped_val=-32768.0;
if (croped_val > 32767.f) croped_val= 32767.f;
if (croped_val < -32768.f) croped_val=-32768.f;
return (SAMPLE_FORMAT) croped_val;
}

View File

@ -2216,6 +2216,7 @@ void hfp_bcm_write_i2spcm_interface_param(hfp_connection_t * hfp_connection){
#endif
void hfp_prepare_for_sco(hfp_connection_t * hfp_connection){
UNUSED(hfp_connection);
#ifdef ENABLE_CC256X_ASSISTED_HFP
hfp_connection->cc256x_send_write_codec_config = true;
if (hfp_connection->negotiated_codec == HFP_CODEC_MSBC){

View File

@ -672,8 +672,8 @@ bool sdp_record_matches_service_search_pattern(uint8_t *record, uint8_t *service
// context { indent }
#ifdef ENABLE_SDP_DES_DUMP
static int de_traversal_dump_data(uint8_t * element, de_type_t de_type, de_size_t de_size, void *my_context){
int indent = *(int*) my_context;
int i;
unsigned int indent = *(unsigned int*) my_context;
unsigned int i;
for (i=0; i<indent;i++) printf(" ");
unsigned int pos = de_get_header_size(element);
unsigned int end_pos = de_get_len(element);
@ -698,7 +698,7 @@ static int de_traversal_dump_data(uint8_t * element, de_type_t de_type, de_size_
}
printf(", len %2u, value: '", len);
for (i=0;i<len;i++){
char c = element[pos + i];
uint8_t c = element[pos + i];
printf("%c", (c >= 0x20 && c <= 0x7f) ? c : '.');
}
printf("'\n");
@ -727,7 +727,7 @@ static int de_traversal_dump_data(uint8_t * element, de_type_t de_type, de_size_
void de_dump_data_element(const uint8_t * record){
#ifdef ENABLE_SDP_DES_DUMP
int indent = 0;
unsigned int indent = 0;
// hack to get root DES, too.
de_type_t type = de_get_element_type(record);
de_size_t size = de_get_size_type(record);

View File

@ -1528,7 +1528,7 @@ static void mesh_configuration_client_network_transmit_handler(mesh_model_t *mes
mesh_access_message_processed(pdu);
}
const static mesh_operation_t mesh_configuration_client_model_operations[] = {
static const mesh_operation_t mesh_configuration_client_model_operations[] = {
{ MESH_FOUNDATION_OPERATION_BEACON_STATUS, 1, mesh_configuration_client_beacon_status_handler },
{ MESH_FOUNDATION_OPERATION_COMPOSITION_DATA_STATUS, 10, mesh_configuration_client_composition_data_status_handler },
{ MESH_FOUNDATION_OPERATION_DEFAULT_TTL_STATUS, 1, mesh_configuration_client_default_ttl_handler },

View File

@ -2219,7 +2219,7 @@ static void config_node_identity_set_handler(mesh_model_t *mesh_model, mesh_pdu_
//
const static mesh_operation_t mesh_configuration_server_model_operations[] = {
static const mesh_operation_t mesh_configuration_server_model_operations[] = {
{ MESH_FOUNDATION_OPERATION_APPKEY_ADD, 19, config_appkey_add_handler },
{ MESH_FOUNDATION_OPERATION_APPKEY_DELETE, 3, config_appkey_delete_handler },
{ MESH_FOUNDATION_OPERATION_APPKEY_GET, 2, config_appkey_get_handler },

View File

@ -139,7 +139,7 @@ static void generic_default_transition_time_status_handler(mesh_model_t *mesh_mo
mesh_access_message_processed(pdu);
}
const static mesh_operation_t mesh_generic_default_transition_time_model_operations[] = {
static const mesh_operation_t mesh_generic_default_transition_time_model_operations[] = {
{ MESH_GENERIC_DEFAULT_TRANSITION_TIME_STATUS, 0, generic_default_transition_time_status_handler },
{ 0, 0, NULL }
};

View File

@ -121,7 +121,7 @@ static void generic_default_transition_time_set_unacknowledged_handler(mesh_mode
}
// Generic On Off Message
const static mesh_operation_t mesh_generic_default_transition_time_model_operations[] = {
static const mesh_operation_t mesh_generic_default_transition_time_model_operations[] = {
{ MESH_GENERIC_DEFAULT_TRANSITION_TIME_GET, 0, generic_default_transition_time_get_handler },
{ MESH_GENERIC_DEFAULT_TRANSITION_TIME_SET, 1, generic_default_transition_time_set_handler },
{ MESH_GENERIC_DEFAULT_TRANSITION_TIME_SET_UNACKNOWLEDGED, 1, generic_default_transition_time_set_unacknowledged_handler },

View File

@ -250,7 +250,7 @@ static void generic_level_status_handler(mesh_model_t *mesh_model, mesh_pdu_t *
mesh_access_message_processed(pdu);
}
const static mesh_operation_t mesh_generic_level_model_operations[] = {
static const mesh_operation_t mesh_generic_level_model_operations[] = {
{ MESH_GENERIC_LEVEL_STATUS, 0, generic_level_status_handler },
{ 0, 0, NULL }
};

View File

@ -344,7 +344,7 @@ static void generic_move_set_unacknowledged_handler(mesh_model_t *generic_level_
}
// Generic On Off Message
const static mesh_operation_t mesh_generic_level_model_operations[] = {
static const mesh_operation_t mesh_generic_level_model_operations[] = {
{ MESH_GENERIC_LEVEL_GET, 0, generic_level_get_handler },
{ MESH_GENERIC_LEVEL_SET, 3, generic_level_set_handler },
{ MESH_GENERIC_LEVEL_SET_UNACKNOWLEDGED, 3, generic_level_set_unacknowledged_handler },

View File

@ -171,7 +171,7 @@ static void generic_on_off_status_handler(mesh_model_t *mesh_model, mesh_pdu_t *
mesh_access_message_processed(pdu);
}
const static mesh_operation_t mesh_generic_on_off_model_operations[] = {
static const mesh_operation_t mesh_generic_on_off_model_operations[] = {
{ MESH_GENERIC_ON_OFF_STATUS, 0, generic_on_off_status_handler },
{ 0, 0, NULL }
};

View File

@ -198,7 +198,7 @@ static void generic_on_off_set_unacknowledged_handler(mesh_model_t *generic_on_o
}
// Generic On Off Message
const static mesh_operation_t mesh_generic_on_off_model_operations[] = {
static const mesh_operation_t mesh_generic_on_off_model_operations[] = {
{ MESH_GENERIC_ON_OFF_GET, 0, generic_on_off_get_handler },
{ MESH_GENERIC_ON_OFF_SET, 2, generic_on_off_set_handler },
{ MESH_GENERIC_ON_OFF_SET_UNACKNOWLEDGED, 2, generic_on_off_set_unacknowledged_handler },

View File

@ -327,7 +327,7 @@ static mesh_pdu_t * mesh_health_server_publish_state_fn(struct mesh_model * mesh
}
// Health Message
const static mesh_operation_t mesh_health_model_operations[] = {
static const mesh_operation_t mesh_health_model_operations[] = {
{ MESH_FOUNDATION_OPERATION_HEALTH_FAULT_GET, 2, health_fault_get_handler },
{ MESH_FOUNDATION_OPERATION_HEALTH_FAULT_CLEAR, 2, health_fault_clear_handler },
{ MESH_FOUNDATION_OPERATION_HEALTH_FAULT_CLEAR_UNACKNOWLEDGED, 2, health_fault_clear_unacknowledged_handler },