diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-12-11 08:48:59 -0500 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-12-11 12:39:16 -0500 |
| commit | 02d3243970db013f51a95f93de986f338329f2ac (patch) | |
| tree | b7ff14870f5591d5938d215a9fe463087f97a70f | |
| parent | ff6566f3efaad50d09f0327953b57f75dc607de0 (diff) | |
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>
| -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 2b676e052b..ae1ec7b845 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; } |
