zhhyu7 opened a new pull request, #21383:
URL: https://github.com/apache/nuttx/pull/21383

   ## Summary
   
   `arp_send_async()` logged its allocation failure as
   `nerr("ERROR: %s \n", ENOMEM_STR)`, pulling the message text out of the
   `Exxx_STR` macros in `include/errno.h`. Those macros exist to build the      
                         
   `strerror()` table in `libs/libc/string/lib_strerror.c`; using them directly 
                         
   in log statements ties call sites to that table and gets in the way of  
   removing the macros in favour of `strerror()`.                               
                         
                                                      
   Inline the literal instead, matching every other `nerr()` in this file       
                         
   (`"ERROR: Unreachable: %08lx"`, `"ERROR: Failed to allocate a callback"`,    
                         
   ...). This also drops a stray space that the old format string left between  
                                                                                
                                               
   the message and the newline.                                                 
                         
   
   After this change `ENOMEM_STR` has exactly one user left, the `strerror()`   
                                                                                
                                               
   table itself.                         
   
   File: `net/arp/arp_send.c` (+1/-1)
   ## Impact
   
   Log text only. No functional change: the same `-ENOMEM` is still returned on 
                                                                                
                                               
   the same path, and `include/errno.h` is untouched, so nothing else that uses 
       
   `Exxx_STR` is affected. The message is only compiled in when                 
                         
   `CONFIG_DEBUG_NET_ERROR=y`.                        
                                                                                
                                                                                
                                               
   The printed text is unchanged apart from the removed trailing space, so log  
                         
   scrapers matching on `ERROR: Out of memory` keep working.
   
   ## Testing
   
   `sim:dynconns` with `CONFIG_NET_IPv4=y`, `CONFIG_NET_ARP_SEND=y`,            
                         
   `CONFIG_NET_ARP_ACD=y` and `CONFIG_DEBUG_NET_ERROR=y`. Bringing `eth0` up    
                         
   makes ARP ACD announce the address, which calls `arp_send_async()`; the      
                         
   `kmm_zalloc()` failure branch was forced locally to reach the log line:      
                         
                                                      
       nsh> arpacd                                    
       arp_send_async: ERROR: Out of memory           
       === bringing eth0 up (triggers ARP ACD announce)                   
       === done                                                                 
                         
                                                                                
                         
   The `arp_send_async: ` prefix comes from `EXTRA_FMT` in `nuttx/debug.h`.
   Before the change the same line ended with an extra space before the         
                         
   newline; the message body is otherwise identical.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to