diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-12-11 14:48:59 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-12-11 18:39:16 +0100 |
commit | 02d3243970db013f51a95f93de986f338329f2ac (patch) | |
tree | b7ff14870f5591d5938d215a9fe463087f97a70f /bgpd/bgp_rd.c | |
parent | bgpd: Cleanup SA error in ignoring return from function (diff) | |
download | frr-02d3243970db013f51a95f93de986f338329f2ac.tar.xz frr-02d3243970db013f51a95f93de986f338329f2ac.zip |
bgpd: Modify prefix_rd2str to return "Unknown" when unknown
Make prefix_rd2str return an "Unknown" string when something
goes wrong. This will allow for simplification of the
code that uses prefix_rd2str.
Additionally ensure that size is big enough with an assert.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'bgpd/bgp_rd.c')
-rw-r--r-- | bgpd/bgp_rd.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bgpd/bgp_rd.c b/bgpd/bgp_rd.c index 2b676e052..ae1ec7b84 100644 --- a/bgpd/bgp_rd.c +++ b/bgpd/bgp_rd.c @@ -166,8 +166,7 @@ char *prefix_rd2str(struct prefix_rd *prd, char *buf, size_t size) struct rd_as rd_as; struct rd_ip rd_ip; - if (size < RD_ADDRSTRLEN) - return NULL; + assert(size >= RD_ADDRSTRLEN); pnt = prd->val; @@ -197,5 +196,7 @@ char *prefix_rd2str(struct prefix_rd *prd, char *buf, size_t size) return buf; } #endif - return NULL; + + snprintf(buf, size, "Unknown Type: %d", type); + return buf; } |