You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2021/05/24 03:34:43 UTC

[incubator-nuttx-apps] branch master updated: Include assert.h for DEBUGASSERT caller

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 1ee948e  Include assert.h for DEBUGASSERT caller
1ee948e is described below

commit 1ee948e0c8f998ab6ca0cdae62a8ad39b961964c
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu May 20 11:32:57 2021 +0800

    Include assert.h for DEBUGASSERT caller
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 examples/rpmsgsocket/rpsock_server.c |  1 +
 fsutils/passwd/passwd_find.c         |  3 ++-
 netutils/dhcpd/dhcpd.c               |  1 -
 netutils/ftpc/ftpc_getfile.c         |  1 +
 netutils/ftpc/ftpc_listdir.c         |  1 +
 netutils/ftpc/ftpc_putfile.c         |  1 +
 netutils/ftpc/ftpc_socket.c          | 48 ++++++++++++++++++++----------------
 netutils/netlib/netlib_ipv4adaptor.c |  6 +++--
 netutils/netlib/netlib_ipv6adaptor.c |  6 +++--
 netutils/ntpclient/ntpclient.c       |  3 ++-
 netutils/telnetd/telnetd_daemon.c    |  1 +
 nshlib/nsh_fsutils.c                 |  1 +
 nshlib/nsh_netcmds.c                 |  1 +
 nshlib/nsh_session.c                 |  1 +
 system/taskset/taskset.c             |  1 +
 testing/getprime/getprime_main.c     |  3 ++-
 16 files changed, 50 insertions(+), 29 deletions(-)

diff --git a/examples/rpmsgsocket/rpsock_server.c b/examples/rpmsgsocket/rpsock_server.c
index 001d9db..da8194b 100644
--- a/examples/rpmsgsocket/rpsock_server.c
+++ b/examples/rpmsgsocket/rpsock_server.c
@@ -32,6 +32,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <poll.h>
+#include <assert.h>
 #include <errno.h>
 
 /****************************************************************************
diff --git a/fsutils/passwd/passwd_find.c b/fsutils/passwd/passwd_find.c
index 4e737ec..c30232f 100644
--- a/fsutils/passwd/passwd_find.c
+++ b/fsutils/passwd/passwd_find.c
@@ -42,6 +42,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
+#include <assert.h>
 #include <errno.h>
 
 #include "passwd.h"
@@ -110,7 +111,7 @@ int passwd_find(FAR const char *username, FAR struct passwd_s *passwd)
   offset = 0;
   ret    = -ENOENT;
 
-  while (fgets(iobuffer, CONFIG_FSUTILS_PASSWD_IOBUFFER_SIZE, stream) != NULL)
+  while (fgets(iobuffer, CONFIG_FSUTILS_PASSWD_IOBUFFER_SIZE, stream))
     {
       ptr  = iobuffer;
       name = ptr;
diff --git a/netutils/dhcpd/dhcpd.c b/netutils/dhcpd/dhcpd.c
index 939da5b..5c834d2 100644
--- a/netutils/dhcpd/dhcpd.c
+++ b/netutils/dhcpd/dhcpd.c
@@ -1629,7 +1629,6 @@ int dhcpd_start(FAR const char *interface)
       if (pid < 0)
         {
           int errval = errno;
-          DEBUGASSERT(errval > 0);
 
           g_dhcpd_daemon.ds_state = DHCPD_STOPPED;
           nerr("ERROR: Failed to start the DHCPD daemon: %d\n", errval);
diff --git a/netutils/ftpc/ftpc_getfile.c b/netutils/ftpc/ftpc_getfile.c
index dd2ca62..8bb38b4 100644
--- a/netutils/ftpc/ftpc_getfile.c
+++ b/netutils/ftpc/ftpc_getfile.c
@@ -43,6 +43,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
+#include <assert.h>
 #include <debug.h>
 #include <errno.h>
 
diff --git a/netutils/ftpc/ftpc_listdir.c b/netutils/ftpc/ftpc_listdir.c
index 213ed22..9019b0d 100644
--- a/netutils/ftpc/ftpc_listdir.c
+++ b/netutils/ftpc/ftpc_listdir.c
@@ -44,6 +44,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <libgen.h>
+#include <assert.h>
 #include <errno.h>
 #include <debug.h>
 
diff --git a/netutils/ftpc/ftpc_putfile.c b/netutils/ftpc/ftpc_putfile.c
index dbb1f8f..dc50000 100644
--- a/netutils/ftpc/ftpc_putfile.c
+++ b/netutils/ftpc/ftpc_putfile.c
@@ -44,6 +44,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <libgen.h>
+#include <assert.h>
 #include <errno.h>
 #include <debug.h>
 
diff --git a/netutils/ftpc/ftpc_socket.c b/netutils/ftpc/ftpc_socket.c
index d1f19d7..12520ff 100644
--- a/netutils/ftpc/ftpc_socket.c
+++ b/netutils/ftpc/ftpc_socket.c
@@ -43,6 +43,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
+#include <assert.h>
 #include <debug.h>
 #include <errno.h>
 
@@ -148,8 +149,9 @@ errout:
 
 void ftpc_sockclose(FAR struct ftpc_socket_s *sock)
 {
-  /* Note that the same underlying socket descriptor is used for both streams.
-   * There should be harmless failures on the second fclose and the close.
+  /* Note that the same underlying socket descriptor is used for both
+   * streams. There should be harmless failures on the second fclose
+   * and the close.
    */
 
   fclose(sock->instream);
