drivers/net/phy_notify.c: Use IFNAMSIZ for interface name size

Replace CONFIG_PHY_NOTIFICATION_MAXINTFLEN with IFNAMSIZ
This commit is contained in:
Xiang Xiao 2020-02-02 15:42:28 +08:00 committed by Gregory Nutt
parent 18325867bb
commit 1321c34022
2 changed files with 5 additions and 18 deletions

View File

@ -53,6 +53,7 @@
#include <string.h>
#include <errno.h>
#include <debug.h>
#include <net/if.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
@ -104,7 +105,7 @@
struct phy_notify_s
{
bool assigned;
char intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN + 1];
char intf[IFNAMSIZ + 1];
pid_t pid;
struct sigevent event;
struct sigwork_s work;
@ -200,7 +201,7 @@ static FAR struct phy_notify_s *phy_find_assigned(FAR const char *intf,
{
client = &g_notify_clients[i];
if (client->assigned && client->pid == pid &&
strncmp(client->intf, intf, CONFIG_PHY_NOTIFICATION_MAXINTFLEN) == 0)
strncmp(client->intf, intf, IFNAMSIZ) == 0)
{
/* Return the matching client entry to the caller */
@ -262,8 +263,6 @@ static int phy_handler(int irq, FAR void *context, FAR void *arg)
*
* Input Parameters:
* intf - Provides the name of the network interface, for example, "eth0".
* The length of intf must not exceed 4 bytes (excluding NULL
* terminator). Configurable with CONFIG_PHY_NOTIFICATION_MAXINTFLEN.
* pid - Identifies the task to receive the signal. The special value
* of zero means to use the pid of the current task.
* event - Describes the way a task is to be notified
@ -315,8 +314,8 @@ int phy_notify_subscribe(FAR const char *intf, pid_t pid,
client->pid = pid;
client->event = *event;
strncpy(client->intf, intf, CONFIG_PHY_NOTIFICATION_MAXINTFLEN + 1);
client->intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN] = '\0';
strncpy(client->intf, intf, IFNAMSIZ + 1);
client->intf[IFNAMSIZ] = '\0';
/* Attach/re-attach the PHY interrupt */
@ -343,8 +342,6 @@ int phy_notify_subscribe(FAR const char *intf, pid_t pid,
*
* Input Parameters:
* intf - Provides the name of the network interface, for example, "eth0".
* The length of 'intf' must not exceed 4 bytes (excluding NULL
* terminator). Configurable with CONFIG_PHY_NOTIFICATION_MAXINTFLEN.
* pid - Identifies the task that was receiving notifications.
*
* Returned Value:

View File

@ -60,12 +60,6 @@
# define CONFIG_PHY_NOTIFICATION_NCLIENTS 1
#endif
/* Maximum length of on interface device name (excluding NULL termination) */
#ifndef CONFIG_PHY_NOTIFICATION_MAXINTFLEN
# define CONFIG_PHY_NOTIFICATION_MAXINTFLEN 4
#endif
/****************************************************************************
* Public Data
****************************************************************************/
@ -96,8 +90,6 @@ extern "C"
*
* Input Parameters:
* intf - Provides the name of the network interface, for example, "eth0".
* The length of intf must not exceed 4 bytes (excluding NULL
* terminator). Configurable with CONFIG_PHY_NOTIFICATION_MAXINTFLEN.
* pid - Identifies the task to receive the signal. The special value
* of zero means to use the pid of the current task.
* event - Describe the way a task is to be notified
@ -125,8 +117,6 @@ int phy_notify_subscribe(FAR const char *intf, pid_t pid,
*
* Input Parameters:
* intf - Provides the name of the network interface, for example, "eth0".
* The length of 'intf' must not exceed 4 bytes (excluding NULL
* terminator). Configurable with CONFIG_PHY_NOTIFICATION_MAXINTFLEN.
* pid - Identifies the task that was receiving notifications.
*
* Returned Value: