Update netdev.c

This commit is contained in:
liuduanfei 2020-12-18 20:53:33 +08:00 committed by GitHub
parent 2c964b5bd4
commit 963f35e96d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -78,7 +78,7 @@ int netdev_register(struct netdev *netdev, const char *name, void *user_data)
netdev->addr_callback = RT_NULL;
/* fill network interface device */
rt_strncpy(netdev->name, name, rt_strlen(name));
rt_strncpy(netdev->name, name, RT_NAME_MAX);
netdev->user_data = user_data;
/* initialize current network interface device single list */
@ -260,7 +260,7 @@ struct netdev *netdev_get_by_name(const char *name)
for (node = &(netdev_list->list); node; node = rt_slist_next(node))
{
netdev = rt_slist_entry(node, struct netdev, list);
if (netdev && (rt_strncmp(netdev->name, name, rt_strlen(netdev->name)) == 0))
if (netdev && (rt_strncmp(netdev->name, name, RT_NAME_MAX) == 0))
{
rt_hw_interrupt_enable(level);
return netdev;