mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-06 02:27:15 +00:00
Remove unnecessary p->len checking for pbuf_alloc calls with PBUF_RAM type
pbuf_alloc() for PBUF_RAM type always return big enough memory on success. So checking p->len is not necessary. Testing if p is NULL or not is enough. Signed-off-by: Axel Lin <axel.lin@ingics.com>
This commit is contained in:
parent
8bb27ba8c4
commit
a709041b8b
@ -536,11 +536,7 @@ mld6_send(struct mld_group *group, u8_t type)
|
||||
|
||||
/* Allocate a packet. Size is MLD header + IPv6 Hop-by-hop options header. */
|
||||
p = pbuf_alloc(PBUF_IP, sizeof(struct mld_header) + sizeof(struct ip6_hbh_hdr), PBUF_RAM);
|
||||
if ((p == NULL) || (p->len < (sizeof(struct mld_header) + sizeof(struct ip6_hbh_hdr)))) {
|
||||
/* We couldn't allocate a suitable pbuf. drop it. */
|
||||
if (p != NULL) {
|
||||
pbuf_free(p);
|
||||
}
|
||||
if (p == NULL) {
|
||||
MLD6_STATS_INC(mld6.memerr);
|
||||
return;
|
||||
}
|
||||
|
@ -855,11 +855,7 @@ nd6_send_ns(struct netif * netif, const ip6_addr_t * target_addr, u8_t flags)
|
||||
/* Allocate a packet. */
|
||||
lladdr_opt_len = ((netif->hwaddr_len + 2) >> 3) + (((netif->hwaddr_len + 2) & 0x07) ? 1 : 0);
|
||||
p = pbuf_alloc(PBUF_IP, sizeof(struct ns_header) + (lladdr_opt_len << 3), PBUF_RAM);
|
||||
if ((p == NULL) || (p->len < (sizeof(struct ns_header) + (lladdr_opt_len << 3)))) {
|
||||
/* We couldn't allocate a suitable pbuf for the ns. drop it. */
|
||||
if (p != NULL) {
|
||||
pbuf_free(p);
|
||||
}
|
||||
if (p == NULL) {
|
||||
ND6_STATS_INC(nd6.memerr);
|
||||
return;
|
||||
}
|
||||
@ -923,11 +919,7 @@ nd6_send_na(struct netif * netif, const ip6_addr_t * target_addr, u8_t flags)
|
||||
/* Allocate a packet. */
|
||||
lladdr_opt_len = ((netif->hwaddr_len + 2) >> 3) + (((netif->hwaddr_len + 2) & 0x07) ? 1 : 0);
|
||||
p = pbuf_alloc(PBUF_IP, sizeof(struct na_header) + (lladdr_opt_len << 3), PBUF_RAM);
|
||||
if ((p == NULL) || (p->len < (sizeof(struct na_header) + (lladdr_opt_len << 3)))) {
|
||||
/* We couldn't allocate a suitable pbuf for the ns. drop it. */
|
||||
if (p != NULL) {
|
||||
pbuf_free(p);
|
||||
}
|
||||
if (p == NULL) {
|
||||
ND6_STATS_INC(nd6.memerr);
|
||||
return;
|
||||
}
|
||||
@ -1005,11 +997,7 @@ nd6_send_rs(struct netif * netif)
|
||||
lladdr_opt_len = ((netif->hwaddr_len + 2) >> 3) + (((netif->hwaddr_len + 2) & 0x07) ? 1 : 0);
|
||||
}
|
||||
p = pbuf_alloc(PBUF_IP, sizeof(struct rs_header) + (lladdr_opt_len << 3), PBUF_RAM);
|
||||
if ((p == NULL) || (p->len < (sizeof(struct rs_header) + (lladdr_opt_len << 3)))) {
|
||||
/* We couldn't allocate a suitable pbuf for the ns. drop it. */
|
||||
if (p != NULL) {
|
||||
pbuf_free(p);
|
||||
}
|
||||
if (p == NULL) {
|
||||
ND6_STATS_INC(nd6.memerr);
|
||||
return ERR_BUF;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user