From dd08e11ee18a3f71970708318d5d4e74c09443a9 Mon Sep 17 00:00:00 2001 From: Amin Ben Ramdhane Date: Mon, 25 Jan 2021 18:56:05 +0100 Subject: [PATCH] fix compiler warnings on x86 and staic code analysis --- dmtree/tr181/bridging.c | 8 +++----- dmtree/tr181/ip.c | 10 +++++----- dmtree/tr181/wifi.c | 9 --------- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/dmtree/tr181/bridging.c b/dmtree/tr181/bridging.c index fd3c4953..1c2472f1 100644 --- a/dmtree/tr181/bridging.c +++ b/dmtree/tr181/bridging.c @@ -2405,7 +2405,7 @@ static int get_BridgingBridgePort_PVID(char *refparam, struct dmctx *ctx, void * static int fetch_and_configure_inner_vid(char *br_inst, char *type_val, char **vid) { struct uci_section *dev_s = NULL, *sec = NULL; - char *name, *instance; + char *name, *instance = NULL; // Get the vid under device section with type 8021q of port under same br_inst. uci_foreach_option_eq("network", "device", "type", type_val, dev_s) { @@ -2417,10 +2417,8 @@ static int fetch_and_configure_inner_vid(char *br_inst, char *type_val, char **v } //Check if the bridge instances are same or not, if yes, then get the vid. - char bridge_inst[20] = {0}; - strncpy(bridge_inst, br_inst, sizeof(bridge_inst)); - if (strncmp(bridge_inst, instance, sizeof(bridge_inst)) == 0) { - if (strcmp(type_val, "8021ad") == 0) { + if (instance && br_inst && strcmp(br_inst, instance) == 0) { + if (type_val && strcmp(type_val, "8021ad") == 0) { dmuci_set_value_by_section(dev_s, "inner_vid", *vid); } else { dmuci_get_value_by_section_string(dev_s, "vid", vid); diff --git a/dmtree/tr181/ip.c b/dmtree/tr181/ip.c index fc77b801..916c4b75 100644 --- a/dmtree/tr181/ip.c +++ b/dmtree/tr181/ip.c @@ -81,7 +81,7 @@ static void create_firewall_zone_config(char *iface) dmuci_set_value_by_section(s, "network", iface); } -static int parse_proc_intf6_line(const char *line, const char *device, char *ipstr) +static int parse_proc_intf6_line(const char *line, const char *device, char *ipstr, size_t str_len) { char ip6buf[INET6_ADDRSTRLEN] = {0}, dev[32] = {0}; unsigned int ip[4], prefix; @@ -99,7 +99,7 @@ static int parse_proc_intf6_line(const char *line, const char *device, char *ips ip[3] = htonl(ip[3]); inet_ntop(AF_INET6, ip, ip6buf, INET6_ADDRSTRLEN); - snprintf(ipstr, INET6_ADDRSTRLEN, "%s/%u", ip6buf, prefix); + snprintf(ipstr, str_len, "%s/%u", ip6buf, prefix); if (strncmp(ipstr, "fe80:", 5) != 0) return -1; @@ -127,7 +127,7 @@ static bool proc_intf6_line_exists(char *parent_section, char *address) static void dmmap_synchronize_ipv6_address_link_local(char *parent_section) { struct uci_section *s = NULL, *stmp = NULL; - char buf[512] = {0}, ipstr[INET6_ADDRSTRLEN] = {0}; + char buf[512] = {0}, ipstr[64] = {0}; FILE *fp = NULL; char *device = get_device(parent_section); @@ -151,7 +151,7 @@ static void dmmap_synchronize_ipv6_address_link_local(char *parent_section) bool found = false; while (fgets(buf, 512, fp) != NULL) { - if (parse_proc_intf6_line(buf, device, ipstr)) + if (parse_proc_intf6_line(buf, device, ipstr, sizeof(ipstr))) continue; if (address && strcmp(address, ipstr) == 0) { @@ -171,7 +171,7 @@ static void dmmap_synchronize_ipv6_address_link_local(char *parent_section) while (fgets(buf , 512 , fp) != NULL) { - if (parse_proc_intf6_line(buf, device, ipstr)) + if (parse_proc_intf6_line(buf, device, ipstr, sizeof(ipstr))) continue; if (proc_intf6_line_exists(parent_section, ipstr)) diff --git a/dmtree/tr181/wifi.c b/dmtree/tr181/wifi.c index 0fb3a12c..ca83f434 100644 --- a/dmtree/tr181/wifi.c +++ b/dmtree/tr181/wifi.c @@ -1554,20 +1554,11 @@ static int get_WiFiEndPointProfileSecurity_ModeEnabled(char *refparam, struct dm static int set_WiFiEndPointProfileSecurity_ModeEnabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) { - char *supported_modes = NULL; - switch (action) { case VALUECHECK: if (dm_validate_string(value, -1, -1, NULL, 0, NULL, 0)) return FAULT_9007; - // Get the list of all supported security modes - get_access_point_security_supported_modes(refparam, ctx, data, instance, &supported_modes); - - // Check if the input value is a valid security mode - if (supported_modes && strstr(supported_modes, value) == NULL) - return FAULT_9007; - return 0; case VALUESET: set_security_mode((struct uci_section *)data, value);