From 5c8092bfd0513fe177f0599f5185697094956d5c Mon Sep 17 00:00:00 2001 From: alagoutte Date: Thu, 22 Jan 2015 09:08:51 +0000 Subject: [PATCH 01/12] Created new branch clang From df9db3f1308717e27c1a8d1ca0da4491f85e7f70 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Thu, 22 Jan 2015 10:19:38 +0100 Subject: [PATCH 02/12] Remove -Werror to automake (fix build for Ubuntu) --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 9948317..fe9b12a 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ AC_PREREQ(2.63) AC_INIT([SmartCAPWAP], [1.0.0], [https://bitbucket.org/vemax78/smartcapwap], [smartcapwap]) AC_CONFIG_AUX_DIR([build]) AC_CONFIG_MACRO_DIR([m4]) -AM_INIT_AUTOMAKE([1.11 -Wall -Werror]) +AM_INIT_AUTOMAKE([1.11 -Wall]) AC_USE_SYSTEM_EXTENSIONS # cross-compile macros From addf009baec7af3abc6e5e85587fe14ba82cbf27 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Thu, 22 Jan 2015 10:19:38 +0100 Subject: [PATCH 03/12] Fix equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality] when build with Clang --- src/wtp/wtp_dfa_discovery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- src/wtp/wtp_dfa_discovery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wtp/wtp_dfa_discovery.c b/src/wtp/wtp_dfa_discovery.c index f4cf98a..e51c339 100644 --- a/src/wtp/wtp_dfa_discovery.c +++ b/src/wtp/wtp_dfa_discovery.c @@ -68,7 +68,7 @@ void wtp_dfa_state_discovery_timeout(struct capwap_timeout* timeout, unsigned lo } /* AC with IPv6 */ - if ((g_wtp.net.localaddr.ss.ss_family == AF_INET6)) { + if (g_wtp.net.localaddr.ss.ss_family == AF_INET6) { for (w = 0; w < response->controlipv6->count; w++) { struct capwap_controlipv6_element* controlipv6 = (struct capwap_controlipv6_element*)capwap_array_get_item_pointer(response->controlipv6, w); From 0cfead4e0961fad0c483f09f6a49cba2c81b1434 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Thu, 22 Jan 2015 10:19:38 +0100 Subject: [PATCH 04/12] Add .gitignore (based on .hgignore) --- .gitignore | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .gitignore --- .gitignore | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4bab6fd --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +# use glob syntax +syntax: glob + +Makefile +Makefile.in +aclocal.m4 +autom4te.cache/ +config.guess +config.log +config.status +config.sub +configure +depcomp +install-sh +missing +Module.symvers +modules.order + +build/ + +src/ac/kmod/.tmp_versions + +*~ +*.o +*.lo +*.la +m4 +.deps +.libs +*.mod.c +*.ko +*.cmd From 1ba7fc23556771ef75985d75b32fa413ede68d86 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Thu, 22 Jan 2015 10:19:38 +0100 Subject: [PATCH 05/12] Add exit(1) when ASSERT() Move to 520 issues found by Clang Analyzer to only 18 ! --- src/common/capwap_debug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- src/common/capwap_debug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/capwap_debug.h b/src/common/capwap_debug.h index 91ef44e..e0ec7b8 100644 --- a/src/common/capwap_debug.h +++ b/src/common/capwap_debug.h @@ -3,7 +3,7 @@ #ifdef DEBUG -#define ASSERT(expr) if (!(expr)) { capwap_logging_fatal("Assertion failed \'%s\': %s(%d)", #expr, __FILE__, __LINE__); } +#define ASSERT(expr) if (!(expr)) { capwap_logging_fatal("Assertion failed \'%s\': %s(%d)", #expr, __FILE__, __LINE__); exit(1); } /* Custom memory management */ #define capwap_alloc(x) capwap_alloc_debug(x, __FILE__, __LINE__) From 3a51803eba38345a230a4b9fb8bed0e2aaf598a5 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Thu, 22 Jan 2015 10:19:38 +0100 Subject: [PATCH 06/12] Fix Dead Store (Dead Assignment) found by Clang Analyzer --- src/common/capwap_protocol.c | 2 -- 1 file changed, 2 deletions(-) --- src/common/capwap_protocol.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/common/capwap_protocol.c b/src/common/capwap_protocol.c index 2fa8c56..2e03b94 100644 --- a/src/common/capwap_protocol.c +++ b/src/common/capwap_protocol.c @@ -800,8 +800,6 @@ int capwap_packet_rxmng_add_recv_packet(struct capwap_packet_rxmng* rxmngpacket, /* Check complete only if receive last packet */ ASSERT(rxmngpacket->fragmentlist->last != NULL); - packetsearch = (struct capwap_fragment_packet_item*)rxmngpacket->fragmentlist->last->item; - headersearch = (struct capwap_header*)packetsearch->buffer; if (IS_FLAG_L_HEADER(header)) { unsigned short sanityfragoffset = 0; From e5f1fbd992636c502395dcc6909cb8656cd49e8a Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Thu, 22 Jan 2015 10:19:38 +0100 Subject: [PATCH 07/12] Fix Dead Store (Dead Assignment) found by Clang Analyzer --- src/wtp/binding/ieee80211/wifi_nl80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- src/wtp/binding/ieee80211/wifi_nl80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wtp/binding/ieee80211/wifi_nl80211.c b/src/wtp/binding/ieee80211/wifi_nl80211.c index 9185a06..062fd14 100644 --- a/src/wtp/binding/ieee80211/wifi_nl80211.c +++ b/src/wtp/binding/ieee80211/wifi_nl80211.c @@ -1663,7 +1663,7 @@ static wifi_global_handle nl80211_global_init(void) { /* Add membership regulatory events */ result = nl80211_get_multicast_id(globalhandle, "nl80211", "regulatory"); if (result >= 0) { - result = nl_socket_add_membership(globalhandle->nl_event, result); + nl_socket_add_membership(globalhandle->nl_event, result); } /* Get nl80211 netlink family */ From d12d15d67dbabc23a9cd5b3f457e73f677646427 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Thu, 22 Jan 2015 10:19:38 +0100 Subject: [PATCH 08/12] Fix Dead Store (Dead Assignment) found by Clang Analyzer --- src/wtp/wtp_dfa.c | 2 -- 1 file changed, 2 deletions(-) --- src/wtp/wtp_dfa.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/wtp/wtp_dfa.c b/src/wtp/wtp_dfa.c index 27dbc25..7554f6b 100644 --- a/src/wtp/wtp_dfa.c +++ b/src/wtp/wtp_dfa.c @@ -379,10 +379,8 @@ int wtp_dfa_running(void) { /* Check is handshake complete */ if ((oldaction == CAPWAP_DTLS_ACTION_HANDSHAKE) && (g_wtp.dtls.action == CAPWAP_DTLS_ACTION_DATA)) { if (g_wtp.state == CAPWAP_DTLS_CONNECT_STATE) { - check = CAPWAP_NONE_PACKET; wtp_send_join(); } else { - check = CAPWAP_WRONG_PACKET; wtp_teardown_connection(); } } From 49f7ba41df994b2245bb341d264b1ec278569ad8 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Thu, 22 Jan 2015 10:19:38 +0100 Subject: [PATCH 09/12] Fix Dead Store (Dead increment) found by Clang Analyzer --- src/wtp/binding/ieee80211/wifi_drivers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- src/wtp/binding/ieee80211/wifi_drivers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wtp/binding/ieee80211/wifi_drivers.c b/src/wtp/binding/ieee80211/wifi_drivers.c index 397eaf4..be175aa 100644 --- a/src/wtp/binding/ieee80211/wifi_drivers.c +++ b/src/wtp/binding/ieee80211/wifi_drivers.c @@ -1559,7 +1559,7 @@ uint16_t wifi_wlan_check_capability(struct wifi_wlan* wlan, uint16_t capability) result &= ~IEEE80211_CAPABILITY_SHORTSLOTTIME; } - return capability; + return result; } /* */ From 4d1b60a6c178064d79630a7cce39905864ce6209 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Thu, 22 Jan 2015 10:19:38 +0100 Subject: [PATCH 10/12] Fix Dead Store (Dead increment) found by Clang Analyzer --- src/common/binding/ieee80211/ieee80211.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- src/common/binding/ieee80211/ieee80211.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/binding/ieee80211/ieee80211.c b/src/common/binding/ieee80211/ieee80211.c index b26b62d..033d465 100644 --- a/src/common/binding/ieee80211/ieee80211.c +++ b/src/common/binding/ieee80211/ieee80211.c @@ -624,7 +624,7 @@ int ieee80211_create_probe_response(uint8_t* buffer, int length, struct ieee8021 return -1; } - pos += result; + /*pos += result;*/ /* Comment for disable Dead inscrement Clang Analyzer warning */ responselength += result; return responselength; @@ -701,7 +701,7 @@ int ieee80211_create_associationresponse_response(uint8_t* buffer, int length, s return -1; } - pos += result; + /*pos += result;*/ /* Comment for disable Dead inscrement Clang Analyzer warning */ responselength += result; return responselength; From 63189997dfdc4d7f7b48ec0a9d76f463e4bcb567 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Thu, 22 Jan 2015 10:19:38 +0100 Subject: [PATCH 11/12] Fix Uninitialized argument value found by Clang Analyzer (Need to be confirmed) --- src/ac/ac_dfa_join.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- src/ac/ac_dfa_join.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ac/ac_dfa_join.c b/src/ac/ac_dfa_join.c index 033b967..f4a1c4c 100644 --- a/src/ac/ac_dfa_join.c +++ b/src/ac/ac_dfa_join.c @@ -456,7 +456,7 @@ static uint32_t ac_dfa_state_join_create_response(struct ac_session_t* session, responseacipv4list->addresses = capwap_array_create(sizeof(struct in_addr), 0, 0); for (j = 0; j < length; j++) { - struct json_object* jsonvalue = json_object_array_get_idx(jsonelement, i); + struct json_object* jsonvalue = json_object_array_get_idx(jsonelement, j); if (jsonvalue && (json_object_get_type(jsonvalue) == json_type_object)) { struct json_object* jsonitem; @@ -507,7 +507,7 @@ static uint32_t ac_dfa_state_join_create_response(struct ac_session_t* session, responseacipv6list->addresses = capwap_array_create(sizeof(struct in6_addr), 0, 0); for (j = 0; j < length; j++) { - struct json_object* jsonvalue = json_object_array_get_idx(jsonelement, i); + struct json_object* jsonvalue = json_object_array_get_idx(jsonelement, j); if (jsonvalue && (json_object_get_type(jsonvalue) == json_type_object)) { struct json_object* jsonitem; From 28112ee228146bd25ae2147564b4a81dd2befbed Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Thu, 22 Jan 2015 10:19:38 +0100 Subject: [PATCH 12/12] Fix Branch condition evaluates to a garbage value found by Clang Analyzer --- src/ac/ac_backend.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- src/ac/ac_backend.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ac/ac_backend.c b/src/ac/ac_backend.c index d30c99d..bdc257f 100644 --- a/src/ac/ac_backend.c +++ b/src/ac/ac_backend.c @@ -319,7 +319,7 @@ static int ac_backend_parsing_deletewlan_event(const char* idevent, struct json_ static int ac_backend_soap_update_event(const char* idevent, int status) { int result = 0; char buffer[256]; - struct ac_soap_request* request; + struct ac_soap_request* request = NULL; struct ac_http_soap_server* server; ASSERT(g_ac_backend.soaprequest == NULL); @@ -376,7 +376,7 @@ static int ac_backend_soap_update_event(const char* idevent, int status) { /* */ static int ac_backend_soap_getconfiguration(void) { int result = -1; - struct ac_soap_request* request; + struct ac_soap_request* request = NULL; struct ac_http_soap_server* server; struct json_object* jsonroot = NULL; @@ -441,7 +441,7 @@ static int ac_backend_soap_getconfiguration(void) { /* */ static int ac_backend_soap_join(int forcereset) { - struct ac_soap_request* request; + struct ac_soap_request* request = NULL; struct ac_http_soap_server* server; ASSERT(g_ac_backend.soaprequest == NULL); @@ -570,7 +570,7 @@ static int ac_backend_parsing_event(struct json_object* jsonitem) { /* */ static int ac_backend_soap_waitevent(void) { int result = -1; - struct ac_soap_request* request; + struct ac_soap_request* request = NULL; struct ac_http_soap_server* server; struct json_object* jsonroot = NULL;