summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsri-mohan1 <sri.mohan@samsung.com>2024-09-09 09:46:16 +0530
committersri-mohan1 <sri.mohan@samsung.com>2024-09-10 10:37:04 +0530
commitbbfbf3e6b98076de9cbd5fd91b5d50738ac1d549 (patch)
tree0e9bfe474101ba57c86f8d1639f8cfc612577654
parentfbd743197a9c06bfa90d0fb6afa53df74abc2092 (diff)
bgpd: changes for code maintainability
these changes are for improving the code maintainability and readability Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
-rw-r--r--bgpd/bgp_clist.c4
-rw-r--r--bgpd/bgp_community.c7
-rw-r--r--bgpd/bgp_debug.c4
3 files changed, 7 insertions, 8 deletions
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c
index 153cbd6e50..ad154e638b 100644
--- a/bgpd/bgp_clist.c
+++ b/bgpd/bgp_clist.c
@@ -496,8 +496,8 @@ static char *community_str_get(struct community *com, int i)
break;
default:
str = XSTRDUP(MTYPE_COMMUNITY_STR, "65536:65535");
- as = (comval >> 16) & 0xFFFF;
- val = comval & 0xFFFF;
+ as = CHECK_FLAG((comval >> 16), 0xFFFF);
+ val = CHECK_FLAG(comval, 0xFFFF);
snprintf(str, strlen(str), "%u:%d", as, val);
break;
}
diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c
index 8e4c430555..602c1437af 100644
--- a/bgpd/bgp_community.c
+++ b/bgpd/bgp_community.c
@@ -416,13 +416,12 @@ static void set_community_string(struct community *com, bool make_json,
}
break;
default:
- as = (comval >> 16) & 0xFFFF;
- val = comval & 0xFFFF;
+ as = CHECK_FLAG((comval >> 16), 0xFFFF);
+ val = CHECK_FLAG(comval, 0xFFFF);
char buf[32];
snprintf(buf, sizeof(buf), "%u:%d", as, val);
const char *com2alias =
- translate_alias ? bgp_community2alias(buf)
- : buf;
+ translate_alias ? bgp_community2alias(buf) : buf;
strlcat(str, com2alias, len);
if (make_json) {
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index 6228432bd2..97c3e5740f 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -2558,7 +2558,7 @@ static int bgp_debug_per_prefix(const struct prefix *p,
struct bgp_debug_filter *filter;
struct listnode *node, *nnode;
- if (term_bgp_debug_type & BGP_DEBUG_TYPE) {
+ if (CHECK_FLAG(term_bgp_debug_type, BGP_DEBUG_TYPE)) {
/* We are debugging all prefixes so return true */
if (!per_prefix_list || list_isempty(per_prefix_list))
return 1;
@@ -2591,7 +2591,7 @@ static bool bgp_debug_per_peer(char *host, const struct prefix *p,
struct bgp_debug_filter *filter;
struct listnode *node, *nnode;
- if (term_bgp_debug_type & BGP_DEBUG_TYPE) {
+ if (CHECK_FLAG(term_bgp_debug_type, BGP_DEBUG_TYPE)) {
/* We are debugging all peers so return true */
if (!per_peer_list || list_isempty(per_peer_list))
return true;