@@ -168,7 +170,8 @@ void ftpc_sockclose(FAR struct ftpc_socket_s *sock)
  *
  ****************************************************************************/
 
-int ftpc_sockconnect(FAR struct ftpc_socket_s *sock, FAR struct sockaddr *addr)
+int ftpc_sockconnect(FAR struct ftpc_socket_s *sock,
+                     FAR struct sockaddr *addr)
 {
   int ret;
 
@@ -177,14 +180,16 @@ int ftpc_sockconnect(FAR struct ftpc_socket_s *sock, FAR struct sockaddr *addr)
 #ifdef CONFIG_NET_IPv6
   if (addr->sa_family == AF_INET6)
     {
-      ret = connect(sock->sd, (struct sockaddr *)addr, sizeof(struct sockaddr_in6));
+      ret = connect(sock->sd, (struct sockaddr *)addr,
+                    sizeof(struct sockaddr_in6));
     }
   else
 #endif
 #ifdef CONFIG_NET_IPv4
   if (addr->sa_family == AF_INET)
     {
-      ret = connect(sock->sd, (struct sockaddr *)addr, sizeof(struct sockaddr_in));
+      ret = connect(sock->sd, (struct sockaddr *)addr,
+                    sizeof(struct sockaddr_in));
     }
   else
 #endif
@@ -234,21 +239,21 @@ void ftpc_sockcopy(FAR struct ftpc_socket_s *dest,
  *   Accept a connection on the data socket.  This function is only used
  *   in active mode.
  *
- *   In active mode FTP the client connects from a random port (N>1023) to the
- *   FTP server's command port, port 21. Then, the client starts listening to
- *   port N+1 and sends the FTP command PORT N+1 to the FTP server. The server
- *   will then connect back to the client's specified data port from its local
- *   data port, which is port 20. In passive mode FTP the client initiates
- *   both connections to the server, solving the problem of firewalls filtering
- *   the incoming data port connection to the client from the server. When
- *   opening an FTP connection, the client opens two random ports locally
- *   (N>1023 and N+1). The first port contacts the server on port 21, but
- *   instead of then issuing a PORT command and allowing the server to connect
- *   back to its data port, the client will issue the PASV command. The result
- *   of this is that the server then opens a random unprivileged port (P >
- *   1023) and sends the PORT P command back to the client. The client then
- *   initiates the connection from port N+1 to port P on the server to transfer
- *   data.
+ *   In active mode FTP the client connects from a random port (N>1023) to
+ *   the FTP server's command port, port 21. Then, the client starts
+ *   listening to port N+1 and sends the FTP command PORT N+1 to the FTP
+ *   server. The server will then connect back to the client's specified data
+ *   port from its local data port, which is port 20. In passive mode FTP the
+ *   client initiates both connections to the server, solving the problem of
+ *   firewalls filtering the incoming data port connection to the client from
+ *   the server. When opening an FTP connection, the client opens two random
+ *   ports locally (N>1023 and N+1). The first port contacts the server on
+ *   port 21, but instead of then issuing a PORT command and allowing the
+ *   server to connect back to its data port, the client will issue the PASV
+ *   command. The result of this is that the server then opens a random
+ *   unprivileged port (P > 1023) and sends the PORT P command back to the
+ *   client. The client then initiates the connection from port N+1 to port P
+ *   on the server to transfer data.
  *
  ****************************************************************************/
 
@@ -318,7 +323,7 @@ errout_with_sd:
  * Name: ftpc_socklisten
  *
  * Description:
- *   Bind the socket to local address and wait for connection from the server.
+ *   Bind the socket to local address and wait for connection from server.
  *
  ****************************************************************************/
 
@@ -411,5 +416,6 @@ int ftpc_sockgetsockname(FAR struct ftpc_socket_s *sock,
       nerr("ERROR: getsockname failed: %d\n", errno);
       return ERROR;
     }
+
   return OK;
 }
diff --git a/netutils/netlib/netlib_ipv4adaptor.c b/netutils/netlib/netlib_ipv4adaptor.c
index 8b99ec2..9024a5a 100644
--- a/netutils/netlib/netlib_ipv4adaptor.c
+++ b/netutils/netlib/netlib_ipv4adaptor.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * netutils/netlib/netlib_ipv4adaptor.c
+ * apps/netutils/netlib/netlib_ipv4adaptor.c
  *
  *   Copyright (C) 2017 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <gn...@nuttx.org>
@@ -43,6 +43,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <assert.h>
 #include <errno.h>
 
 #include <net/if.h>
@@ -87,7 +88,8 @@
  *
  ****************************************************************************/
 
-static int _netlib_ipv4adaptor(in_addr_t destipaddr, FAR in_addr_t *srcipaddr)
+static int _netlib_ipv4adaptor(in_addr_t destipaddr,
+                               FAR in_addr_t *srcipaddr)
 {
   FAR struct ifreq *ifr;
   struct ifconf ifc;
diff --git a/netutils/netlib/netlib_ipv6adaptor.c b/netutils/netlib/netlib_ipv6adaptor.c
index aa734ce..05a7b9e 100644
--- a/netutils/netlib/netlib_ipv6adaptor.c
+++ b/netutils/netlib/netlib_ipv6adaptor.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * netutils/netlib/netlib_ipv6adaptor.c
+ * apps/netutils/netlib/netlib_ipv6adaptor.c
  *
  *   Copyright (C) 2017 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <gn...@nuttx.org>
@@ -43,6 +43,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <assert.h>
 #include <errno.h>
 
 #include <net/if.h>
@@ -179,7 +180,8 @@ static int _netlib_ipv6adaptor(FAR const struct in6_addr *destipaddr,
 
       strncpy(maskreq.lifr_name, lifr->lifr_name, IFNAMSIZ);
 
-      status = ioctl(sd, SIOCGLIFNETMASK, (unsigned long)((uintptr_t)&maskreq));
+      status = ioctl(sd, SIOCGLIFNETMASK,
+                     (unsigned long)((uintptr_t)&maskreq));
       if (status < 0)
         {
           ret = -errno;
diff --git a/netutils/ntpclient/ntpclient.c b/netutils/ntpclient/ntpclient.c
index cdaf1b1..4140a18 100644
--- a/netutils/ntpclient/ntpclient.c
+++ b/netutils/ntpclient/ntpclient.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * netutils/ntpclient/ntpclient.c
+ * apps/netutils/ntpclient/ntpclient.c
  *
  *   Copyright (C) 2014, 2016, 2020 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <gn...@nuttx.org>
@@ -50,6 +50,7 @@
 #include <string.h>
 #include <time.h>
 #include <sched.h>
+#include <assert.h>
 #include <errno.h>
 #include <debug.h>
 
diff --git a/netutils/telnetd/telnetd_daemon.c b/netutils/telnetd/telnetd_daemon.c
index 94fc2f1..dca485e 100644
--- a/netutils/telnetd/telnetd_daemon.c
+++ b/netutils/telnetd/telnetd_daemon.c
@@ -53,6 +53,7 @@
 #include <signal.h>
 #include <semaphore.h>
 #include <sched.h>
+#include <assert.h>
 #include <errno.h>
 #include <debug.h>
 
diff --git a/nshlib/nsh_fsutils.c b/nshlib/nsh_fsutils.c
index 9d8cf27..b20d803 100644
--- a/nshlib/nsh_fsutils.c
+++ b/nshlib/nsh_fsutils.c
@@ -47,6 +47,7 @@
 #include <ctype.h>
 #include <fcntl.h>
 #include <dirent.h>
+#include <assert.h>
 
 #include "nsh.h"
 #include "nsh_console.h"
diff --git a/nshlib/nsh_netcmds.c b/nshlib/nsh_netcmds.c
index d4633e1..c518b4a 100644
--- a/nshlib/nsh_netcmds.c
+++ b/nshlib/nsh_netcmds.c
@@ -56,6 +56,7 @@
 #include <fcntl.h>       /* Needed for open */
 #include <dirent.h>
 #include <libgen.h>      /* Needed for basename */
+#include <assert.h>
 #include <errno.h>
 #include <debug.h>
 
diff --git a/nshlib/nsh_session.c b/nshlib/nsh_session.c
index 2f28412..9379df0 100644
--- a/nshlib/nsh_session.c
+++ b/nshlib/nsh_session.c
@@ -43,6 +43,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <assert.h>
 
 #ifdef CONFIG_NSH_CLE
 #  include "system/cle.h"
diff --git a/system/taskset/taskset.c b/system/taskset/taskset.c
index 1135c53..ea6d5ec 100644
--- a/system/taskset/taskset.c
+++ b/system/taskset/taskset.c
@@ -31,6 +31,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <sched.h>
+#include <assert.h>
 #include <errno.h>
 #include <string.h>
 
diff --git a/testing/getprime/getprime_main.c b/testing/getprime/getprime_main.c
index b72b50e..5b219bc 100644
--- a/testing/getprime/getprime_main.c
+++ b/testing/getprime/getprime_main.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * apps/testing/getprime_main.c
+ * apps/testing/getprime/getprime_main.c
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <pthread.h>
 #include <time.h>
+#include <assert.h>
 
 /****************************************************************************
  * Pre-processor Definitions