summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_aspath.c7
-rw-r--r--bgpd/bgp_attr.c17
-rw-r--r--tests/bgpd/test_aspath.c12
3 files changed, 17 insertions, 19 deletions
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index 192cd6ca8..dd27c9f6a 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -328,7 +328,12 @@ void aspath_free(struct aspath *aspath)
void aspath_unintern(struct aspath **aspath)
{
struct aspath *ret;
- struct aspath *asp = *aspath;
+ struct aspath *asp;
+
+ if (!*aspath)
+ return;
+
+ asp = *aspath;
if (asp->refcnt)
asp->refcnt--;
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 4f25f2284..21f92c353 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -1086,8 +1086,7 @@ void bgp_attr_unintern_sub(struct attr *attr)
struct lcommunity *lcomm = NULL;
/* aspath refcount shoud be decrement. */
- if (attr->aspath)
- aspath_unintern(&attr->aspath);
+ aspath_unintern(&attr->aspath);
UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AS_PATH));
if (attr->community)
@@ -3494,14 +3493,12 @@ done:
* we can chuck as4_aggregator and as4_path alltogether in order
* to save memory
*/
- if (as4_path) {
- /*
- * unintern - it is in the hash
- * The flag that we got this is still there, but that
- * does not do any trouble
- */
- aspath_unintern(&as4_path);
- }
+ /*
+ * unintern - it is in the hash
+ * The flag that we got this is still there, but that
+ * does not do any trouble
+ */
+ aspath_unintern(&as4_path);
transit = bgp_attr_get_transit(attr);
if (ret != BGP_ATTR_PARSE_ERROR) {
diff --git a/tests/bgpd/test_aspath.c b/tests/bgpd/test_aspath.c
index c2d39752a..7288dc086 100644
--- a/tests/bgpd/test_aspath.c
+++ b/tests/bgpd/test_aspath.c
@@ -1062,8 +1062,7 @@ static void parse_test(struct test_segment *t)
printf("\n");
- if (asp)
- aspath_unintern(&asp);
+ aspath_unintern(&asp);
}
/* prepend testing */
@@ -1117,8 +1116,7 @@ static void empty_prepend_test(struct test_segment *t)
printf(FAILED "!\n");
printf("\n");
- if (asp1)
- aspath_unintern(&asp1);
+ aspath_unintern(&asp1);
aspath_free(asp2);
}
@@ -1277,10 +1275,8 @@ static int handle_attr_test(struct aspath_tests *t)
}
out:
- if (attr.aspath)
- aspath_unintern(&attr.aspath);
- if (asp)
- aspath_unintern(&asp);
+ aspath_unintern(&attr.aspath);
+ aspath_unintern(&asp);
return failed - initfail;
}