From 10ebd2add594d822a1db094a6e19e431ab69db78 Mon Sep 17 00:00:00 2001
From: Amin Ben Romdhane <amin.benromdhane@iopsys.eu>
Date: Sun, 20 Oct 2024 20:34:24 +0000
Subject: [PATCH] Revert "Fix usages of BBF_VENDOR_PREFIX macro"

This reverts commit ad4825bc6349d1cd68680aaaa6c5b217227c90fe
---
 .gitlab-ci.yml       | 2 +-
 src/Makefile         | 2 +-
 src/common.h         | 1 -
 src/interfacestack.c | 5 ++---
 src/ip.c             | 8 ++------
 src/ppp.c            | 5 ++---
 src/routing.c        | 1 -
 7 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b81ec81..1515e60 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,6 +1,6 @@
 variables:
   SOURCE_FOLDER: "src"
-  CFLAGS: "-DBBF_VENDOR_PREFIX=X_IOPSYS_EU"
+  CPPCHECK_OPTIONS: "--suppress=cert-MSC24-C -DBBF_VENDOR_PREFIX=X_IOPSYS_EU_"
 
 include:
   - project: 'iopsys/gitlab-ci-pipeline'
diff --git a/src/Makefile b/src/Makefile
index 7330df0..a60218d 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
+LIB_CFLAGS = $(CFLAGS) -Wall -Werror -fstrict-aliasing -g -DBBF_VENDOR_PREFIX=\"X_IOPSYS_EU_\"
 LIB_LDFLAGS = $(LDFLAGS)
 FPIC := -fPIC
 
diff --git a/src/common.h b/src/common.h
index 49bb75c..7661902 100644
--- a/src/common.h
+++ b/src/common.h
@@ -13,7 +13,6 @@
 #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 4a625d1..d0d238c 100644
--- a/src/interfacestack.c
+++ b/src/interfacestack.c
@@ -8,7 +8,6 @@
  *	Author: Amin Ben Romdhane <amin.benromdhane@iopsys.eu>
  */
 
-#include "common.h"
 #include "interfacestack.h"
 
 struct interfacestack_data
@@ -101,7 +100,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."STR(BBF_VENDOR_PREFIX)"MACVLAN.", strlen("Device.Ethernet."STR(BBF_VENDOR_PREFIX)"MACVLAN.")) == 0) {
+	} else if (DM_STRNCMP(path, "Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.", strlen("Device.Ethernet."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);
 	}
@@ -185,7 +184,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."STR(BBF_VENDOR_PREFIX)"MACVLAN.", "mac_vlan_instance", "mac_vlan_alias", &idx))
+				"Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN.", "mac_vlan_instance", "mac_vlan_alias", &idx))
 			goto end;
 	}
 
diff --git a/src/ip.c b/src/ip.c
index 8a3cf32..060b7e8 100644
--- a/src/ip.c
+++ b/src/ip.c
@@ -75,7 +75,6 @@ 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;
@@ -143,7 +142,6 @@ 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;
@@ -256,7 +254,6 @@ 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;
@@ -278,7 +275,6 @@ 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;
@@ -1307,7 +1303,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."STR(BBF_VENDOR_PREFIX)"MACVLAN.", "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.VLANTermination.", "Name", device, buf, sizeof(buf));
 		bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet.Link.", "Name", device, buf, sizeof(buf));
 
@@ -1329,7 +1325,7 @@ static int set_IPInterface_LowerLayers(char *refparam, struct dmctx *ctx, void *
 {
 	char *allowed_objects[] = {
 			"Device.PPP.Interface.",
-			"Device.Ethernet."STR(BBF_VENDOR_PREFIX)"MACVLAN",
+			"Device.Ethernet."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 5af533f..3293b71 100644
--- a/src/ppp.c
+++ b/src/ppp.c
@@ -682,7 +682,6 @@ 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");
@@ -957,7 +956,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."STR(BBF_VENDOR_PREFIX)"MACVLAN.", "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.VLANTermination.", "Name", device, buf, sizeof(buf));
 		bbfdm_get_references(ctx, MATCH_FIRST, "Device.Ethernet.Link.", "Name", device, buf, sizeof(buf));
 
@@ -974,7 +973,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."STR(BBF_VENDOR_PREFIX)"MACVLAN",
+			"Device.Ethernet."BBF_VENDOR_PREFIX"MACVLAN",
 			"Device.Ethernet.VLANTermination.",
 			"Device.Ethernet.Link.",
 			NULL};
diff --git a/src/routing.c b/src/routing.c
index c3c44a9..7757ed6 100644
--- a/src/routing.c
+++ b/src/routing.c
@@ -1010,7 +1010,6 @@ 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};
-- 
GitLab