From e702605d80c26e94681b282d97c726df6c6871da Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Tue, 29 Jun 2021 15:18:22 +0300 Subject: [PATCH] *: Do not check for XMALLOC/XCALLOC against NULLs We don't check this pattern anywhere in the code basically, so let's unify the code. Signed-off-by: Donatas Abraitis --- bfdd/dplane.c | 2 -- bgpd/bgpd.c | 2 -- lib/link_state.c | 12 ------------ 3 files changed, 16 deletions(-) diff --git a/bfdd/dplane.c b/bfdd/dplane.c index 6fb301d46a..4b7f9ba7ac 100644 --- a/bfdd/dplane.c +++ b/bfdd/dplane.c @@ -651,8 +651,6 @@ static struct bfd_dplane_ctx *bfd_dplane_ctx_new(int sock) struct bfd_dplane_ctx *bdc; bdc = XCALLOC(MTYPE_BFDD_DPLANE_CTX, sizeof(*bdc)); - if (bdc == NULL) - return NULL; bdc->sock = sock; bdc->inbuf = stream_new(BFD_DPLANE_CLIENT_BUF_SIZE); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index b5eebe8259..cf38f377b4 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -3104,8 +3104,6 @@ static struct bgp *bgp_create(as_t *as, const char *name, safi_t safi; bgp = XCALLOC(MTYPE_BGP, sizeof(struct bgp)); - if (bgp == NULL) - return NULL; if (BGP_DEBUG(zebra, ZEBRA)) { if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) diff --git a/lib/link_state.c b/lib/link_state.c index e8a6b89f89..062384aac7 100644 --- a/lib/link_state.c +++ b/lib/link_state.c @@ -538,8 +538,6 @@ struct ls_edge *ls_edge_add(struct ls_ted *ted, /* Create Edge and add it to the TED */ new = XCALLOC(MTYPE_LS_DB, sizeof(struct ls_edge)); - if (!new) - return NULL; new->attributes = attributes; new->key = key; @@ -804,8 +802,6 @@ struct ls_ted *ls_ted_new(const uint32_t key, const char *name, struct ls_ted *new; new = XCALLOC(MTYPE_LS_DB, sizeof(struct ls_ted)); - if (new == NULL) - return new; /* Set basic information for this ted */ new->key = key; @@ -1005,8 +1001,6 @@ static struct ls_node *ls_parse_node(struct stream *s) size_t len; node = XCALLOC(MTYPE_LS_DB, sizeof(struct ls_node)); - if (node == NULL) - return NULL; STREAM_GET(&node->adv, s, sizeof(struct ls_node_id)); STREAM_GETW(s, node->flags); @@ -1051,8 +1045,6 @@ static struct ls_attributes *ls_parse_attributes(struct stream *s) size_t len; attr = XCALLOC(MTYPE_LS_DB, sizeof(struct ls_attributes)); - if (attr == NULL) - return NULL; attr->srlgs = NULL; STREAM_GET(&attr->adv, s, sizeof(struct ls_node_id)); @@ -1157,8 +1149,6 @@ static struct ls_prefix *ls_parse_prefix(struct stream *s) size_t len; ls_pref = XCALLOC(MTYPE_LS_DB, sizeof(struct ls_prefix)); - if (ls_pref == NULL) - return NULL; STREAM_GET(&ls_pref->adv, s, sizeof(struct ls_node_id)); STREAM_GETW(s, ls_pref->flags); @@ -1193,8 +1183,6 @@ struct ls_message *ls_parse_msg(struct stream *s) struct ls_message *msg; msg = XCALLOC(MTYPE_LS_DB, sizeof(struct ls_message)); - if (msg == NULL) - return NULL; /* Read LS Message header */ STREAM_GETC(s, msg->event); -- 2.39.5