diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2020-06-05 09:02:44 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2020-06-05 09:04:55 -0400 |
| commit | 3e0a9b403254de62eaaf45c032295026f63a9fd6 (patch) | |
| tree | be1b521f6db14413807f7ce8c560a88b0fe7a8b8 /zebra/zebra_mpls.c | |
| parent | ce49c4255dc54ac5c8e9df7312be89797319da5a (diff) | |
zebra: nhlfe_alloc should not fail
Let's prevent nhlfe_alloc from actually returning anything that can fail:
1) nexthop_new -> never returns NULL so checking for NULL here
makes no sense, remove it.
2) lsp not being NULL is a assert condition here as that it's
a precondition for the function to work properly.
3) since nhlfe_alloc cannot return NULL now remove tests
for it in callng functions
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'zebra/zebra_mpls.c')
| -rw-r--r-- | zebra/zebra_mpls.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 1210430b06..25dd31a3b6 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -1258,8 +1258,7 @@ static zebra_nhlfe_t *nhlfe_alloc(zebra_lsp_t *lsp, enum lsp_types_t lsp_type, zebra_nhlfe_t *nhlfe; struct nexthop *nexthop; - if (!lsp) - return NULL; + assert(lsp); nhlfe = XCALLOC(MTYPE_NHLFE, sizeof(zebra_nhlfe_t)); @@ -1268,10 +1267,6 @@ static zebra_nhlfe_t *nhlfe_alloc(zebra_lsp_t *lsp, enum lsp_types_t lsp_type, nhlfe->distance = lsp_distance(lsp_type); nexthop = nexthop_new(); - if (!nexthop) { - XFREE(MTYPE_NHLFE, nhlfe); - return NULL; - } nexthop_add_labels(nexthop, lsp_type, num_labels, labels); @@ -1322,8 +1317,7 @@ static zebra_nhlfe_t *nhlfe_add(zebra_lsp_t *lsp, enum lsp_types_t lsp_type, labels); /* Enqueue to LSP, at head of list. */ - if (nhlfe) - nhlfe_list_add_head(&lsp->nhlfe_list, nhlfe); + nhlfe_list_add_head(&lsp->nhlfe_list, nhlfe); return nhlfe; } @@ -1351,8 +1345,7 @@ static zebra_nhlfe_t *nhlfe_backup_add(zebra_lsp_t *lsp, SET_FLAG(nhlfe->flags, NHLFE_FLAG_IS_BACKUP); /* Enqueue to LSP, at tail of list. */ - if (nhlfe) - nhlfe_list_add_tail(&lsp->backup_nhlfe_list, nhlfe); + nhlfe_list_add_tail(&lsp->backup_nhlfe_list, nhlfe); return nhlfe; } |
