You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/02/02 17:03:00 UTC

[incubator-nuttx] branch master updated: drivers/net/phy_notify.c: Use IFNAMSIZ for interface name size

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 1321c34  drivers/net/phy_notify.c: Use IFNAMSIZ for interface name size
1321c34 is described below

commit 1321c34022d8e867ee3da1b664c4c7a95ee6a3e8
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Feb 2 15:42:28 2020 +0800

    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 3ceda17..7d6abb8 100644
--- a/drivers/net/phy_notify.c
+++ b/drivers/net/phy_notify.c
@@ -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:
diff --git a/include/nuttx/net/phy.h b/include/nuttx/net/phy.h
index 553cbe3..ae7e294 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: