Hi Thang,

ACK from me.

Best Regards,
Thien

________________________________
From: Thang Duc Nguyen <thang.d.ngu...@dektech.com.au>
Sent: Monday, January 15, 2024 5:42 PM
To: Thien Minh Huynh <thien.m.hu...@dektech.com.au>; Dat Tran Quoc Phan 
<dat.tq.p...@dektech.com.au>
Cc: opensaf-devel@lists.sourceforge.net <opensaf-devel@lists.sourceforge.net>; 
Thang Duc Nguyen <thang.d.ngu...@dektech.com.au>
Subject: [PATCH 1/1] osaf: supports compile/build with gcc/g++ 12 [#3346]

Fix error when compiling/building Opensaf using
gcc/g++ 12.
---
 src/amf/amfd/node.h                |  5 +++-
 src/dtm/dtmnd/dtm_node_db.cc       |  2 +-
 src/imm/immnd/immnd_proc.c         |  2 +-
 src/osaf/consensus/key_value.cc    |  1 +
 src/smf/smfd/SmfProcedureThread.cc | 43 +++++++++++++++---------------
 5 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/src/amf/amfd/node.h b/src/amf/amfd/node.h
index 37b8ce938..3456adb85 100644
--- a/src/amf/amfd/node.h
+++ b/src/amf/amfd/node.h
@@ -166,7 +166,10 @@ class AVD_AVND {
 bool operator<(const AVD_AVND &lhs, const AVD_AVND &rhs);

 struct NodeNameCompare
-    : public std::binary_function<AVD_AVND *, AVD_AVND *, bool> {
+{
+  typedef AVD_AVND first_argument_type;
+  typedef AVD_AVND second_argument_type;
+  typedef bool result_type;
   bool operator()(const AVD_AVND *lhs, const AVD_AVND *rhs);
 };

diff --git a/src/dtm/dtmnd/dtm_node_db.cc b/src/dtm/dtmnd/dtm_node_db.cc
index 679368971..aa7125b68 100644
--- a/src/dtm/dtmnd/dtm_node_db.cc
+++ b/src/dtm/dtmnd/dtm_node_db.cc
@@ -292,7 +292,7 @@ uint32_t dtm_node_delete(DTM_NODE_DB *node, KeyTypes type) {
       break;

     case KeyTypes::kDtmNodeIpKeyType:
-      if (node->node_ip != nullptr && node->pat_ip_address.key_info) {
+      if (strlen(node->node_ip) != 0 && node->pat_ip_address.key_info) {
         TRACE("DTM:Deleting node_ip from the  database with node_ip :%s as 
key",
               node->node_ip);
         if ((rc = ncs_patricia_tree_del(&dtms_cb->ip_addr_tree,
diff --git a/src/imm/immnd/immnd_proc.c b/src/imm/immnd/immnd_proc.c
index bf14d18a8..5df703799 100644
--- a/src/imm/immnd/immnd_proc.c
+++ b/src/imm/immnd/immnd_proc.c
@@ -1901,7 +1901,7 @@ static int immnd_forkPbe(IMMND_CB *cb)
                 return -1;
         }

-       strncpy(execPath, cb->mProgName, execDirLen);
+       memcpy(execPath, cb->mProgName, execDirLen);
         execPath[execDirLen] = 0;
         if ((execDirLen == 0) || (cb->mProgName[execDirLen - 1] != '/'))
                 strncat(execPath, "/", 2);
diff --git a/src/osaf/consensus/key_value.cc b/src/osaf/consensus/key_value.cc
index 692dd3f1d..b3417c735 100644
--- a/src/osaf/consensus/key_value.cc
+++ b/src/osaf/consensus/key_value.cc
@@ -18,6 +18,7 @@
 #include "base/getenv.h"
 #include "base/logtrace.h"
 #include "osaf/consensus/consensus.h"
+#include <array>

 int KeyValue::Execute(const std::string& command, std::string& output) {
   TRACE_ENTER();
diff --git a/src/smf/smfd/SmfProcedureThread.cc 
b/src/smf/smfd/SmfProcedureThread.cc
index f41e89288..db52895dc 100644
--- a/src/smf/smfd/SmfProcedureThread.cc
+++ b/src/smf/smfd/SmfProcedureThread.cc
@@ -441,30 +441,31 @@ SaAisErrorT SmfProcedureThread::getImmProcedure(
   implementorName = immutil_getStringAttr(
       (const SaImmAttrValuesT_2 **)attributes, SA_IMM_ATTR_IMPLEMENTER_NAME, 
0);

-  if ((implementorName != NULL) &&
-      (strcmp(implementorName, procedure->getProcName().c_str())) &&
+  if (implementorName != NULL) {
+    if(strcmp(implementorName, procedure->getProcName().c_str()) &&
       strncmp(implementorName, SMF_PROC_OI_NAME_PREFIX,
               strlen(SMF_PROC_OI_NAME_PREFIX))) {
-    /* The implementor name:
-     *    -is not the procedure name (newer implementation of SMF)
-     *    -and does not start with the SMF procedure OI name prefix (even newer
-     * implementation of SMF) which means the procedure object was created by 
an
-     * old version of SMF. So we have to continue using this old implementor
-     * name (i.e. IMM handle) for this procedure. This is just to be able to
-     * handle the upgrade case where a new opensaf is upgraded by an old 
opensaf
-     * version (which used the campaign Dn as implementor name for everything).
-     */
-    LOG_NO("SmfProcedureThread::getImmProcedure, Using campaign IMM handle %s",
-           implementorName);
-    m_useCampaignOiHandle = true;
-  } else {
-    LOG_NO("SmfProcedureThread::getImmProcedure, Using own IMM handle %s",
-           implementorName);
-    // Overwrite the already existing OI name (that was generated by the
-    // constructor)
-    procedure->setProcOiName(implementorName);
+      /* The implementor name:
+      *    -is not the procedure name (newer implementation of SMF)
+      *    -and does not start with the SMF procedure OI name prefix (even 
newer
+      * implementation of SMF) which means the procedure object was created by
+      * an old version of SMF. So we have to continue using this old
+      * implementor name (i.e. IMM handle) for this procedure. This is just to
+      * be able to handle the upgrade case where a new opensaf is upgraded by
+      * an old opensaf version (which used the campaign Dn as implementor name
+      * for everything).
+      */
+      LOG_NO("SmfProcedureThread::getImmProcedure, Using campaign IMM \
+            handle %s", implementorName);
+      m_useCampaignOiHandle = true;
+    } else {
+      LOG_NO("SmfProcedureThread::getImmProcedure, Using own IMM handle %s",
+            implementorName);
+      // Overwrite the already existing OI name (that was generated by the
+      // constructor)
+      procedure->setProcOiName(implementorName);
+    }
   }
-
 done:
   TRACE_LEAVE();
   return rc;
--
2.25.1


_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to