From 1321c34022d8e867ee3da1b664c4c7a95ee6a3e8 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 2 Feb 2020 15:42:28 +0800 Subject: [PATCH] drivers/net/phy_notify.c: Use IFNAMSIZ for interface name size Replace CONFIG_PHY_NOTIFICATION_MAXINTFLEN with IFNAMSIZ --- drivers/net/phy_notify.c | 13 +++++-------- include/nuttx/net/phy.h | 10 ---------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/net/phy_notify.c b/drivers/net/phy_notify.c index 3ceda17e91..7d6abb8cad 100644 --- a/drivers/net/phy_notify.c +++ b/drivers/net/phy_notify.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -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: diff --git a/include/nuttx/net/phy.h b/include/nuttx/net/phy.h index 553cbe369a..ae7e294c29 100644 --- a/include/nuttx/net/phy.h +++ b/include/nuttx/net/phy.h @@ -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: