diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1515e602c366c361d42786021c830ec1bb2dbc72..b81ec81eb681321c5cff0b948698a0edfd2845e7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ variables: SOURCE_FOLDER: "src" - CPPCHECK_OPTIONS: "--suppress=cert-MSC24-C -DBBF_VENDOR_PREFIX=X_IOPSYS_EU_" + CFLAGS: "-DBBF_VENDOR_PREFIX=X_IOPSYS_EU" include: - project: 'iopsys/gitlab-ci-pipeline' diff --git a/src/Makefile b/src/Makefile index a60218dd97c14267131ee2ed9edbf449c10603ed..7330df00c5fc8d519f5a54233e17057bf1f8e354 100644 --- a/src/Makefile +++ b/src/Makefile @@ -11,7 +11,7 @@ LIBNETMNGROBJS := net_plugin.o \ LIBIFACESTACKOBJS := interfacestack.o -LIB_CFLAGS = $(CFLAGS) -Wall -Werror -fstrict-aliasing -g -DBBF_VENDOR_PREFIX=\"X_IOPSYS_EU_\" +LIB_CFLAGS = $(CFLAGS) -Wall -Werror -fstrict-aliasing -g LIB_LDFLAGS = $(LDFLAGS) FPIC := -fPIC diff --git a/src/common.h b/src/common.h index 7661902ec55d64c14803ef471fb0cdd3ec3c3119..49bb75c518b2993865f8c01ed4f41a1434d6c3b5 100644 --- a/src/common.h +++ b/src/common.h @@ -13,6 +13,7 @@ #define __DMLAYER_H__ #include "libbbfdm-api/dmcommon.h" +#define STR(s) #s void gre___get_tunnel_system_name(struct uci_section *iface_section, char *device_str, size_t device_str_size); diff --git a/src/interfacestack.c b/src/interfacestack.c index d0d238c9647c3b488d320c6fc72f82ac7588f3f9..4a625d18ca6341fd98be9f7212a5156d7cf27efb 100644 --- a/src/interfacestack.c +++ b/src/interfacestack.c @@ -8,6 +8,7 @@ * Author: Amin Ben Romdhane <amin.benromdhane@iopsys.eu> */ +#include "common.h" #include "interfacestack.h" struct interfacestack_data @@ -100,7 +101,7 @@ static char *get_lower_alias_value(const char *path) } else if (DM_STRNCMP(path, "Device.PPP.Interface.", strlen("Device.PPP.Interface.")) == 0) { get_dmmap_section_of_config_section_eq("dmmap_ppp", "interface", "ppp_int_instance", instance + 1, &s); dmuci_get_value_by_section_string(s, "ppp_int_alias", &alias_value); - } else if (DM_STRNCMP(path, "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.", strlen("Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.")) == 0) { + } else if (DM_STRNCMP(path, "Device.Ethernet."STR(BBF_VENDOR_PREFIX)"MACVLAN.", strlen("Device.Ethernet."STR(BBF_VENDOR_PREFIX)"MACVLAN.")) == 0) { get_dmmap_section_of_config_section_eq("dmmap_network", "device", "mac_vlan_instance", instance + 1, &s); dmuci_get_value_by_section_string(s, "mac_vlan_alias", &alias_value); } @@ -184,7 +185,7 @@ static int browseInterfaceStackInst(struct dmctx *dmctx, DMNODE *parent_node, vo uci_path_foreach_sections(bbfdm, "dmmap_network", "device", s) { if (create_interface_stack_instance(dmctx, parent_node, &curr_interfacestack_data, s, - "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.", "mac_vlan_instance", "mac_vlan_alias", &idx)) + "Device.Ethernet."STR(BBF_VENDOR_PREFIX)"MACVLAN.", "mac_vlan_instance", "mac_vlan_alias", &idx)) goto end; } diff --git a/src/ip.c b/src/ip.c index 060b7e8563a1379ac42fd6d9ce47c8171a4dc16b..8a3cf320229e20c174fb698e627061fe054951b0 100644 --- a/src/ip.c +++ b/src/ip.c @@ -75,6 +75,7 @@ static bool browse_ip_port(struct dmctx *dmctx, DMNODE *parent_node, bool is_ipv if (proc_path == NULL || DM_STRLEN(proc_path) == 0) return is_instance; + // cppcheck-suppress cert-MSC24-C FILE* fp = fopen(proc_path, "r"); if (fp == NULL) { return is_instance; @@ -142,6 +143,7 @@ static int set_sysctl_disable_ipv6_per_device(const char *device, bool value) char cmd[128] = {0}; char path[64] = {0}; + // cppcheck-suppress cert-MSC24-C fp = fopen("/etc/bbfdm/sysctl.conf", "r+"); if (!fp) return -1; @@ -254,6 +256,7 @@ static void dmmap_synchronize_ipv6_address_link_local(const char *parent_section dmuci_get_value_by_section_string(s, "address", &address); + // cppcheck-suppress cert-MSC24-C fp = fopen(PROC_INTF6, "r"); if (fp == NULL) return; @@ -275,6 +278,7 @@ static void dmmap_synchronize_ipv6_address_link_local(const char *parent_section dmuci_delete_by_section(s, NULL, NULL); } + // cppcheck-suppress cert-MSC24-C fp = fopen(PROC_INTF6, "r"); if (fp == NULL) return; @@ -1303,7 +1307,7 @@ static int get_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void * } bbfdm_get_references(ctx, MATCH_FIRST, "Device.PPP.Interface.", "Name", device, buf, sizeof(buf)); - bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.", "Name", device, buf, sizeof(buf)); + bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet."STR(BBF_VENDOR_PREFIX)"MACVLAN.", "Name", device, buf, sizeof(buf)); bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet.VLANTermination.", "Name", device, buf, sizeof(buf)); bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet.Link.", "Name", device, buf, sizeof(buf)); @@ -1325,7 +1329,7 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void * { char *allowed_objects[] = { "Device.PPP.Interface.", - "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN", + "Device.Ethernet."STR(BBF_VENDOR_PREFIX)"MACVLAN", "Device.Ethernet.VLANTermination.", "Device.Ethernet.Link.", "Device.GRE.Tunnel.*.Interface.", diff --git a/src/ppp.c b/src/ppp.c index 3293b7152d7e0d1bf8395ed6cfbda20526d98c83..5af533fd3b07a185ee5e79612a6e387addb9aff8 100644 --- a/src/ppp.c +++ b/src/ppp.c @@ -682,6 +682,7 @@ static int set_PPPInterface_IPv6CPEnable(char *refparam, struct dmctx *ctx, void static int get_PPPInterfacePPPoE_SessionID(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { + // cppcheck-suppress cert-MSC24-C FILE *fp = fopen("/proc/net/pppoe" ,"r"); if (NULL == fp) { *value = dmstrdup("1"); @@ -956,7 +957,7 @@ static int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch if (DM_STRLEN(device) == 0) return 0; - bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.", "Name", device, buf, sizeof(buf)); + bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet."STR(BBF_VENDOR_PREFIX)"MACVLAN.", "Name", device, buf, sizeof(buf)); bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet.VLANTermination.", "Name", device, buf, sizeof(buf)); bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet.Link.", "Name", device, buf, sizeof(buf)); @@ -973,7 +974,7 @@ static int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, ch { struct dm_data *ppp = (struct dm_data *)data; char *allowed_objects[] = { - "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN", + "Device.Ethernet."STR(BBF_VENDOR_PREFIX)"MACVLAN", "Device.Ethernet.VLANTermination.", "Device.Ethernet.Link.", NULL}; diff --git a/src/routing.c b/src/routing.c index 7757ed6ee66ef79309f20546819554cd3d999959..c3c44a9139e0e6a7c83340960553ffc912a4ee0e 100644 --- a/src/routing.c +++ b/src/routing.c @@ -1010,6 +1010,7 @@ static int get_RoutingRouteInformationInterfaceSetting_Interface(char *refparam, snprintf(cmd, sizeof(cmd), "ip -6 route show"); + // cppcheck-suppress cert-MSC24-C FILE *fp = fopen(PROC_ROUTE6, "r"); if (fp != NULL) { char line[MAX_ROUTE_LEN] = {0};