diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-06-14 08:58:05 -0400 | 
|---|---|---|
| committer | David Lamparter <equinox@opensourcerouting.org> | 2018-08-11 17:14:58 +0200 | 
| commit | 0ce1ca805d607cec2c0f75dac8950f40e75fc971 (patch) | |
| tree | bf34e7a0084ae76089d43ee7f2c4ca8eeed62c8a /nhrpd | |
| parent | 1408cdfc07202b2c3e31ad2ef40fae0e8a31e8c0 (diff) | |
*: ALLOC calls cannot fail
There is no need to check for failure of a ALLOC call
as that any failure to do so will result in a assert
happening.  So we can safely remove all of this code.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'nhrpd')
| -rw-r--r-- | nhrpd/nhrp_cache.c | 21 | ||||
| -rw-r--r-- | nhrpd/nhrp_interface.c | 2 | ||||
| -rw-r--r-- | nhrpd/nhrp_nhs.c | 2 | ||||
| -rw-r--r-- | nhrpd/nhrp_peer.c | 24 | ||||
| -rw-r--r-- | nhrpd/nhrp_vc.c | 17 | ||||
| -rw-r--r-- | nhrpd/zbuf.c | 2 | 
6 files changed, 29 insertions, 39 deletions
diff --git a/nhrpd/nhrp_cache.c b/nhrpd/nhrp_cache.c index ffc8b5a9bf..f3a33eb28f 100644 --- a/nhrpd/nhrp_cache.c +++ b/nhrpd/nhrp_cache.c @@ -48,17 +48,16 @@ static void *nhrp_cache_alloc(void *data)  	struct nhrp_cache *p, *key = data;  	p = XMALLOC(MTYPE_NHRP_CACHE, sizeof(struct nhrp_cache)); -	if (p) { -		*p = (struct nhrp_cache){ -			.cur.type = NHRP_CACHE_INVALID, -			.new.type = NHRP_CACHE_INVALID, -			.remote_addr = key->remote_addr, -			.ifp = key->ifp, -			.notifier_list = -				NOTIFIER_LIST_INITIALIZER(&p->notifier_list), -		}; -		nhrp_cache_counts[p->cur.type]++; -	} + +	*p = (struct nhrp_cache){ +		.cur.type = NHRP_CACHE_INVALID, +		.new.type = NHRP_CACHE_INVALID, +		.remote_addr = key->remote_addr, +		.ifp = key->ifp, +		.notifier_list = +		NOTIFIER_LIST_INITIALIZER(&p->notifier_list), +	}; +	nhrp_cache_counts[p->cur.type]++;  	return p;  } diff --git a/nhrpd/nhrp_interface.c b/nhrpd/nhrp_interface.c index 054a375cb8..3a42712748 100644 --- a/nhrpd/nhrp_interface.c +++ b/nhrpd/nhrp_interface.c @@ -25,8 +25,6 @@ static int nhrp_if_new_hook(struct interface *ifp)  	afi_t afi;  	nifp = XCALLOC(MTYPE_NHRP_IF, sizeof(struct nhrp_interface)); -	if (!nifp) -		return 0;  	ifp->info = nifp;  	nifp->ifp = ifp; diff --git a/nhrpd/nhrp_nhs.c b/nhrpd/nhrp_nhs.c index a7a8c20191..360972c327 100644 --- a/nhrpd/nhrp_nhs.c +++ b/nhrpd/nhrp_nhs.c @@ -324,8 +324,6 @@ int nhrp_nhs_add(struct interface *ifp, afi_t afi, union sockunion *proto_addr,  	}  	nhs = XMALLOC(MTYPE_NHRP_NHS, sizeof(struct nhrp_nhs)); -	if (!nhs) -		return NHRP_ERR_NO_MEMORY;  	*nhs = (struct nhrp_nhs){  		.afi = afi, diff --git a/nhrpd/nhrp_peer.c b/nhrpd/nhrp_peer.c index 8952a282e9..44271d68ac 100644 --- a/nhrpd/nhrp_peer.c +++ b/nhrpd/nhrp_peer.c @@ -165,18 +165,18 @@ static void *nhrp_peer_create(void *data)  	struct nhrp_peer *p, *key = data;  	p = XMALLOC(MTYPE_NHRP_PEER, sizeof(*p)); -	if (p) { -		*p = (struct nhrp_peer){ -			.ref = 0, -			.ifp = key->ifp, -			.vc = key->vc, -			.notifier_list = -				NOTIFIER_LIST_INITIALIZER(&p->notifier_list), -		}; -		nhrp_vc_notify_add(p->vc, &p->vc_notifier, nhrp_peer_vc_notify); -		nhrp_interface_notify_add(p->ifp, &p->ifp_notifier, -					  nhrp_peer_ifp_notify); -	} + +	*p = (struct nhrp_peer){ +		.ref = 0, +		.ifp = key->ifp, +		.vc = key->vc, +		.notifier_list = +		NOTIFIER_LIST_INITIALIZER(&p->notifier_list), +	}; +	nhrp_vc_notify_add(p->vc, &p->vc_notifier, nhrp_peer_vc_notify); +	nhrp_interface_notify_add(p->ifp, &p->ifp_notifier, +				  nhrp_peer_ifp_notify); +  	return p;  } diff --git a/nhrpd/nhrp_vc.c b/nhrpd/nhrp_vc.c index c373411d66..41a87d4adb 100644 --- a/nhrpd/nhrp_vc.c +++ b/nhrpd/nhrp_vc.c @@ -48,14 +48,13 @@ static void *nhrp_vc_alloc(void *data)  	struct nhrp_vc *vc, *key = data;  	vc = XMALLOC(MTYPE_NHRP_VC, sizeof(struct nhrp_vc)); -	if (vc) { -		*vc = (struct nhrp_vc){ -			.local.nbma = key->local.nbma, -			.remote.nbma = key->remote.nbma, -			.notifier_list = -				NOTIFIER_LIST_INITIALIZER(&vc->notifier_list), -		}; -	} + +	*vc = (struct nhrp_vc){ +		.local.nbma = key->local.nbma, +		.remote.nbma = key->remote.nbma, +		.notifier_list = +		NOTIFIER_LIST_INITIALIZER(&vc->notifier_list), +	};  	return vc;  } @@ -118,8 +117,6 @@ int nhrp_vc_ipsec_updown(uint32_t child_id, struct nhrp_vc *vc)  			return 0;  		sa = XMALLOC(MTYPE_NHRP_VC, sizeof(struct child_sa)); -		if (!sa) -			return 0;  		*sa = (struct child_sa){  			.id = child_id, diff --git a/nhrpd/zbuf.c b/nhrpd/zbuf.c index 65232a3093..6e7cad8aec 100644 --- a/nhrpd/zbuf.c +++ b/nhrpd/zbuf.c @@ -25,8 +25,6 @@ struct zbuf *zbuf_alloc(size_t size)  	struct zbuf *zb;  	zb = XMALLOC(MTYPE_ZBUF_DATA, sizeof(*zb) + size); -	if (!zb) -		return NULL;  	zbuf_init(zb, zb + 1, size, 0);  	zb->allocated = 1;  | 
