Hi Anders, Let me submit the set of patches what I published in this cycle. Still there is a scope of stream lining the legacy BASE code, will take it up in the next iteration.
Thanks, Ramesh. On 12/10/2013 2:25 PM, Anders Widell wrote: > The macro definitions of m_KEY_CMP and m_GET_BIT are wrong: macro > parameters must always be surrounded with parentheses in the macro > expression: > > #define m_KEY_CMP(t, k1, k2) memcmp(k1, k2, (size_t)(t)->params.key_size) > #define m_GET_BIT(key, bit) ((bit < 0) ? 0 : ((int)((*((key) + (bit >> > 3))) >> (7 - (bit & 0x07))) & 0x01)) > > should be: > > #define m_KEY_CMP(t, k1, k2) memcmp((k1), (k2), > (size_t)(t)->params.key_size) > #define m_GET_BIT(key, bit) (((bit) < 0) ? 0 : ((int)((*((key) + > ((bit) >> 3))) >> (7 - ((bit) & 0x07))) & 0x01)) > > On the other hand, why not convert them to inline functions instead? > Also, they are only used in patricia.c, so I suggest removing > m_KEY_CMP and m_GET_BIT from ncspatricia.h and instead adding the > following inline functions in patricia.c (they should also be given > better names, but I haven't done that here): > > #include <stdint.h> > #include <string.h> > > static inline int m_KEY_CMP(const NCS_PATRICIA_TREE* t, const uint8_t* > k1, const uint8_t* k2) > { > return memcmp(k1, k2, t->params.key_size); > } > > static inline int m_GET_BIT(const uint8_t* key, int bit) > { > return (bit < 0) ? 0 : ((int) ((*(key + (bit >> 3))) >> (7 - (bit > & 0x07))) & 0x01); > } > > regards, > Anders Widell > > 2013-12-05 13:51, ramesh.bet...@oracle.com skrev: >> osaf/libs/core/common/saf_edu.c | 2 +- >> osaf/libs/core/include/ncspatricia.h | 3 +++ >> osaf/libs/core/leap/hj_edp.c | 2 +- >> osaf/libs/core/leap/hj_edu.c | 2 +- >> osaf/libs/core/leap/include/Makefile.am | 1 - >> osaf/libs/core/leap/include/patricia.h | 39 >> --------------------------------------- >> osaf/libs/core/leap/patricia.c | 2 +- >> osaf/libs/core/mds/mds_main.c | 2 +- >> 8 files changed, 8 insertions(+), 45 deletions(-) >> >> >> diff --git a/osaf/libs/core/common/saf_edu.c >> b/osaf/libs/core/common/saf_edu.c >> --- a/osaf/libs/core/common/saf_edu.c >> +++ b/osaf/libs/core/common/saf_edu.c >> @@ -30,7 +30,7 @@ >> #include <ncsgl_defs.h> >> -#include "patricia.h" >> +#include "ncspatricia.h" >> #include "ncsencdec_pub.h" >> #include "saAis.h" >> diff --git a/osaf/libs/core/include/ncspatricia.h >> b/osaf/libs/core/include/ncspatricia.h >> --- a/osaf/libs/core/include/ncspatricia.h >> +++ b/osaf/libs/core/include/ncspatricia.h >> @@ -47,6 +47,9 @@ extern "C" { >> #include "ncsgl_defs.h" >> +#define m_KEY_CMP(t, k1, k2) memcmp(k1, k2, >> (size_t)(t)->params.key_size) >> +#define m_GET_BIT(key, bit) ((bit < 0) ? 0 : ((int)((*((key) + (bit >> >> 3))) >> (7 - (bit & 0x07))) & 0x01)) >> + >> typedef struct ncs_patricia_params { >> int key_size; /* 1..NCS_PATRICIA_MAX_KEY_SIZE - in >> OCTETS */ >> int info_size; /* NOT USED! Present for >> backward-compatibility only! */ >> diff --git a/osaf/libs/core/leap/hj_edp.c b/osaf/libs/core/leap/hj_edp.c >> --- a/osaf/libs/core/leap/hj_edp.c >> +++ b/osaf/libs/core/leap/hj_edp.c >> @@ -28,7 +28,7 @@ >> #include <ncsgl_defs.h> >> #include "ncs_osprm.h" >> -#include "patricia.h" >> +#include "ncspatricia.h" >> #include "ncssysf_mem.h" >> #include "ncsencdec_pub.h" >> #include "ncs_edu.h" >> diff --git a/osaf/libs/core/leap/hj_edu.c b/osaf/libs/core/leap/hj_edu.c >> --- a/osaf/libs/core/leap/hj_edu.c >> +++ b/osaf/libs/core/leap/hj_edu.c >> @@ -31,7 +31,7 @@ >> #include "ncssysf_def.h" >> #include "ncssysf_mem.h" >> #include "sysf_def.h" >> -#include "patricia.h" >> +#include "ncspatricia.h" >> #include "ncssysfpool.h" >> #include "ncsencdec_pub.h" >> #include "ncs_edu.h" >> diff --git a/osaf/libs/core/leap/include/Makefile.am >> b/osaf/libs/core/leap/include/Makefile.am >> --- a/osaf/libs/core/leap/include/Makefile.am >> +++ b/osaf/libs/core/leap/include/Makefile.am >> @@ -22,7 +22,6 @@ noinst_HEADERS = \ >> ncsdlib.h \ >> ncs_edu.h \ >> ncs_hdl.h \ >> - patricia.h \ >> sysf_def.h \ >> sysf_exc_scr.h \ >> sysf_ipc.h \ >> diff --git a/osaf/libs/core/leap/include/patricia.h >> b/osaf/libs/core/leap/include/patricia.h >> deleted file mode 100644 >> --- a/osaf/libs/core/leap/include/patricia.h >> +++ /dev/null >> @@ -1,39 +0,0 @@ >> -/* -*- OpenSAF -*- >> - * >> - * (C) Copyright 2008 The OpenSAF Foundation >> - * >> - * This program is distributed in the hope that it will be useful, but >> - * WITHOUT ANY WARRANTY; without even the implied warranty of >> MERCHANTABILITY >> - * or FITNESS FOR A PARTICULAR PURPOSE. This file and program are >> licensed >> - * under the GNU Lesser General Public License Version 2.1, February >> 1999. >> - * The complete license can be accessed from the following location: >> - * http://opensource.org/licenses/lgpl-license.php >> - * See the Copying file included with the OpenSAF distribution for full >> - * licensing terms. >> - * >> - * Author(s): Emerson Network Power >> - * >> - */ >> - >> -/***************************************************************************** >> >> >> - >> - DESCRIPTION: >> - >> - This module contains declarations pertaining to implementation of >> - patricia tree search/add/delete functions. >> - >> -****************************************************************************** >> >> >> -*/ >> - >> -/* >> - * Module Inclusion Control... >> - */ >> -#ifndef _PATRICIA_H_ >> -#define _PATRICIA_H_ >> - >> -#include "ncspatricia.h" >> - >> -#define m_KEY_CMP(t, k1, k2) memcmp(k1, k2, >> (size_t)(t)->params.key_size) >> -#define m_GET_BIT(key, bit) ((bit < 0) ? 0 : ((int)((*((key) + (bit >> >> 3))) >> (7 - (bit & 0x07))) & 0x01)) >> - >> -#endif >> diff --git a/osaf/libs/core/leap/patricia.c >> b/osaf/libs/core/leap/patricia.c >> --- a/osaf/libs/core/leap/patricia.c >> +++ b/osaf/libs/core/leap/patricia.c >> @@ -43,7 +43,7 @@ >> #include "ncs_osprm.h" >> #include "ncssysfpool.h" >> #include "ncssysf_def.h" >> -#include "patricia.h" >> +#include "ncspatricia.h" >> const static uint8_t BitMasks[9] = { >> 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff >> diff --git a/osaf/libs/core/mds/mds_main.c >> b/osaf/libs/core/mds/mds_main.c >> --- a/osaf/libs/core/mds/mds_main.c >> +++ b/osaf/libs/core/mds/mds_main.c >> @@ -35,7 +35,7 @@ >> #include "ncssysf_tmr.h" >> #include "mds_dl_api.h" >> #include "mds_core.h" >> -#include "patricia.h" >> +#include "ncspatricia.h" >> #include "mds_log.h" >> #include "ncs_main_pub.h" >> #include "mds_dt_tcp.h" >> >> ------------------------------------------------------------------------------ >> >> >> Sponsored by Intel(R) XDK >> Develop, test and display web and hybrid apps with a single code base. >> Download it for free now! >> http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk >> >> _______________________________________________ >> Opensaf-devel mailing list >> Opensaf-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/opensaf-devel >> >> > ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel