You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/12/13 17:14:55 UTC

[incubator-nuttx-apps] 04/04: netutils/ftpc: fix incorrect comments, nxstyle

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/incubator-nuttx-apps.git

commit 2a11d60246e670261d74381f925f9e59244d560f
Author: Juha Niskanen <ju...@haltian.com>
AuthorDate: Sun Dec 13 17:35:40 2020 +0200

    netutils/ftpc: fix incorrect comments, nxstyle
    
    Signed-off-by: Juha Niskanen <ju...@haltian.com>
---
 include/netutils/ftpc.h       | 21 +++++++++++----------
 netutils/dhcpd/Makefile       |  2 +-
 netutils/ftpc/Makefile        |  2 --
 netutils/ftpc/ftpc_cmd.c      | 39 +++++++++++----------------------------
 netutils/ftpc/ftpc_listdir.c  | 25 ++++++++-----------------
 netutils/ftpc/ftpc_login.c    | 20 --------------------
 netutils/ftpc/ftpc_mkdir.c    | 20 --------------------
 netutils/ftpc/ftpc_rename.c   | 23 ++---------------------
 netutils/ftpc/ftpc_rmdir.c    | 21 +--------------------
 netutils/ftpc/ftpc_rpwd.c     | 23 ++---------------------
 netutils/ftpc/ftpc_transfer.c | 16 ----------------
 netutils/ftpc/ftpc_utils.c    | 23 ++++-------------------
 12 files changed, 40 insertions(+), 195 deletions(-)

diff --git a/include/netutils/ftpc.h b/include/netutils/ftpc.h
index 64c16a8..5b2dbab 100644
--- a/include/netutils/ftpc.h
+++ b/include/netutils/ftpc.h
@@ -1,5 +1,5 @@
 /****************************************************************************
- * apps/include/system/ftpc.h
+ * apps/include/netutils/ftpc.h
  *
  *   Copyright (C) 2011, 2015-2016 Gregory Nutt. All rights reserved.
  *   Author: Gregory Nutt <gn...@nuttx.org>
@@ -53,6 +53,7 @@
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
+
 /* Configuration ************************************************************/
 
 #ifndef CONFIG_FTP_DEFTIMEO
@@ -88,6 +89,7 @@
 #endif
 
 /* Interface arguments ******************************************************/
+
 /* These definitions describe how a put operation should be performed */
 
 #define FTPC_PUT_NORMAL      0  /* Just PUT the file on the server */
@@ -110,18 +112,15 @@
 /****************************************************************************
  * Public Types
  ****************************************************************************/
+
 /* This "handle" describes the FTP session */
 
 typedef FAR void *SESSION;
 
-/* This union provides information to connect to a host FTP server.
+/* This union provides socket address to connect to a host FTP server.
  *
- * addr - The IPv4 or IPv6 address of the FTP server (or the proxy) for the FTP
- *        server.
- * port - The port number on the FTP server to connect to (in host byte
- *        order).  This is usually port 21 for FTP.  You may set this
- *        value to zero to let FTPC select the default port number for
- *        you (it will use CONFIG_FTP_DEFPORT).
+ * in4, in6 - The IPv4 or IPv6 address of the FTP server (or the proxy)
+ *            for the FTP server.
  */
 
 union ftpc_sockaddr_u
@@ -181,8 +180,9 @@ extern "C"
 #endif
 
 /****************************************************************************
- * Public Functions
+ * Public Function Prototypes
  ****************************************************************************/
+
 /* Connection management ****************************************************/
 
 SESSION ftpc_connect(FAR union ftpc_sockaddr_u *server);
@@ -201,7 +201,8 @@ int ftpc_rmdir(SESSION handle, FAR const char *path);
 
 int ftpc_unlink(SESSION handle, FAR const char *path);
 int ftpc_chmod(SESSION handle, FAR const char *path, FAR const char *mode);
-int ftpc_rename(SESSION handle, FAR const char *oldname, FAR const char *newname);
+int ftpc_rename(SESSION handle, FAR const char *oldname,
+                FAR const char *newname);
 off_t ftpc_filesize(SESSION handle, FAR const char *path);
 time_t ftpc_filetime(SESSION handle, FAR const char *filename);
 
diff --git a/netutils/dhcpd/Makefile b/netutils/dhcpd/Makefile
index b393b32..515b774 100644
--- a/netutils/dhcpd/Makefile
+++ b/netutils/dhcpd/Makefile
@@ -35,7 +35,7 @@
 
 include $(APPDIR)/Make.defs
 
-# DHCP Daemn Library
+# DHCP Daemon Library
 
 ifeq ($(CONFIG_NET_UDP),y)
 CSRCS = dhcpd.c
diff --git a/netutils/ftpc/Makefile b/netutils/ftpc/Makefile
index 2396a35..bfa2ced 100644
--- a/netutils/ftpc/Makefile
+++ b/netutils/ftpc/Makefile
@@ -35,8 +35,6 @@
 
 include $(APPDIR)/Make.defs
 
