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-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 44e5a5ecd dhcpc: adds errno to the dhcpc internal error
44e5a5ecd is described below

commit 44e5a5ecd7318332a4eea6924aecf19f6962379a
Author: zhanghongyu <[email protected]>
AuthorDate: Tue Apr 11 22:10:43 2023 +0800

    dhcpc: adds errno to the dhcpc internal error
    
    add errno to help analyze possible causes of dhcp failures
    
    Signed-off-by: zhanghongyu <[email protected]>
---
 netutils/dhcpc/dhcpc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/netutils/dhcpc/dhcpc.c b/netutils/dhcpc/dhcpc.c
index caf5ea2b5..e716a9d4a 100644
--- a/netutils/dhcpc/dhcpc.c
+++ b/netutils/dhcpc/dhcpc.c
@@ -306,6 +306,7 @@ static int dhcpc_sendmsg(FAR struct dhcpc_state_s *pdhcpc,
         break;
 
       default:
+        errno = EINVAL;
         return ERROR;
     }
 
@@ -729,6 +730,7 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state 
*presult)
     {
       if (pdhcpc->cancel)
         {
+          errno = EINTR;
           return ERROR;
         }
 
@@ -807,6 +809,7 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state 
*presult)
     {
       if (pdhcpc->cancel)
         {
+          errno = EINTR;
           return ERROR;
         }
 
@@ -852,6 +855,7 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state 
*presult)
                   ninfo("Received NAK\n");
                   oldaddr.s_addr = INADDR_ANY;
                   netlib_set_ipv4addr(pdhcpc->interface, &oldaddr);
+                  errno = ECONNREFUSED;
                   return ERROR;
                 }
 
@@ -937,12 +941,14 @@ int dhcpc_request_async(FAR void *handle, 
dhcpc_callback_t callback)
 
   if (!handle || !callback)
     {
+      errno = EINVAL;
       return ERROR;
     }
 
   if (pdhcpc->thread)
     {
       nerr("ERROR: DHCPC thread already running\n");
+      errno = EALREADY;
       return ERROR;
     }
 
@@ -951,6 +957,7 @@ int dhcpc_request_async(FAR void *handle, dhcpc_callback_t 
callback)
   if (ret != 0)
     {
       nerr("ERROR: Failed to start the DHCPC thread\n");
+      errno = ret;
       return ERROR;
     }
 

Reply via email to