Merge pull request #3674 from DavidLin1577/patch-9

[lwip]Fixed a memset bug in ethernetif.c
This commit is contained in:
Bernard Xiong 2020-06-11 06:52:53 +08:00 committed by GitHub
commit 8d11b9b822
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 9 deletions

View File

@ -443,16 +443,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
#if LWIP_NETIF_HOSTNAME
#define LWIP_HOSTNAME_LEN 16
char *hostname = RT_NULL;
netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN);
netif = (struct netif*) rt_calloc (1, sizeof(struct netif) + LWIP_HOSTNAME_LEN);
#else
netif = (struct netif*) rt_malloc (sizeof(struct netif));
netif = (struct netif*) rt_calloc (1, sizeof(struct netif));
#endif
if (netif == RT_NULL)
{
rt_kprintf("malloc netif failed\n");
return -RT_ERROR;
}
rt_memset(netif, 0, sizeof(struct netif));
/* set netif */
dev->netif = netif;

View File

@ -494,16 +494,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
#if LWIP_NETIF_HOSTNAME
#define LWIP_HOSTNAME_LEN 16
char *hostname = RT_NULL;
netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN);
netif = (struct netif*) rt_calloc (1, sizeof(struct netif) + LWIP_HOSTNAME_LEN);
#else
netif = (struct netif*) rt_malloc (sizeof(struct netif));
netif = (struct netif*) rt_calloc (1, sizeof(struct netif));
#endif
if (netif == RT_NULL)
{
rt_kprintf("malloc netif failed\n");
return -RT_ERROR;
}
rt_memset(netif, 0, sizeof(struct netif));
/* set netif */
dev->netif = netif;

View File

@ -490,16 +490,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
#if LWIP_NETIF_HOSTNAME
#define LWIP_HOSTNAME_LEN 16
char *hostname = RT_NULL;
netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN);
netif = (struct netif*) rt_calloc (1, sizeof(struct netif) + LWIP_HOSTNAME_LEN);
#else
netif = (struct netif*) rt_malloc (sizeof(struct netif));
netif = (struct netif*) rt_calloc (1, sizeof(struct netif));
#endif
if (netif == RT_NULL)
{
rt_kprintf("malloc netif failed\n");
return -RT_ERROR;
}
rt_memset(netif, 0, sizeof(struct netif));
/* set netif */
dev->netif = netif;