Re: [devel] [PATCH 1/3] amfnd: Refactor AVND_COMP for simpler environment variable handling [#1945]
Hi Hans Ack for the series. Minor comment, perhaps compare_sanamet() can be moved to common as amfd already has a copy. Thanks Gary On 14/6/17, 5:17 pm, "Hans Nordebäck"wrote: Hi Praveen, thanks for reviewing, for info, the patch series also implies the following improvements: avnd_comp_clc_cmd_execute after refactoring: cyclomatic complexity reduced from 23 to 19 (-17%) # stmts reduced from 150 to 98 (-35%) # lines in function reduced from 259 to 184 (-29%) /Thanks Hans On 06/14/2017 08:52 AM, praveen malviya wrote: > Ack for the series. > > > Thanks > PRaveen > > On 13-Jun-17 4:54 PM, Hans Nordeback wrote: >> --- >> src/amf/amfnd/avnd_comp.h | 134 >> ++ >> src/amf/amfnd/avnd_err.h | 4 +- >> src/amf/amfnd/avnd_hc.h | 2 +- >> src/amf/amfnd/avnd_proc.h | 10 ++-- >> src/amf/amfnd/avnd_util.h | 2 +- >> src/amf/amfnd/clc.cc | 125 >> -- >> src/amf/amfnd/comp.cc | 35 >> src/amf/amfnd/compdb.cc | 36 +++-- >> src/amf/amfnd/proxydb.cc | 2 +- >> 9 files changed, 138 insertions(+), 212 deletions(-) >> >> diff --git a/src/amf/amfnd/avnd_comp.h b/src/amf/amfnd/avnd_comp.h >> index 611e90e11..68de4cc8e 100644 >> --- a/src/amf/amfnd/avnd_comp.h >> +++ b/src/amf/amfnd/avnd_comp.h >> @@ -31,6 +31,8 @@ >> #define AMF_AMFND_AVND_COMP_H_ >> #include >> +#include >> +#include >> struct avnd_cb_tag; >> struct avnd_su_si_rec; >> @@ -57,7 +59,7 @@ struct avnd_srm_req_tag; >> /* clc event handler declaration */ >> typedef uint32_t (*AVND_COMP_CLC_FSM_FN)(struct avnd_cb_tag *, >> - struct avnd_comp_tag *); >> + AVND_COMP *); >> /* clc fsm events */ >> typedef enum avnd_comp_clc_pres_fsm_ev { >> @@ -141,7 +143,7 @@ typedef struct avnd_cbk_tag { >> AVSV_AMF_CBK_INFO *cbk_info; /* callbk info */ >> /* link to other elements */ >> - struct avnd_comp_tag *comp; /* bk ptr to the comp */ >> + AVND_COMP *comp; /* bk ptr to the comp */ >> struct avnd_cbk_tag *next; >> std::string comp_name; /* For checkpointing */ >> } AVND_COMP_CBK; >> @@ -182,7 +184,7 @@ typedef struct avnd_comp_csi_rec { >> wrt prv ha state */ >> /* links to other entities */ >> - struct avnd_comp_tag *comp; /* bk ptr to the comp */ >> + AVND_COMP *comp; /* bk ptr to the comp */ >> struct avnd_su_si_rec *si; /* bk ptr to the si >> record */ >> std::string comp_name; /* For Checkpointing */ >> std::string si_name;/* For Checkpointing */ >> @@ -256,7 +258,7 @@ typedef struct avnd_hc_rec_tag { >> uint32_t opq_hdl; /* hdl returned by hdl-mngr (used during tmr >> expiry) */ >> AVND_COMP_HC_STATUS status; /* indicates status of hc rec */ >> - struct avnd_comp_tag *comp; /* back ptr to the comp */ >> + AVND_COMP *comp; /* back ptr to the comp */ >> struct avnd_hc_rec_tag *next; >> std::string comp_name; /* For checkpoiting */ >> } AVND_COMP_HC_REC; >> @@ -278,7 +280,7 @@ typedef struct avnd_pm_rec { >> } rec_rcvr; >> /* links to other entities */ >> - struct avnd_comp_tag *comp; /* back ptr to the comp */ >> + AVND_COMP *comp; /* back ptr to the comp */ >> } AVND_COMP_PM_REC; >> /*## >> @@ -288,7 +290,7 @@ typedef struct avnd_pm_rec { >> /* proxied info */ >> typedef struct avnd_pxied_rec { >> NCS_DB_LINK_LIST_NODE comp_dll_node; /* node in the comp-pxied >> dll */ >> - struct avnd_comp_tag *pxied_comp;/* ptr to the proxied comp */ >> + AVND_COMP *pxied_comp;/* ptr to the proxied comp */ >> } AVND_COMP_PXIED_REC; >> #define AVND_COMP_TYPE_LOCAL_NODE 0x0001 >> @@ -319,100 +321,115 @@ enum UsedComptypeAttrs { >> NumAttrs >> }; >> -typedef struct avnd_comp_tag { >> - NCS_DB_LINK_LIST_NODE su_dll_node; /* su dll node (key is >> inst-level) */ >> +class AVND_COMP { >> + public: >> + // TODO(uabhano) replace the NCS_DB_LINK_LIST_NODE with C++ STL. >> Now su_dll_node must be first in AVND_COMP >> + // as the macro m_AVND_COMP_SU_DLL_NODE_OFFSET depends on the >> offset. offsetof is to be avoided in classes. >> + NCS_DB_LINK_LIST_NODE su_dll_node {}; /* su dll node (key is >> inst-level) */ >> + AVND_COMP() {} >> + ~AVND_COMP() {}
Re: [devel] [PATCH 1/3] amfnd: Refactor AVND_COMP for simpler environment variable handling [#1945]
Hi Praveen, thanks for reviewing, for info, the patch series also implies the following improvements: avnd_comp_clc_cmd_execute after refactoring: cyclomatic complexity reduced from 23 to 19 (-17%) # stmts reduced from 150 to 98 (-35%) # lines in function reduced from 259 to 184 (-29%) /Thanks Hans On 06/14/2017 08:52 AM, praveen malviya wrote: Ack for the series. Thanks PRaveen On 13-Jun-17 4:54 PM, Hans Nordeback wrote: --- src/amf/amfnd/avnd_comp.h | 134 ++ src/amf/amfnd/avnd_err.h | 4 +- src/amf/amfnd/avnd_hc.h | 2 +- src/amf/amfnd/avnd_proc.h | 10 ++-- src/amf/amfnd/avnd_util.h | 2 +- src/amf/amfnd/clc.cc | 125 -- src/amf/amfnd/comp.cc | 35 src/amf/amfnd/compdb.cc | 36 +++-- src/amf/amfnd/proxydb.cc | 2 +- 9 files changed, 138 insertions(+), 212 deletions(-) diff --git a/src/amf/amfnd/avnd_comp.h b/src/amf/amfnd/avnd_comp.h index 611e90e11..68de4cc8e 100644 --- a/src/amf/amfnd/avnd_comp.h +++ b/src/amf/amfnd/avnd_comp.h @@ -31,6 +31,8 @@ #define AMF_AMFND_AVND_COMP_H_ #include +#include +#include struct avnd_cb_tag; struct avnd_su_si_rec; @@ -57,7 +59,7 @@ struct avnd_srm_req_tag; /* clc event handler declaration */ typedef uint32_t (*AVND_COMP_CLC_FSM_FN)(struct avnd_cb_tag *, - struct avnd_comp_tag *); + AVND_COMP *); /* clc fsm events */ typedef enum avnd_comp_clc_pres_fsm_ev { @@ -141,7 +143,7 @@ typedef struct avnd_cbk_tag { AVSV_AMF_CBK_INFO *cbk_info; /* callbk info */ /* link to other elements */ - struct avnd_comp_tag *comp; /* bk ptr to the comp */ + AVND_COMP *comp; /* bk ptr to the comp */ struct avnd_cbk_tag *next; std::string comp_name; /* For checkpointing */ } AVND_COMP_CBK; @@ -182,7 +184,7 @@ typedef struct avnd_comp_csi_rec { wrt prv ha state */ /* links to other entities */ - struct avnd_comp_tag *comp; /* bk ptr to the comp */ + AVND_COMP *comp; /* bk ptr to the comp */ struct avnd_su_si_rec *si; /* bk ptr to the si record */ std::string comp_name; /* For Checkpointing */ std::string si_name;/* For Checkpointing */ @@ -256,7 +258,7 @@ typedef struct avnd_hc_rec_tag { uint32_t opq_hdl; /* hdl returned by hdl-mngr (used during tmr expiry) */ AVND_COMP_HC_STATUS status; /* indicates status of hc rec */ - struct avnd_comp_tag *comp; /* back ptr to the comp */ + AVND_COMP *comp; /* back ptr to the comp */ struct avnd_hc_rec_tag *next; std::string comp_name; /* For checkpoiting */ } AVND_COMP_HC_REC; @@ -278,7 +280,7 @@ typedef struct avnd_pm_rec { } rec_rcvr; /* links to other entities */ - struct avnd_comp_tag *comp; /* back ptr to the comp */ + AVND_COMP *comp; /* back ptr to the comp */ } AVND_COMP_PM_REC; /*## @@ -288,7 +290,7 @@ typedef struct avnd_pm_rec { /* proxied info */ typedef struct avnd_pxied_rec { NCS_DB_LINK_LIST_NODE comp_dll_node; /* node in the comp-pxied dll */ - struct avnd_comp_tag *pxied_comp;/* ptr to the proxied comp */ + AVND_COMP *pxied_comp;/* ptr to the proxied comp */ } AVND_COMP_PXIED_REC; #define AVND_COMP_TYPE_LOCAL_NODE 0x0001 @@ -319,100 +321,115 @@ enum UsedComptypeAttrs { NumAttrs }; -typedef struct avnd_comp_tag { - NCS_DB_LINK_LIST_NODE su_dll_node; /* su dll node (key is inst-level) */ +class AVND_COMP { + public: + // TODO(uabhano) replace the NCS_DB_LINK_LIST_NODE with C++ STL. Now su_dll_node must be first in AVND_COMP + // as the macro m_AVND_COMP_SU_DLL_NODE_OFFSET depends on the offset. offsetof is to be avoided in classes. + NCS_DB_LINK_LIST_NODE su_dll_node {}; /* su dll node (key is inst-level) */ + AVND_COMP() {} + ~AVND_COMP() {} std::string name; /* comp name */ std::string saAmfCompType; - uint32_t numOfCompCmdEnv; /* number of comp command environment variables */ - SaStringT *saAmfCompCmdEnv; /* comp command environment variables */ - uint32_t inst_level;/* comp instantiation level */ - uint32_t comp_hdl; /* hdl returned by hdl-mngr */ + uint32_t inst_level {};/* comp instantiation level */ + + uint32_t comp_hdl {}; /* hdl returned by hdl-mngr */ /* component attributes */ - uint32_t flag; /* comp attributes */ - bool is_restart_en; /* flag to indicate if comp-restart is allowed */ - SaAmfCompCapabilityModelT cap; /* comp capability model */ - bool is_am_en; - bool is_hc_cmd_configured; + uint32_t flag {}; /* comp attributes */ + bool is_restart_en {}; /* flag to indicate if comp-restart is allowed */ + SaAmfCompCapabilityModelT cap {}; /* comp capability model */ + bool
Re: [devel] [PATCH 1/3] amfnd: Refactor AVND_COMP for simpler environment variable handling [#1945]
Ack for the series. Thanks PRaveen On 13-Jun-17 4:54 PM, Hans Nordeback wrote: --- src/amf/amfnd/avnd_comp.h | 134 ++ src/amf/amfnd/avnd_err.h | 4 +- src/amf/amfnd/avnd_hc.h | 2 +- src/amf/amfnd/avnd_proc.h | 10 ++-- src/amf/amfnd/avnd_util.h | 2 +- src/amf/amfnd/clc.cc | 125 -- src/amf/amfnd/comp.cc | 35 src/amf/amfnd/compdb.cc | 36 +++-- src/amf/amfnd/proxydb.cc | 2 +- 9 files changed, 138 insertions(+), 212 deletions(-) diff --git a/src/amf/amfnd/avnd_comp.h b/src/amf/amfnd/avnd_comp.h index 611e90e11..68de4cc8e 100644 --- a/src/amf/amfnd/avnd_comp.h +++ b/src/amf/amfnd/avnd_comp.h @@ -31,6 +31,8 @@ #define AMF_AMFND_AVND_COMP_H_ #include +#include +#include struct avnd_cb_tag; struct avnd_su_si_rec; @@ -57,7 +59,7 @@ struct avnd_srm_req_tag; /* clc event handler declaration */ typedef uint32_t (*AVND_COMP_CLC_FSM_FN)(struct avnd_cb_tag *, - struct avnd_comp_tag *); + AVND_COMP *); /* clc fsm events */ typedef enum avnd_comp_clc_pres_fsm_ev { @@ -141,7 +143,7 @@ typedef struct avnd_cbk_tag { AVSV_AMF_CBK_INFO *cbk_info; /* callbk info */ /* link to other elements */ - struct avnd_comp_tag *comp; /* bk ptr to the comp */ + AVND_COMP *comp; /* bk ptr to the comp */ struct avnd_cbk_tag *next; std::string comp_name; /* For checkpointing */ } AVND_COMP_CBK; @@ -182,7 +184,7 @@ typedef struct avnd_comp_csi_rec { wrt prv ha state */ /* links to other entities */ - struct avnd_comp_tag *comp; /* bk ptr to the comp */ + AVND_COMP *comp; /* bk ptr to the comp */ struct avnd_su_si_rec *si; /* bk ptr to the si record */ std::string comp_name; /* For Checkpointing */ std::string si_name;/* For Checkpointing */ @@ -256,7 +258,7 @@ typedef struct avnd_hc_rec_tag { uint32_t opq_hdl; /* hdl returned by hdl-mngr (used during tmr expiry) */ AVND_COMP_HC_STATUS status; /* indicates status of hc rec */ - struct avnd_comp_tag *comp; /* back ptr to the comp */ + AVND_COMP *comp; /* back ptr to the comp */ struct avnd_hc_rec_tag *next; std::string comp_name; /* For checkpoiting */ } AVND_COMP_HC_REC; @@ -278,7 +280,7 @@ typedef struct avnd_pm_rec { } rec_rcvr; /* links to other entities */ - struct avnd_comp_tag *comp; /* back ptr to the comp */ + AVND_COMP *comp; /* back ptr to the comp */ } AVND_COMP_PM_REC; /*## @@ -288,7 +290,7 @@ typedef struct avnd_pm_rec { /* proxied info */ typedef struct avnd_pxied_rec { NCS_DB_LINK_LIST_NODE comp_dll_node; /* node in the comp-pxied dll */ - struct avnd_comp_tag *pxied_comp;/* ptr to the proxied comp */ + AVND_COMP *pxied_comp;/* ptr to the proxied comp */ } AVND_COMP_PXIED_REC; #define AVND_COMP_TYPE_LOCAL_NODE 0x0001 @@ -319,100 +321,115 @@ enum UsedComptypeAttrs { NumAttrs }; -typedef struct avnd_comp_tag { - NCS_DB_LINK_LIST_NODE su_dll_node; /* su dll node (key is inst-level) */ +class AVND_COMP { + public: + // TODO(uabhano) replace the NCS_DB_LINK_LIST_NODE with C++ STL. Now su_dll_node must be first in AVND_COMP + // as the macro m_AVND_COMP_SU_DLL_NODE_OFFSET depends on the offset. offsetof is to be avoided in classes. + NCS_DB_LINK_LIST_NODE su_dll_node {}; /* su dll node (key is inst-level) */ + AVND_COMP() {} + ~AVND_COMP() {} std::string name; /* comp name */ std::string saAmfCompType; - uint32_t numOfCompCmdEnv; /* number of comp command environment variables */ - SaStringT *saAmfCompCmdEnv; /* comp command environment variables */ - uint32_t inst_level;/* comp instantiation level */ - uint32_t comp_hdl; /* hdl returned by hdl-mngr */ + uint32_t inst_level {};/* comp instantiation level */ + + uint32_t comp_hdl {}; /* hdl returned by hdl-mngr */ /* component attributes */ - uint32_t flag; /* comp attributes */ - bool is_restart_en; /* flag to indicate if comp-restart is allowed */ - SaAmfCompCapabilityModelT cap; /* comp capability model */ - bool is_am_en; - bool is_hc_cmd_configured; + uint32_t flag {}; /* comp attributes */ + bool is_restart_en {}; /* flag to indicate if comp-restart is allowed */ + SaAmfCompCapabilityModelT cap {}; /* comp capability model */ + bool is_am_en {}; + bool is_hc_cmd_configured {}; /* clc info */ - AVND_COMP_CLC_INFO clc_info; + AVND_COMP_CLC_INFO clc_info {}; /* Update received flag, which will normally be false and will be * true if updates are received from the AVD on fail-over.*/ - bool avd_updt_flag; + bool avd_updt_flag {}; /*
[devel] [PATCH 1/3] amfnd: Refactor AVND_COMP for simpler environment variable handling [#1945]
--- src/amf/amfnd/avnd_comp.h | 134 ++ src/amf/amfnd/avnd_err.h | 4 +- src/amf/amfnd/avnd_hc.h | 2 +- src/amf/amfnd/avnd_proc.h | 10 ++-- src/amf/amfnd/avnd_util.h | 2 +- src/amf/amfnd/clc.cc | 125 -- src/amf/amfnd/comp.cc | 35 src/amf/amfnd/compdb.cc | 36 +++-- src/amf/amfnd/proxydb.cc | 2 +- 9 files changed, 138 insertions(+), 212 deletions(-) diff --git a/src/amf/amfnd/avnd_comp.h b/src/amf/amfnd/avnd_comp.h index 611e90e11..68de4cc8e 100644 --- a/src/amf/amfnd/avnd_comp.h +++ b/src/amf/amfnd/avnd_comp.h @@ -31,6 +31,8 @@ #define AMF_AMFND_AVND_COMP_H_ #include +#include +#include struct avnd_cb_tag; struct avnd_su_si_rec; @@ -57,7 +59,7 @@ struct avnd_srm_req_tag; /* clc event handler declaration */ typedef uint32_t (*AVND_COMP_CLC_FSM_FN)(struct avnd_cb_tag *, - struct avnd_comp_tag *); + AVND_COMP *); /* clc fsm events */ typedef enum avnd_comp_clc_pres_fsm_ev { @@ -141,7 +143,7 @@ typedef struct avnd_cbk_tag { AVSV_AMF_CBK_INFO *cbk_info; /* callbk info */ /* link to other elements */ - struct avnd_comp_tag *comp; /* bk ptr to the comp */ + AVND_COMP *comp; /* bk ptr to the comp */ struct avnd_cbk_tag *next; std::string comp_name; /* For checkpointing */ } AVND_COMP_CBK; @@ -182,7 +184,7 @@ typedef struct avnd_comp_csi_rec { wrt prv ha state */ /* links to other entities */ - struct avnd_comp_tag *comp; /* bk ptr to the comp */ + AVND_COMP *comp; /* bk ptr to the comp */ struct avnd_su_si_rec *si; /* bk ptr to the si record */ std::string comp_name; /* For Checkpointing */ std::string si_name;/* For Checkpointing */ @@ -256,7 +258,7 @@ typedef struct avnd_hc_rec_tag { uint32_t opq_hdl; /* hdl returned by hdl-mngr (used during tmr expiry) */ AVND_COMP_HC_STATUS status; /* indicates status of hc rec */ - struct avnd_comp_tag *comp; /* back ptr to the comp */ + AVND_COMP *comp; /* back ptr to the comp */ struct avnd_hc_rec_tag *next; std::string comp_name; /* For checkpoiting */ } AVND_COMP_HC_REC; @@ -278,7 +280,7 @@ typedef struct avnd_pm_rec { } rec_rcvr; /* links to other entities */ - struct avnd_comp_tag *comp; /* back ptr to the comp */ + AVND_COMP *comp; /* back ptr to the comp */ } AVND_COMP_PM_REC; /*## @@ -288,7 +290,7 @@ typedef struct avnd_pm_rec { /* proxied info */ typedef struct avnd_pxied_rec { NCS_DB_LINK_LIST_NODE comp_dll_node; /* node in the comp-pxied dll */ - struct avnd_comp_tag *pxied_comp;/* ptr to the proxied comp */ + AVND_COMP *pxied_comp;/* ptr to the proxied comp */ } AVND_COMP_PXIED_REC; #define AVND_COMP_TYPE_LOCAL_NODE 0x0001 @@ -319,100 +321,115 @@ enum UsedComptypeAttrs { NumAttrs }; -typedef struct avnd_comp_tag { - NCS_DB_LINK_LIST_NODE su_dll_node; /* su dll node (key is inst-level) */ +class AVND_COMP { + public: + // TODO(uabhano) replace the NCS_DB_LINK_LIST_NODE with C++ STL. Now su_dll_node must be first in AVND_COMP + // as the macro m_AVND_COMP_SU_DLL_NODE_OFFSET depends on the offset. offsetof is to be avoided in classes. + NCS_DB_LINK_LIST_NODE su_dll_node {}; /* su dll node (key is inst-level) */ + AVND_COMP() {} + ~AVND_COMP() {} std::string name; /* comp name */ std::string saAmfCompType; - uint32_t numOfCompCmdEnv; /* number of comp command environment variables */ - SaStringT *saAmfCompCmdEnv; /* comp command environment variables */ - uint32_t inst_level;/* comp instantiation level */ - uint32_t comp_hdl; /* hdl returned by hdl-mngr */ + uint32_t inst_level {};/* comp instantiation level */ + + uint32_t comp_hdl {}; /* hdl returned by hdl-mngr */ /* component attributes */ - uint32_t flag; /* comp attributes */ - bool is_restart_en; /* flag to indicate if comp-restart is allowed */ - SaAmfCompCapabilityModelT cap; /* comp capability model */ - bool is_am_en; - bool is_hc_cmd_configured; + uint32_t flag {}; /* comp attributes */ + bool is_restart_en {}; /* flag to indicate if comp-restart is allowed */ + SaAmfCompCapabilityModelT cap {}; /* comp capability model */ + bool is_am_en {}; + bool is_hc_cmd_configured {}; /* clc info */ - AVND_COMP_CLC_INFO clc_info; + AVND_COMP_CLC_INFO clc_info {}; /* Update received flag, which will normally be false and will be * true if updates are received from the AVD on fail-over.*/ - bool avd_updt_flag; + bool avd_updt_flag {}; /* component registration info */ - SaAmfHandleT reg_hdl; /* registered handle value */ - MDS_DEST reg_dest;/* mds dest of the registering prc */ + SaAmfHandleT reg_hdl
Re: [devel] [PATCH 1/3] amfnd: Refactor AVND_COMP for simpler environment variable handling [#1945]
Hi Praveen, good catch, I'll update. /Thanks HansN On 06/13/2017 08:53 AM, praveen malviya wrote: Hi Hans, One comment on this patch inline with [Praveen]. Thanks, Praveen On 18-May-17 3:32 PM, Hans Nordeback wrote: --- src/amf/amfnd/avnd_comp.h | 134 ++ src/amf/amfnd/avnd_err.h | 4 +- src/amf/amfnd/avnd_hc.h | 2 +- src/amf/amfnd/avnd_proc.h | 10 ++-- src/amf/amfnd/avnd_util.h | 2 +- src/amf/amfnd/clc.cc | 125 -- src/amf/amfnd/comp.cc | 35 src/amf/amfnd/compdb.cc | 36 +++-- src/amf/amfnd/proxydb.cc | 2 +- 9 files changed, 138 insertions(+), 212 deletions(-) diff --git a/src/amf/amfnd/avnd_comp.h b/src/amf/amfnd/avnd_comp.h index 611e90e11..68de4cc8e 100644 --- a/src/amf/amfnd/avnd_comp.h +++ b/src/amf/amfnd/avnd_comp.h @@ -31,6 +31,8 @@ #define AMF_AMFND_AVND_COMP_H_ #include +#include +#include struct avnd_cb_tag; struct avnd_su_si_rec; @@ -57,7 +59,7 @@ struct avnd_srm_req_tag; /* clc event handler declaration */ typedef uint32_t (*AVND_COMP_CLC_FSM_FN)(struct avnd_cb_tag *, - struct avnd_comp_tag *); + AVND_COMP *); /* clc fsm events */ typedef enum avnd_comp_clc_pres_fsm_ev { @@ -141,7 +143,7 @@ typedef struct avnd_cbk_tag { AVSV_AMF_CBK_INFO *cbk_info; /* callbk info */ /* link to other elements */ - struct avnd_comp_tag *comp; /* bk ptr to the comp */ + AVND_COMP *comp; /* bk ptr to the comp */ struct avnd_cbk_tag *next; std::string comp_name; /* For checkpointing */ } AVND_COMP_CBK; @@ -182,7 +184,7 @@ typedef struct avnd_comp_csi_rec { wrt prv ha state */ /* links to other entities */ - struct avnd_comp_tag *comp; /* bk ptr to the comp */ + AVND_COMP *comp; /* bk ptr to the comp */ struct avnd_su_si_rec *si; /* bk ptr to the si record */ std::string comp_name; /* For Checkpointing */ std::string si_name;/* For Checkpointing */ @@ -256,7 +258,7 @@ typedef struct avnd_hc_rec_tag { uint32_t opq_hdl; /* hdl returned by hdl-mngr (used during tmr expiry) */ AVND_COMP_HC_STATUS status; /* indicates status of hc rec */ - struct avnd_comp_tag *comp; /* back ptr to the comp */ + AVND_COMP *comp; /* back ptr to the comp */ struct avnd_hc_rec_tag *next; std::string comp_name; /* For checkpoiting */ } AVND_COMP_HC_REC; @@ -278,7 +280,7 @@ typedef struct avnd_pm_rec { } rec_rcvr; /* links to other entities */ - struct avnd_comp_tag *comp; /* back ptr to the comp */ + AVND_COMP *comp; /* back ptr to the comp */ } AVND_COMP_PM_REC; /*## @@ -288,7 +290,7 @@ typedef struct avnd_pm_rec { /* proxied info */ typedef struct avnd_pxied_rec { NCS_DB_LINK_LIST_NODE comp_dll_node; /* node in the comp-pxied dll */ - struct avnd_comp_tag *pxied_comp;/* ptr to the proxied comp */ + AVND_COMP *pxied_comp;/* ptr to the proxied comp */ } AVND_COMP_PXIED_REC; #define AVND_COMP_TYPE_LOCAL_NODE 0x0001 @@ -319,100 +321,115 @@ enum UsedComptypeAttrs { NumAttrs }; -typedef struct avnd_comp_tag { - NCS_DB_LINK_LIST_NODE su_dll_node; /* su dll node (key is inst-level) */ +class AVND_COMP { + public: + // TODO(uabhano) replace the NCS_DB_LINK_LIST_NODE with C++ STL. Now su_dll_node must be first in AVND_COMP + // as the macro m_AVND_COMP_SU_DLL_NODE_OFFSET depends on the offset. offsetof is to be avoided in classes. + NCS_DB_LINK_LIST_NODE su_dll_node {}; /* su dll node (key is inst-level) */ + AVND_COMP() {} + ~AVND_COMP() {} std::string name; /* comp name */ std::string saAmfCompType; - uint32_t numOfCompCmdEnv; /* number of comp command environment variables */ - SaStringT *saAmfCompCmdEnv; /* comp command environment variables */ - uint32_t inst_level;/* comp instantiation level */ - uint32_t comp_hdl; /* hdl returned by hdl-mngr */ + uint32_t inst_level {};/* comp instantiation level */ + + uint32_t comp_hdl {}; /* hdl returned by hdl-mngr */ /* component attributes */ - uint32_t flag; /* comp attributes */ - bool is_restart_en; /* flag to indicate if comp-restart is allowed */ - SaAmfCompCapabilityModelT cap; /* comp capability model */ - bool is_am_en; - bool is_hc_cmd_configured; + uint32_t flag {}; /* comp attributes */ + bool is_restart_en {}; /* flag to indicate if comp-restart is allowed */ + SaAmfCompCapabilityModelT cap {}; /* comp capability model */ + bool is_am_en {}; + bool is_hc_cmd_configured {}; /* clc info */ - AVND_COMP_CLC_INFO clc_info; + AVND_COMP_CLC_INFO clc_info {}; /* Update received flag, which will normally be false and will be *
Re: [devel] [PATCH 1/3] amfnd: Refactor AVND_COMP for simpler environment variable handling [#1945]
Hi Hans, One comment on this patch inline with [Praveen]. Thanks, Praveen On 18-May-17 3:32 PM, Hans Nordeback wrote: --- src/amf/amfnd/avnd_comp.h | 134 ++ src/amf/amfnd/avnd_err.h | 4 +- src/amf/amfnd/avnd_hc.h | 2 +- src/amf/amfnd/avnd_proc.h | 10 ++-- src/amf/amfnd/avnd_util.h | 2 +- src/amf/amfnd/clc.cc | 125 -- src/amf/amfnd/comp.cc | 35 src/amf/amfnd/compdb.cc | 36 +++-- src/amf/amfnd/proxydb.cc | 2 +- 9 files changed, 138 insertions(+), 212 deletions(-) diff --git a/src/amf/amfnd/avnd_comp.h b/src/amf/amfnd/avnd_comp.h index 611e90e11..68de4cc8e 100644 --- a/src/amf/amfnd/avnd_comp.h +++ b/src/amf/amfnd/avnd_comp.h @@ -31,6 +31,8 @@ #define AMF_AMFND_AVND_COMP_H_ #include +#include +#include struct avnd_cb_tag; struct avnd_su_si_rec; @@ -57,7 +59,7 @@ struct avnd_srm_req_tag; /* clc event handler declaration */ typedef uint32_t (*AVND_COMP_CLC_FSM_FN)(struct avnd_cb_tag *, - struct avnd_comp_tag *); + AVND_COMP *); /* clc fsm events */ typedef enum avnd_comp_clc_pres_fsm_ev { @@ -141,7 +143,7 @@ typedef struct avnd_cbk_tag { AVSV_AMF_CBK_INFO *cbk_info; /* callbk info */ /* link to other elements */ - struct avnd_comp_tag *comp; /* bk ptr to the comp */ + AVND_COMP *comp; /* bk ptr to the comp */ struct avnd_cbk_tag *next; std::string comp_name; /* For checkpointing */ } AVND_COMP_CBK; @@ -182,7 +184,7 @@ typedef struct avnd_comp_csi_rec { wrt prv ha state */ /* links to other entities */ - struct avnd_comp_tag *comp; /* bk ptr to the comp */ + AVND_COMP *comp; /* bk ptr to the comp */ struct avnd_su_si_rec *si; /* bk ptr to the si record */ std::string comp_name; /* For Checkpointing */ std::string si_name;/* For Checkpointing */ @@ -256,7 +258,7 @@ typedef struct avnd_hc_rec_tag { uint32_t opq_hdl; /* hdl returned by hdl-mngr (used during tmr expiry) */ AVND_COMP_HC_STATUS status; /* indicates status of hc rec */ - struct avnd_comp_tag *comp; /* back ptr to the comp */ + AVND_COMP *comp; /* back ptr to the comp */ struct avnd_hc_rec_tag *next; std::string comp_name; /* For checkpoiting */ } AVND_COMP_HC_REC; @@ -278,7 +280,7 @@ typedef struct avnd_pm_rec { } rec_rcvr; /* links to other entities */ - struct avnd_comp_tag *comp; /* back ptr to the comp */ + AVND_COMP *comp; /* back ptr to the comp */ } AVND_COMP_PM_REC; /*## @@ -288,7 +290,7 @@ typedef struct avnd_pm_rec { /* proxied info */ typedef struct avnd_pxied_rec { NCS_DB_LINK_LIST_NODE comp_dll_node; /* node in the comp-pxied dll */ - struct avnd_comp_tag *pxied_comp;/* ptr to the proxied comp */ + AVND_COMP *pxied_comp;/* ptr to the proxied comp */ } AVND_COMP_PXIED_REC; #define AVND_COMP_TYPE_LOCAL_NODE 0x0001 @@ -319,100 +321,115 @@ enum UsedComptypeAttrs { NumAttrs }; -typedef struct avnd_comp_tag { - NCS_DB_LINK_LIST_NODE su_dll_node; /* su dll node (key is inst-level) */ +class AVND_COMP { + public: + // TODO(uabhano) replace the NCS_DB_LINK_LIST_NODE with C++ STL. Now su_dll_node must be first in AVND_COMP + // as the macro m_AVND_COMP_SU_DLL_NODE_OFFSET depends on the offset. offsetof is to be avoided in classes. + NCS_DB_LINK_LIST_NODE su_dll_node {}; /* su dll node (key is inst-level) */ + AVND_COMP() {} + ~AVND_COMP() {} std::string name; /* comp name */ std::string saAmfCompType; - uint32_t numOfCompCmdEnv; /* number of comp command environment variables */ - SaStringT *saAmfCompCmdEnv; /* comp command environment variables */ - uint32_t inst_level;/* comp instantiation level */ - uint32_t comp_hdl; /* hdl returned by hdl-mngr */ + uint32_t inst_level {};/* comp instantiation level */ + + uint32_t comp_hdl {}; /* hdl returned by hdl-mngr */ /* component attributes */ - uint32_t flag; /* comp attributes */ - bool is_restart_en; /* flag to indicate if comp-restart is allowed */ - SaAmfCompCapabilityModelT cap; /* comp capability model */ - bool is_am_en; - bool is_hc_cmd_configured; + uint32_t flag {}; /* comp attributes */ + bool is_restart_en {}; /* flag to indicate if comp-restart is allowed */ + SaAmfCompCapabilityModelT cap {}; /* comp capability model */ + bool is_am_en {}; + bool is_hc_cmd_configured {}; /* clc info */ - AVND_COMP_CLC_INFO clc_info; + AVND_COMP_CLC_INFO clc_info {}; /* Update received flag, which will normally be false and will be * true if updates are received from the AVD on fail-over.*/ - bool avd_updt_flag; +
[devel] [PATCH 1/3] amfnd: Refactor AVND_COMP for simpler environment variable handling [#1945]
--- src/amf/amfnd/avnd_comp.h | 134 ++ src/amf/amfnd/avnd_err.h | 4 +- src/amf/amfnd/avnd_hc.h | 2 +- src/amf/amfnd/avnd_proc.h | 10 ++-- src/amf/amfnd/avnd_util.h | 2 +- src/amf/amfnd/clc.cc | 125 -- src/amf/amfnd/comp.cc | 35 src/amf/amfnd/compdb.cc | 36 +++-- src/amf/amfnd/proxydb.cc | 2 +- 9 files changed, 138 insertions(+), 212 deletions(-) diff --git a/src/amf/amfnd/avnd_comp.h b/src/amf/amfnd/avnd_comp.h index 611e90e11..68de4cc8e 100644 --- a/src/amf/amfnd/avnd_comp.h +++ b/src/amf/amfnd/avnd_comp.h @@ -31,6 +31,8 @@ #define AMF_AMFND_AVND_COMP_H_ #include +#include +#include struct avnd_cb_tag; struct avnd_su_si_rec; @@ -57,7 +59,7 @@ struct avnd_srm_req_tag; /* clc event handler declaration */ typedef uint32_t (*AVND_COMP_CLC_FSM_FN)(struct avnd_cb_tag *, - struct avnd_comp_tag *); + AVND_COMP *); /* clc fsm events */ typedef enum avnd_comp_clc_pres_fsm_ev { @@ -141,7 +143,7 @@ typedef struct avnd_cbk_tag { AVSV_AMF_CBK_INFO *cbk_info; /* callbk info */ /* link to other elements */ - struct avnd_comp_tag *comp; /* bk ptr to the comp */ + AVND_COMP *comp; /* bk ptr to the comp */ struct avnd_cbk_tag *next; std::string comp_name; /* For checkpointing */ } AVND_COMP_CBK; @@ -182,7 +184,7 @@ typedef struct avnd_comp_csi_rec { wrt prv ha state */ /* links to other entities */ - struct avnd_comp_tag *comp; /* bk ptr to the comp */ + AVND_COMP *comp; /* bk ptr to the comp */ struct avnd_su_si_rec *si; /* bk ptr to the si record */ std::string comp_name; /* For Checkpointing */ std::string si_name;/* For Checkpointing */ @@ -256,7 +258,7 @@ typedef struct avnd_hc_rec_tag { uint32_t opq_hdl; /* hdl returned by hdl-mngr (used during tmr expiry) */ AVND_COMP_HC_STATUS status; /* indicates status of hc rec */ - struct avnd_comp_tag *comp; /* back ptr to the comp */ + AVND_COMP *comp; /* back ptr to the comp */ struct avnd_hc_rec_tag *next; std::string comp_name; /* For checkpoiting */ } AVND_COMP_HC_REC; @@ -278,7 +280,7 @@ typedef struct avnd_pm_rec { } rec_rcvr; /* links to other entities */ - struct avnd_comp_tag *comp; /* back ptr to the comp */ + AVND_COMP *comp; /* back ptr to the comp */ } AVND_COMP_PM_REC; /*## @@ -288,7 +290,7 @@ typedef struct avnd_pm_rec { /* proxied info */ typedef struct avnd_pxied_rec { NCS_DB_LINK_LIST_NODE comp_dll_node; /* node in the comp-pxied dll */ - struct avnd_comp_tag *pxied_comp;/* ptr to the proxied comp */ + AVND_COMP *pxied_comp;/* ptr to the proxied comp */ } AVND_COMP_PXIED_REC; #define AVND_COMP_TYPE_LOCAL_NODE 0x0001 @@ -319,100 +321,115 @@ enum UsedComptypeAttrs { NumAttrs }; -typedef struct avnd_comp_tag { - NCS_DB_LINK_LIST_NODE su_dll_node; /* su dll node (key is inst-level) */ +class AVND_COMP { + public: + // TODO(uabhano) replace the NCS_DB_LINK_LIST_NODE with C++ STL. Now su_dll_node must be first in AVND_COMP + // as the macro m_AVND_COMP_SU_DLL_NODE_OFFSET depends on the offset. offsetof is to be avoided in classes. + NCS_DB_LINK_LIST_NODE su_dll_node {}; /* su dll node (key is inst-level) */ + AVND_COMP() {} + ~AVND_COMP() {} std::string name; /* comp name */ std::string saAmfCompType; - uint32_t numOfCompCmdEnv; /* number of comp command environment variables */ - SaStringT *saAmfCompCmdEnv; /* comp command environment variables */ - uint32_t inst_level;/* comp instantiation level */ - uint32_t comp_hdl; /* hdl returned by hdl-mngr */ + uint32_t inst_level {};/* comp instantiation level */ + + uint32_t comp_hdl {}; /* hdl returned by hdl-mngr */ /* component attributes */ - uint32_t flag; /* comp attributes */ - bool is_restart_en; /* flag to indicate if comp-restart is allowed */ - SaAmfCompCapabilityModelT cap; /* comp capability model */ - bool is_am_en; - bool is_hc_cmd_configured; + uint32_t flag {}; /* comp attributes */ + bool is_restart_en {}; /* flag to indicate if comp-restart is allowed */ + SaAmfCompCapabilityModelT cap {}; /* comp capability model */ + bool is_am_en {}; + bool is_hc_cmd_configured {}; /* clc info */ - AVND_COMP_CLC_INFO clc_info; + AVND_COMP_CLC_INFO clc_info {}; /* Update received flag, which will normally be false and will be * true if updates are received from the AVD on fail-over.*/ - bool avd_updt_flag; + bool avd_updt_flag {}; /* component registration info */ - SaAmfHandleT reg_hdl; /* registered handle value */ - MDS_DEST reg_dest;/* mds dest of the registering prc */ + SaAmfHandleT reg_hdl
[devel] [PATCH 1/3] amfnd: Refactor AVND_COMP for simpler environment variable handling [#1945]
--- src/amf/amfnd/avnd_comp.h | 134 ++ src/amf/amfnd/avnd_err.h | 4 +- src/amf/amfnd/avnd_hc.h | 2 +- src/amf/amfnd/avnd_proc.h | 10 ++-- src/amf/amfnd/avnd_util.h | 2 +- src/amf/amfnd/clc.cc | 125 -- src/amf/amfnd/comp.cc | 35 src/amf/amfnd/compdb.cc | 36 +++-- src/amf/amfnd/proxydb.cc | 2 +- 9 files changed, 138 insertions(+), 212 deletions(-) diff --git a/src/amf/amfnd/avnd_comp.h b/src/amf/amfnd/avnd_comp.h index 611e90e11..68de4cc8e 100644 --- a/src/amf/amfnd/avnd_comp.h +++ b/src/amf/amfnd/avnd_comp.h @@ -31,6 +31,8 @@ #define AMF_AMFND_AVND_COMP_H_ #include +#include +#include struct avnd_cb_tag; struct avnd_su_si_rec; @@ -57,7 +59,7 @@ struct avnd_srm_req_tag; /* clc event handler declaration */ typedef uint32_t (*AVND_COMP_CLC_FSM_FN)(struct avnd_cb_tag *, - struct avnd_comp_tag *); + AVND_COMP *); /* clc fsm events */ typedef enum avnd_comp_clc_pres_fsm_ev { @@ -141,7 +143,7 @@ typedef struct avnd_cbk_tag { AVSV_AMF_CBK_INFO *cbk_info; /* callbk info */ /* link to other elements */ - struct avnd_comp_tag *comp; /* bk ptr to the comp */ + AVND_COMP *comp; /* bk ptr to the comp */ struct avnd_cbk_tag *next; std::string comp_name; /* For checkpointing */ } AVND_COMP_CBK; @@ -182,7 +184,7 @@ typedef struct avnd_comp_csi_rec { wrt prv ha state */ /* links to other entities */ - struct avnd_comp_tag *comp; /* bk ptr to the comp */ + AVND_COMP *comp; /* bk ptr to the comp */ struct avnd_su_si_rec *si; /* bk ptr to the si record */ std::string comp_name; /* For Checkpointing */ std::string si_name;/* For Checkpointing */ @@ -256,7 +258,7 @@ typedef struct avnd_hc_rec_tag { uint32_t opq_hdl; /* hdl returned by hdl-mngr (used during tmr expiry) */ AVND_COMP_HC_STATUS status; /* indicates status of hc rec */ - struct avnd_comp_tag *comp; /* back ptr to the comp */ + AVND_COMP *comp; /* back ptr to the comp */ struct avnd_hc_rec_tag *next; std::string comp_name; /* For checkpoiting */ } AVND_COMP_HC_REC; @@ -278,7 +280,7 @@ typedef struct avnd_pm_rec { } rec_rcvr; /* links to other entities */ - struct avnd_comp_tag *comp; /* back ptr to the comp */ + AVND_COMP *comp; /* back ptr to the comp */ } AVND_COMP_PM_REC; /*## @@ -288,7 +290,7 @@ typedef struct avnd_pm_rec { /* proxied info */ typedef struct avnd_pxied_rec { NCS_DB_LINK_LIST_NODE comp_dll_node; /* node in the comp-pxied dll */ - struct avnd_comp_tag *pxied_comp;/* ptr to the proxied comp */ + AVND_COMP *pxied_comp;/* ptr to the proxied comp */ } AVND_COMP_PXIED_REC; #define AVND_COMP_TYPE_LOCAL_NODE 0x0001 @@ -319,100 +321,115 @@ enum UsedComptypeAttrs { NumAttrs }; -typedef struct avnd_comp_tag { - NCS_DB_LINK_LIST_NODE su_dll_node; /* su dll node (key is inst-level) */ +class AVND_COMP { + public: + // TODO(uabhano) replace the NCS_DB_LINK_LIST_NODE with C++ STL. Now su_dll_node must be first in AVND_COMP + // as the macro m_AVND_COMP_SU_DLL_NODE_OFFSET depends on the offset. offsetof is to be avoided in classes. + NCS_DB_LINK_LIST_NODE su_dll_node {}; /* su dll node (key is inst-level) */ + AVND_COMP() {} + ~AVND_COMP() {} std::string name; /* comp name */ std::string saAmfCompType; - uint32_t numOfCompCmdEnv; /* number of comp command environment variables */ - SaStringT *saAmfCompCmdEnv; /* comp command environment variables */ - uint32_t inst_level;/* comp instantiation level */ - uint32_t comp_hdl; /* hdl returned by hdl-mngr */ + uint32_t inst_level {};/* comp instantiation level */ + + uint32_t comp_hdl {}; /* hdl returned by hdl-mngr */ /* component attributes */ - uint32_t flag; /* comp attributes */ - bool is_restart_en; /* flag to indicate if comp-restart is allowed */ - SaAmfCompCapabilityModelT cap; /* comp capability model */ - bool is_am_en; - bool is_hc_cmd_configured; + uint32_t flag {}; /* comp attributes */ + bool is_restart_en {}; /* flag to indicate if comp-restart is allowed */ + SaAmfCompCapabilityModelT cap {}; /* comp capability model */ + bool is_am_en {}; + bool is_hc_cmd_configured {}; /* clc info */ - AVND_COMP_CLC_INFO clc_info; + AVND_COMP_CLC_INFO clc_info {}; /* Update received flag, which will normally be false and will be * true if updates are received from the AVD on fail-over.*/ - bool avd_updt_flag; + bool avd_updt_flag {}; /* component registration info */ - SaAmfHandleT reg_hdl; /* registered handle value */ - MDS_DEST reg_dest;/* mds dest of the registering prc */ + SaAmfHandleT reg_hdl