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/12 14:04:48 UTC

[incubator-nuttx] 02/05: arch/sim: Change the return type of netdriver_setmacaddr to void

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

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

commit dbc33fa64f485b8e0e9c32bbb0364ebd36248e0e
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Feb 10 15:10:38 2020 +0800

    arch/sim: Change the return type of netdriver_setmacaddr to void
    
    Change-Id: Idad8e411c58223c6e4f6250aa616c1a94ce61780
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/sim/src/sim/up_internal.h  |  2 +-
 arch/sim/src/sim/up_netdriver.c |  3 +--
 arch/sim/src/sim/up_tapdev.c    | 12 +++++-------
 arch/sim/src/sim/up_wpcap.c     | 18 ++++++------------
 4 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/arch/sim/src/sim/up_internal.h b/arch/sim/src/sim/up_internal.h
index e0b2f91..17e3118 100644
--- a/arch/sim/src/sim/up_internal.h
+++ b/arch/sim/src/sim/up_internal.h
@@ -354,7 +354,7 @@ void wpcap_send(unsigned char *buf, unsigned int buflen);
 
 #ifdef CONFIG_NET_ETHERNET
 int netdriver_init(void);
-int netdriver_setmacaddr(unsigned char *macaddr);
+void netdriver_setmacaddr(unsigned char *macaddr);
 void netdriver_loop(void);
 #endif
 
diff --git a/arch/sim/src/sim/up_netdriver.c b/arch/sim/src/sim/up_netdriver.c
index 88e4f73..d816b96 100644
--- a/arch/sim/src/sim/up_netdriver.c
+++ b/arch/sim/src/sim/up_netdriver.c
@@ -370,8 +370,7 @@ int netdriver_init(void)
   return OK;
 }
 
-int netdriver_setmacaddr(unsigned char *macaddr)
+void netdriver_setmacaddr(unsigned char *macaddr)
 {
   memcpy(g_sim_dev.d_mac.ether.ether_addr_octet, macaddr, IFHWADDRLEN);
-  return 0;
 }
diff --git a/arch/sim/src/sim/up_tapdev.c b/arch/sim/src/sim/up_tapdev.c
index 5a09ef3..463e453 100644
--- a/arch/sim/src/sim/up_tapdev.c
+++ b/arch/sim/src/sim/up_tapdev.c
@@ -88,10 +88,10 @@ struct sel_arg_struct
 };
 
 /****************************************************************************
- * NuttX Domain Public Function Prototypes
+ * Public Function Prototypes
  ****************************************************************************/
 
-int netdriver_setmacaddr(unsigned char *macaddr);
+void netdriver_setmacaddr(unsigned char *macaddr);
 
 /****************************************************************************
  * Private Data
@@ -131,10 +131,9 @@ static inline void dump_ethhdr(const char *msg, unsigned char *buf,
 #  define dump_ethhdr(m,b,l)
 #endif
 
-static int up_setmacaddr(void)
+static void set_macaddr(void)
 {
   unsigned char mac[7];
-  int ret = -1;
 
   /* Assign a random locally-created MAC address.
    *
@@ -158,8 +157,7 @@ static int up_setmacaddr(void)
   mac[5] = rand() % 256;
   mac[6] = 0;
 
-  ret = netdriver_setmacaddr(mac);
-  return ret;
+  netdriver_setmacaddr(mac);
 }
 
 /****************************************************************************
@@ -230,7 +228,7 @@ void tapdev_init(void)
 
   /* Set the MAC address */
 
-  up_setmacaddr();
+  set_macaddr();
 }
 
 unsigned int tapdev_read(unsigned char *buf, unsigned int buflen)
diff --git a/arch/sim/src/sim/up_wpcap.c b/arch/sim/src/sim/up_wpcap.c
index 8bc4526..0cf9138 100644
--- a/arch/sim/src/sim/up_wpcap.c
+++ b/arch/sim/src/sim/up_wpcap.c
@@ -69,8 +69,6 @@
  * Private Types
  ****************************************************************************/
 
-__attribute__ ((dllimport)) extern char **__argv[];
-
 struct pcap;
 
 struct pcap_if
@@ -111,22 +109,18 @@ typedef int (*pcap_sendpacket_t)(struct pcap *, unsigned char *, int);
 HMODULE wpcap;
 static struct pcap *pcap;
 
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-extern int netdriver_setmacaddr(unsigned char *macaddr);
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
 static pcap_findalldevs_t pcap_findalldevs;
 static pcap_open_live_t   pcap_open_live;
 static pcap_next_ex_t     pcap_next_ex;
 static pcap_sendpacket_t  pcap_sendpacket;
 
 /****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+void netdriver_setmacaddr(unsigned char *macaddr);
+
+/****************************************************************************
  * Private Functions
  ****************************************************************************/