shithub: riscv

Download patch

ref: 99cc56f2e986f7337142d382d699ef09c337074a
parent: 5cbffd6e6b4430724532beb5bb130ea701cd1a70
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Nov 8 16:05:01 EST 2016

kernel/ip: remove nil checks for allocb() and padblock()

--- a/sys/src/9/ip/gre.c
+++ b/sys/src/9/ip/gre.c
@@ -297,13 +297,9 @@
 
 	/* Make space to fit ip header (gre header already there) */
 	bp = padblock(bp, GRE_IPONLY);
-	if(bp == nil)
-		return;
 
 	/* make sure the message has a GRE header */
 	bp = pullupblock(bp, GRE_IPONLY+GRE_IPPLUSGRE);
-	if(bp == nil)
-		return;
 
 	gre = (GREhdr *)bp->rp;
 	gre->vihl = IP_VER4;
--- a/sys/src/9/ip/igmp.c
+++ b/sys/src/9/ip/igmp.c
@@ -90,8 +90,6 @@
 	Block *bp;
 
 	bp = allocb(sizeof(IGMPpkt));
-	if(bp == nil)
-		return;
 	p = (IGMPpkt*)bp->wp;
 	p->vihl = IP_VER4;
 	bp->wp += IGMPPKTSZ;
--- a/sys/src/9/ip/rudp.c
+++ b/sys/src/9/ip/rudp.c
@@ -384,9 +384,6 @@
 
 	/* Make space to fit rudp & ip header */
 	bp = padblock(bp, UDP_IPHDR+UDP_RHDRSIZE);
-	if(bp == nil)
-		return;
-
 	uh = (Udphdr *)(bp->rp);
 	uh->vihl = IP_VER4;
 
@@ -955,8 +952,6 @@
 	Fs *f;
 
 	bp = allocb(UDP_IPHDR + UDP_RHDRSIZE);
-	if(bp == nil)
-		return;
 	bp->wp += UDP_IPHDR + UDP_RHDRSIZE;
 	f = c->p->f;
 	uh = (Udphdr *)(bp->rp);
--- a/sys/src/9/ip/tcp.c
+++ b/sys/src/9/ip/tcp.c
@@ -1114,14 +1114,10 @@
 	if(data) {
 		dlen = blocklen(data);
 		data = padblock(data, hdrlen + TCP4_PKT);
-		if(data == nil)
-			return nil;
 	}
 	else {
 		dlen = 0;
 		data = allocb(hdrlen + TCP4_PKT + 64);	/* the 64 pad is to meet mintu's */
-		if(data == nil)
-			return nil;
 		data->wp += hdrlen + TCP4_PKT;
 	}
 
--- a/sys/src/9/ip/udp.c
+++ b/sys/src/9/ip/udp.c
@@ -242,9 +242,6 @@
 	switch(version){
 	case V4:
 		bp = padblock(bp, UDP4_IPHDR_SZ+UDP_UDPHDR_SZ);
-		if(bp == nil)
-			return;
-
 		uh4 = (Udp4hdr *)(bp->rp);
 		ptcllen = dlen + UDP_UDPHDR_SZ;
 		uh4->Unused = 0;
@@ -276,14 +273,11 @@
 		break;
 
 	case V6:
-		bp = padblock(bp, UDP6_IPHDR_SZ+UDP_UDPHDR_SZ);
-		if(bp == nil)
-			return;
-
 		/*
 		 * using the v6 ip header to create pseudo header
 		 * first then reset it to the normal ip header
 		 */
+		bp = padblock(bp, UDP6_IPHDR_SZ+UDP_UDPHDR_SZ);
 		uh6 = (Udp6hdr *)(bp->rp);
 		memset(uh6, 0, 8);
 		ptcllen = dlen + UDP_UDPHDR_SZ;