-# DHCP Daemn Library
-
 ifeq ($(CONFIG_NET_TCP),y)
 # FTP connection management
 CSRCS += ftpc_connect.c ftpc_disconnect.c
diff --git a/netutils/ftpc/ftpc_cmd.c b/netutils/ftpc/ftpc_cmd.c
index d12a24b..ec85e5c 100644
--- a/netutils/ftpc/ftpc_cmd.c
+++ b/netutils/ftpc/ftpc_cmd.c
@@ -48,26 +48,6 @@
 #include "ftpc_internal.h"
 
 /****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
  * Private Functions
  ****************************************************************************/
 
@@ -106,8 +86,9 @@ static int ftpc_restore(struct ftpc_session_s *session)
 
           ftpc_reset(session);
         }
+
       return ret;
-  }
+    }
 
   return ERROR;
 }
@@ -136,15 +117,15 @@ int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...)
   /* Verify that we are still connected to the server */
 
   if (!ftpc_sockconnected(&session->cmd))
-  {
-    nwarn("WARNING: Cmd channel is not connected\n");
-    goto errout;
-  }
+    {
+      nwarn("WARNING: Cmd channel is not connected\n");
+      goto errout;
+    }
 
   /* Loop, reconnecting as necessary until the command is sent */
 
 #ifdef CONFIG_FTP_AUTORECONNECT
-  for (;;)
+  for (; ; )
 #endif
     {
       /* Send the command */
@@ -159,6 +140,7 @@ int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...)
               ret = ftpc_sockflush(&session->cmd);
             }
         }
+
       va_end(ap);
 
       /* Check for an error in sending the data */
@@ -167,7 +149,7 @@ int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...)
         {
           nerr("ERROR: Error sending cmd %s: %d\n", cmd, errno);
           goto errout;
-       }
+        }
 
       /* Get the response to the command */
 
@@ -176,7 +158,7 @@ int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...)
         {
           nerr("ERROR: Error getting reply: %d\n", errno);
           goto errout;
-       }
+        }
 
       /* Check for "421 Service not available, closing control connection" */
 
@@ -214,6 +196,7 @@ int ftpc_cmd(struct ftpc_session_s *session, const char *cmd, ...)
                       nwarn("WARNING: Failed to restore the connection");
                       goto errout;
                     }
+
                   continue;
                 }
             }
diff --git a/netutils/ftpc/ftpc_listdir.c b/netutils/ftpc/ftpc_listdir.c
index 60ff370..213ed22 100644
--- a/netutils/ftpc/ftpc_listdir.c
+++ b/netutils/ftpc/ftpc_listdir.c
@@ -52,24 +52,12 @@
 #include "ftpc_internal.h"
 
 /****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
  * Private Types
  ****************************************************************************/
 
 typedef void (*callback_t)(FAR const char *name, FAR void *arg);
 
 /****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
  * Private Functions
  ****************************************************************************/
 
@@ -111,8 +99,9 @@ static void ftpc_addname(FAR const char *name, FAR void *arg)
  *   sequence of pathnames. Each pathname is terminated by \r\n.
  *
  *   If a pathname starts with a slash, it represents the pathname. If a
- *   pathname does not start with a slash, it represents the pathname obtained
- *   by concatenating the pathname of the directory and the pathname.
+ *   pathname does not start with a slash, it represents the pathname
+ *   obtained by concatenating the pathname of the directory and the
+ *   pathname.
  *
  *   IF NLST of directory /pub produces foo\r\nbar\r\n, it refers to the
  *   pathnames /pub/foo and /pub/bar.
