You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/02/03 13:42:47 UTC

[incubator-nuttx-apps] 01/01: Run all files modified by pr45 through nxstyle.

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

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

commit 724a34bd3b68674e75d88af1e7a99b3ec7675c0d
Author: Gregory Nutt <gn...@nuttx.org>
AuthorDate: Mon Feb 3 07:35:37 2020 -0600

    Run all files modified by pr45 through nxstyle.
---
 examples/nxterm/nxterm_main.c     | 124 ++++++++++++++++++++------------------
 netutils/telnetd/telnetd_daemon.c |   5 +-
 nshlib/nsh_telnetlogin.c          |   4 +-
 system/nsh/nsh_main.c             |  13 ++--
 4 files changed, 79 insertions(+), 67 deletions(-)

diff --git a/examples/nxterm/nxterm_main.c b/examples/nxterm/nxterm_main.c
index 578836d..0384630 100644
--- a/examples/nxterm/nxterm_main.c
+++ b/examples/nxterm/nxterm_main.c
@@ -131,53 +131,54 @@ static int nxterm_initialize(void)
 #ifdef CONFIG_VNCSERVER
       /* Setup the VNC server to support keyboard/mouse inputs */
 
-       struct boardioc_vncstart_s vnc =
-       {
-         0, g_nxterm_vars.hnx
-       };
-
-       ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
-       if (ret < 0)
-         {
-           printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
-           nx_disconnect(g_nxterm_vars.hnx);
-           return ERROR;
-         }
+      struct boardioc_vncstart_s vnc =
+      {
+        0, g_nxterm_vars.hnx
+      };
+
+      ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
+      if (ret < 0)
+        {
+          printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
+          nx_disconnect(g_nxterm_vars.hnx);
+          return ERROR;
+        }
 #endif
 
-       /* Start a separate thread to listen for server events.  This is probably
-        * the least efficient way to do this, but it makes this example flow more
-        * smoothly.
-        */
-
-       pthread_attr_init(&attr);
-       param.sched_priority = CONFIG_EXAMPLES_NXTERM_LISTENERPRIO;
-       pthread_attr_setschedparam(&attr, &param);
-       pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_NXTERM_STACKSIZE);
-
-       ret = pthread_create(&thread, &attr, nxterm_listener, NULL);
-       if (ret != 0)
-         {
-            printf("nxterm_initialize: pthread_create failed: %d\n", ret);
-            return ERROR;
-         }
-
-       /* Don't return until we are connected to the server */
-
-       while (!g_nxterm_vars.connected)
-         {
-           /* Wait for the listener thread to wake us up when we really
-            * are connected.
-            */
-
-           sem_wait(&g_nxterm_vars.eventsem);
-         }
+      /* Start a separate thread to listen for server events.  This is probably
+       * the least efficient way to do this, but it makes this example flow more
+       * smoothly.
+       */
+
+      pthread_attr_init(&attr);
+      param.sched_priority = CONFIG_EXAMPLES_NXTERM_LISTENERPRIO;
+      pthread_attr_setschedparam(&attr, &param);
+      pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_NXTERM_STACKSIZE);
+
+      ret = pthread_create(&thread, &attr, nxterm_listener, NULL);
+      if (ret != 0)
+        {
+          printf("nxterm_initialize: pthread_create failed: %d\n", ret);
+          return ERROR;
+        }
+
+      /* Don't return until we are connected to the server */
+
+      while (!g_nxterm_vars.connected)
+        {
+          /* Wait for the listener thread to wake us up when we really
+           * are connected.
+           */
+
+          sem_wait(&g_nxterm_vars.eventsem);
+        }
     }
   else
     {
       printf("nxterm_initialize: nx_connect failed: %d\n", errno);
       return ERROR;
     }
+
   return OK;
 }
 
@@ -223,6 +224,7 @@ int main(int argc, FAR char *argv[])
   int ret;
 
   /* General Initialization *************************************************/
+
   /* Reset all global data */
 
   printf("nxterm_main: Started\n");
@@ -235,6 +237,7 @@ int main(int argc, FAR char *argv[])
 #endif
 
   /* NSH Initialization *****************************************************/
+
   /* Initialize the NSH library */
 
   printf("nxterm_main: Initialize NSH\n");
@@ -248,14 +251,16 @@ int main(int argc, FAR char *argv[])
   ret = nsh_telnetstart(AF_UNSPEC);
   if (ret < 0)
     {
-     /* The daemon is NOT running.  Report the error then fail...
-      * either with the serial console up or just exiting.
-      */
+      /* The daemon is NOT running.  Report the error then fail...
+       * either with the serial console up or just exiting.
+       */
 
-     fprintf(stderr, "ERROR: Failed to start TELNET daemon: %d\n", ret);
-   }
+      fprintf(stderr, "ERROR: Failed to start TELNET daemon: %d\n", ret);
+    }
 #endif
+
   /* NX Initialization ******************************************************/
+
   /* Initialize NX */
 
   printf("nxterm_main: Initialize NX\n");
@@ -281,6 +286,7 @@ int main(int argc, FAR char *argv[])
     }
 
   /* Window Configuration ***************************************************/
+
   /* Create a window */
 
   printf("nxterm_main: Create window\n");
