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

This commit is contained in:
cinap_lenrek 2016-11-08 21:05:01 +01:00
parent 5cbffd6e6b
commit 99cc56f2e9
5 changed files with 1 additions and 22 deletions

View file

@ -297,13 +297,9 @@ grekick(void *x, Block *bp)
/* 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;

View file

@ -90,8 +90,6 @@ igmpsendreport(Medium *m, uchar *addr)
Block *bp;
bp = allocb(sizeof(IGMPpkt));
if(bp == nil)
return;
p = (IGMPpkt*)bp->wp;
p->vihl = IP_VER4;
bp->wp += IGMPPKTSZ;

View file

@ -384,9 +384,6 @@ rudpkick(void *x)
/* 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 @@ relsendack(Conv *c, Reliable *r, int hangup)
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);

View file

@ -1114,14 +1114,10 @@ htontcp4(Tcp *tcph, Block *data, Tcp4hdr *ph, Tcpctl *tcb)
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;
}

View file

@ -242,9 +242,6 @@ udpkick(void *x, Block *bp)
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 @@ udpkick(void *x, Block *bp)
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;