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

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

commit 4c99ad1ba9576f59267135211b5ff6cc3477315c
Author: Zhe Weng <[email protected]>
AuthorDate: Fri Nov 3 21:22:03 2023 +0800

    net/utils: Switch argument order of net_ipv6_pref2mask
    
    When implementing IPv6-related logic, we found the `net_ipv6_pref2mask`
    and `net_ipv6addr_copy` are using different argument order:
    ```
    net_ipv6addr_copy(ifaddr->addr, addr);
    net_ipv6_pref2mask(preflen, ifaddr->mask);
    ```
    Change the order to:
    ```
    net_ipv6addr_copy(ifaddr->addr, addr);
    net_ipv6_pref2mask(ifaddr->mask, preflen);
    ```
    
    Signed-off-by: Zhe Weng <[email protected]>
---
 net/icmpv6/icmpv6_rnotify.c    | 2 +-
 net/netdev/netdev_ipv6.c       | 4 ++--
 net/utils/net_ipv6_pref2mask.c | 4 ++--
 net/utils/utils.h              | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/icmpv6/icmpv6_rnotify.c b/net/icmpv6/icmpv6_rnotify.c
index 9ea4a1683f..24516da857 100644
--- a/net/icmpv6/icmpv6_rnotify.c
+++ b/net/icmpv6/icmpv6_rnotify.c
@@ -103,7 +103,7 @@ void icmpv6_setaddresses(FAR struct net_driver_s *dev,
       preflen = 128;
     }
 
-  net_ipv6_pref2mask(preflen, mask);
+  net_ipv6_pref2mask(mask, preflen);
 
   ninfo("preflen=%d netmask=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
         preflen,
diff --git a/net/netdev/netdev_ipv6.c b/net/netdev/netdev_ipv6.c
index 0692d32305..67e51e871f 100644
--- a/net/netdev/netdev_ipv6.c
+++ b/net/netdev/netdev_ipv6.c
@@ -142,7 +142,7 @@ int netdev_ipv6_add(FAR struct net_driver_s *dev, const 
net_ipv6addr_t addr,
        *          allows to override the address. But not sure if it's good.
        */
 
-      net_ipv6_pref2mask(preflen, ifaddr->mask);
+      net_ipv6_pref2mask(ifaddr->mask, preflen);
       return OK;
     }
 
@@ -174,7 +174,7 @@ int netdev_ipv6_add(FAR struct net_driver_s *dev, const 
net_ipv6addr_t addr,
 #endif /* CONFIG_NETDEV_MULTIPLE_IPv6 */
 
   net_ipv6addr_copy(ifaddr->addr, addr);
-  net_ipv6_pref2mask(preflen, ifaddr->mask);
+  net_ipv6_pref2mask(ifaddr->mask, preflen);
 
   return OK;
 }
diff --git a/net/utils/net_ipv6_pref2mask.c b/net/utils/net_ipv6_pref2mask.c
index 4f016b57c8..880abc5985 100644
--- a/net/utils/net_ipv6_pref2mask.c
+++ b/net/utils/net_ipv6_pref2mask.c
@@ -42,15 +42,15 @@
  *   specifies the number of MS bits under mask (0-128)
  *
  * Input Parameters:
+ *   mask     - The location to return the netmask.
  *   preflen  - Determines the width of the netmask (in bits).  Range 0-128
- *   mask  - The location to return the netmask.
  *
  * Returned Value:
  *   None
  *
  ****************************************************************************/
 
-void net_ipv6_pref2mask(uint8_t preflen, net_ipv6addr_t mask)
+void net_ipv6_pref2mask(net_ipv6addr_t mask, uint8_t preflen)
 {
   unsigned int bit;
   unsigned int i;
diff --git a/net/utils/utils.h b/net/utils/utils.h
index 757e0580b9..04fe60a442 100644
--- a/net/utils/utils.h
+++ b/net/utils/utils.h
@@ -242,8 +242,8 @@ uint8_t net_ipv6_mask2pref(FAR const uint16_t *mask);
  *   specifies the number of MS bits under mask (0-128)
  *
  * Input Parameters:
+ *   mask     - The location to return the netmask.
  *   preflen  - Determines the width of the netmask (in bits).  Range 0-128
- *   mask  - The location to return the netmask.
  *
  * Returned Value:
  *   None
@@ -251,7 +251,7 @@ uint8_t net_ipv6_mask2pref(FAR const uint16_t *mask);
  ****************************************************************************/
 
 #ifdef CONFIG_NET_IPv6
-void net_ipv6_pref2mask(uint8_t preflen, net_ipv6addr_t mask);
+void net_ipv6_pref2mask(net_ipv6addr_t mask, uint8_t preflen);
 #endif
 
 /****************************************************************************

Reply via email to