@@ -352,7 +358,8 @@ int main(int argc, FAR char *argv[])
 
   sleep(2);
 
-  /* NxTerm Configuration ************************************************/
+  /* NxTerm Configuration ***************************************************/
+
   /* Use the window to create an NX console */
 
   g_nxterm_vars.wndo.wcolor[0] = CONFIG_EXAMPLES_NXTERM_WCOLOR;
@@ -392,12 +399,14 @@ int main(int argc, FAR char *argv[])
     }
 
   /* Start Console Task *****************************************************/
+
   /* Now re-direct stdout and stderr so that they use the NX console driver.
-   * Note that stdin is retained (file descriptor 0, probably the serial console).
-    */
+   * Note that stdin is retained (file descriptor 0, probably the serial
+   * console).
+   */
 
-   printf("nxterm_main: Starting the console task\n");
-   fflush(stdout);
+  printf("nxterm_main: Starting the console task\n");
+  fflush(stdout);
 
   fflush(stdout);
   fflush(stderr);
@@ -408,19 +417,19 @@ int main(int argc, FAR char *argv[])
   dup2(fd, 1);
   dup2(fd, 2);
 
-   /* And we can close our original driver file descriptor */
+  /* And we can close our original driver file descriptor */
 
-   close(fd);
+  close(fd);
 
-   /* And start the console task.  It will inherit stdin, stdout, and stderr
-    * from this task.
-    */
+  /* And start the console task.  It will inherit stdin, stdout, and stderr
+   * from this task.
+   */
 
-   g_nxterm_vars.pid = task_create("NxTerm", CONFIG_EXAMPLES_NXTERM_PRIO,
+  g_nxterm_vars.pid = task_create("NxTerm", CONFIG_EXAMPLES_NXTERM_PRIO,
                                   CONFIG_EXAMPLES_NXTERM_STACKSIZE,
                                   nxterm_task, NULL);
-   DEBUGASSERT(g_nxterm_vars.pid > 0);
-   return EXIT_SUCCESS;
+  DEBUGASSERT(g_nxterm_vars.pid > 0);
+  return EXIT_SUCCESS;
 
   /* Error Exits ************************************************************/
 
@@ -431,6 +440,7 @@ errout_with_hwnd:
   nxtk_closewindow(g_nxterm_vars.hwnd);
 
 errout_with_nx:
+
   /* Disconnect from the server */
 
   nx_disconnect(g_nxterm_vars.hnx);
diff --git a/netutils/telnetd/telnetd_daemon.c b/netutils/telnetd/telnetd_daemon.c
index 3be5b51..776460f 100644
--- a/netutils/telnetd/telnetd_daemon.c
+++ b/netutils/telnetd/telnetd_daemon.c
@@ -179,7 +179,8 @@ static int telnetd_daemon(int argc, FAR char *argv[])
   /* Set socket to reuse address */
 
   optval = 1;
-  if (setsockopt(listensd, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, sizeof(int)) < 0)
+  if (setsockopt(listensd, SOL_SOCKET, SO_REUSEADDR,
+                 (FAR void *)&optval, sizeof(int)) < 0)
     {
       nerr("ERROR: setsockopt SO_REUSEADDR failure: %d\n", errno);
       goto errout_with_socket;
@@ -237,7 +238,7 @@ static int telnetd_daemon(int argc, FAR char *argv[])
 
   /* Begin accepting connections */
 
-  for (;;)
+  for (; ; )
     {
       socklen_t accptlen;
 
diff --git a/nshlib/nsh_telnetlogin.c b/nshlib/nsh_telnetlogin.c
index b2db2e3..80d6b33 100644
--- a/nshlib/nsh_telnetlogin.c
+++ b/nshlib/nsh_telnetlogin.c
@@ -149,9 +149,9 @@ static void nsh_telnettoken(FAR struct console_stdio_s *pstate,
 
       else if (isspace(*endp1))
         {
-         /* Break out... endp1 points to first while space encountered */
+          /* Break out... endp1 points to first while space encountered */
 
-          break;
+           break;
         }
     }
 
diff --git a/system/nsh/nsh_main.c b/system/nsh/nsh_main.c
index eeb9cb9..7ebcf80 100644
--- a/system/nsh/nsh_main.c
+++ b/system/nsh/nsh_main.c
@@ -166,13 +166,13 @@ static int nsh_task(void)
   ret = nsh_telnetstart(AF_UNSPEC);
   if (ret < 0)
     {
-     /* The daemon is NOT running.  Report the error then fail...
-      * either with the serial console up or just exiting.
-      */
+      /* The daemon is NOT running.  Report the error then fail...
+       * either with the serial console up or just exiting.
+       */
 
-     fprintf(stderr, "ERROR: Failed to start TELNET daemon: %d\n", ret);
-     exitval = 1;
-   }
+      fprintf(stderr, "ERROR: Failed to start TELNET daemon: %d\n", ret);
+      exitval = 1;
+    }
 #endif
 
 #ifdef CONFIG_NSH_CONSOLE
@@ -232,6 +232,7 @@ int main(int argc, FAR char *argv[])
     {
       return nsh_system(argc, argv);
     }
+  else
 #endif
     {
       return nsh_task();