@@ -122,11 +111,11 @@ static void ftpc_addname(FAR const char *name, FAR void *arg)
 static void ftpc_nlstparse(FAR FILE *instream, callback_t callback,
                            FAR void *arg)
 {
-  char buffer[CONFIG_FTP_MAXPATH+1];
+  char buffer[CONFIG_FTP_MAXPATH + 1];
 
   /* Read every filename from the temporary file */
 
-  for (;;)
+  for (; ; )
     {
       /* Read the next line from the file */
 
@@ -145,6 +134,7 @@ static void ftpc_nlstparse(FAR FILE *instream, callback_t callback,
         {
           break;
         }
+
       ninfo("File: %s\n", buffer);
 
       /* Perform the callback operation */
@@ -265,7 +255,7 @@ static int ftpc_recvdir(FAR struct ftpc_session_s *session,
  *   expansion "~/xyz" and relative paths (abc/def) because we do have
  *   special knowledge about the home and current directories.  But otherwise
  *   the paths are expected to be pre-sanitized:  No . or .. in paths,
- *   no '//' in paths, etc.
+ *   no multiple consecutive '/' in paths, etc.
  *
  ****************************************************************************/
 
@@ -367,6 +357,7 @@ FAR struct ftpc_dirlist_s *ftpc_listdir(SESSION handle,
           nwarn("WARNING: Nothing found in directory\n");
           goto errout;
         }
+
       ninfo("nnames: %d\n", nnames);
 
       /* Allocate and initialize a directory container */
diff --git a/netutils/ftpc/ftpc_login.c b/netutils/ftpc/ftpc_login.c
index 6f9f534..7691ae4 100644
--- a/netutils/ftpc/ftpc_login.c
+++ b/netutils/ftpc/ftpc_login.c
@@ -33,26 +33,6 @@
 #include "ftpc_internal.h"
 
 /****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
  * Public Functions
  ****************************************************************************/
 
diff --git a/netutils/ftpc/ftpc_mkdir.c b/netutils/ftpc/ftpc_mkdir.c
index bd32121..15e93d3 100644
--- a/netutils/ftpc/ftpc_mkdir.c
+++ b/netutils/ftpc/ftpc_mkdir.c
@@ -47,26 +47,6 @@
 #include "ftpc_internal.h"
 
 /****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
  * Public Functions
  ****************************************************************************/
 
diff --git a/netutils/ftpc/ftpc_rename.c b/netutils/ftpc/ftpc_rename.c
index c5d735a..3b67671 100644
--- a/netutils/ftpc/ftpc_rename.c
+++ b/netutils/ftpc/ftpc_rename.c
@@ -47,26 +47,6 @@
 #include "ftpc_internal.h"
 
 /****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
  * Public Functions
  ****************************************************************************/
 
@@ -78,7 +58,8 @@
  *
  ****************************************************************************/
 
-int ftpc_rename(SESSION handle, FAR const char *oldname, FAR const char *newname)
+int ftpc_rename(SESSION handle, FAR const char *oldname,
+                FAR const char *newname)
 {
   FAR struct ftpc_session_s *session = (FAR struct ftpc_session_s *)handle;
   char *oldcopy;
diff --git a/netutils/ftpc/ftpc_rmdir.c b/netutils/ftpc/ftpc_rmdir.c
index 5f78ef2..d9ddbed 100644
--- a/netutils/ftpc/ftpc_rmdir.c
+++ b/netutils/ftpc/ftpc_rmdir.c
@@ -46,26 +46,6 @@
 #include "ftpc_internal.h"
 
 /****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
  * Public Functions
  ****************************************************************************/
 
@@ -76,6 +56,7 @@
  *   Deletes the named directory on the remote server.
  *
  ****************************************************************************/
+
 int ftpc_rmdir(SESSION handle, FAR const char *path)
 {
   FAR struct ftpc_session_s *session = (FAR struct ftpc_session_s *)handle;
diff --git a/netutils/ftpc/ftpc_rpwd.c b/netutils/ftpc/ftpc_rpwd.c
index 5c8e49e..db4d210 100644
--- a/netutils/ftpc/ftpc_rpwd.c
+++ b/netutils/ftpc/ftpc_rpwd.c
@@ -48,26 +48,6 @@
 #include "ftpc_internal.h"
 
 /****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
  * Public Functions
  ****************************************************************************/
 
@@ -103,6 +83,7 @@ FAR char *ftpc_rpwd(SESSION handle)
       nwarn("WARNING: Opening quote not found\n");
       return NULL;
     }
+
   start++;
 
   end = strchr(start, '\"');
@@ -133,7 +114,7 @@ FAR char *ftpc_rpwd(SESSION handle)
   memcpy(pwd, start, len);
   pwd[len] = '\0';
 
-  /* Remove any trailing slashes that the server may have added */
+  /* Remove any trailing slash that the server may have added */
 
   ftpc_stripslash(pwd);
 
diff --git a/netutils/ftpc/ftpc_transfer.c b/netutils/ftpc/ftpc_transfer.c
index b983a13..47f0d2e 100644
--- a/netutils/ftpc/ftpc_transfer.c
+++ b/netutils/ftpc/ftpc_transfer.c
@@ -57,22 +57,6 @@
 #include "ftpc_internal.h"
 
 /****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
  * Private Functions
  ****************************************************************************/
 
diff --git a/netutils/ftpc/ftpc_utils.c b/netutils/ftpc/ftpc_utils.c
index 90793d1..8dca41a 100644
--- a/netutils/ftpc/ftpc_utils.c
+++ b/netutils/ftpc/ftpc_utils.c
@@ -45,22 +45,6 @@
 #include "ftpc_internal.h"
 
 /****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
  * Private Functions
  ****************************************************************************/
 
@@ -139,6 +123,7 @@ FAR const char *ftpc_lpwd(void)
     {
       val = CONFIG_FTP_TMPDIR;
     }
+
   return val;
 #else
   return CONFIG_FTP_TMPDIR;
@@ -178,8 +163,8 @@ void ftpc_stripcrlf(FAR char *str)
  * Name: ftpc_stripslash
  *
  * Description:
- *   Strip any trailing slashes from a string (by overwriting them with NUL
- *   characters.
+ *   Strip single trailing slash from a string (by overwriting it with NUL
+ *   character).
  *
  ****************************************************************************/
 
@@ -223,7 +208,7 @@ FAR char *ftpc_dequote(FAR const char *str)
       /* Allocate space for a modifiable copy of the string */
 
       len      = strlen(str);
-      allocstr = (FAR char*)malloc(len + 1);
+      allocstr = (FAR char *)malloc(len + 1);
       if (allocstr)
         {
           /* Search the string */