From 2eaac0351dc943e0f0e2e66cbd75a996a12a308f Mon Sep 17 00:00:00 2001
From: Teodora <teodora.vladic@openairinterface.org>
Date: Tue, 26 Sep 2023 18:13:01 +0200
Subject: [PATCH] Fix compile error when --build-e2 option included

- modify byte_array.h in order to avoid conflict for same file names
---
 common/utils/ds/byte_array.c | 17 +++++++++++++++++
 common/utils/ds/byte_array.h |  8 ++++++--
 executables/nr-softmodem.c   |  2 +-
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/common/utils/ds/byte_array.c b/common/utils/ds/byte_array.c
index dfc8872662..c3281ffa27 100644
--- a/common/utils/ds/byte_array.c
+++ b/common/utils/ds/byte_array.c
@@ -22,6 +22,7 @@
 #include "byte_array.h"
 
 #include "common/utils/assertions.h"
+#include <assert.h>
 #include <string.h>
 
 byte_array_t copy_byte_array(byte_array_t src)
@@ -56,3 +57,19 @@ bool eq_byte_array(const byte_array_t* m0, const byte_array_t* m1)
 
   return true;
 }
+
+byte_array_t cp_str_to_ba(const char* str)
+{
+  assert(str != NULL);
+  
+  const size_t sz = strlen(str);
+
+  byte_array_t dst = {.len = sz};
+
+  dst.buf = calloc(sz,sizeof(uint8_t));
+  assert(dst.buf != NULL && "Memory exhausted");
+
+  memcpy(dst.buf, str, sz);
+
+  return dst;
+}
diff --git a/common/utils/ds/byte_array.h b/common/utils/ds/byte_array.h
index f16fd7c01d..236f3e683f 100644
--- a/common/utils/ds/byte_array.h
+++ b/common/utils/ds/byte_array.h
@@ -19,8 +19,10 @@
  *      contact@openairinterface.org
  */
 
-#ifndef BYTE_ARRAY_H_OAI
-#define BYTE_ARRAY_H_OAI
+#ifndef BYTE_ARRAY_H 
+#define BYTE_ARRAY_H 
+
+/* WARNING: This file is also defined at XXXXX. Both files need to be completely equal. Same applies for *.c */
 
 #include <stdbool.h>
 #include <stdint.h>
@@ -39,4 +41,6 @@ byte_array_t copy_byte_array(byte_array_t src);
 void free_byte_array(byte_array_t ba);
 bool eq_byte_array(const byte_array_t* m0, const byte_array_t* m1);
 
+byte_array_t cp_str_to_ba(const char* str);
+
 #endif
diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c
index 8bffda8f61..31bde16b97 100644
--- a/executables/nr-softmodem.c
+++ b/executables/nr-softmodem.c
@@ -709,7 +709,7 @@ int main( int argc, char **argv ) {
   const int mcc = rrc->configuration.mcc[0];
   const int mnc = rrc->configuration.mnc[0];
   const int mnc_digit_len = rrc->configuration.mnc_digit_length[0];
-  const ngran_node_t node_type = rrc->node_type;
+  // const ngran_node_t node_type = rrc->node_type;
   int nb_id = 0;
   int cu_du_id = 0;
   if (node_type == ngran_gNB) {
-- 
2.26.2