diff --git a/include/nshlib/nshlib.h b/include/nshlib/nshlib.h index 1e0db818f..b22dfb509 100644 --- a/include/nshlib/nshlib.h +++ b/include/nshlib/nshlib.h @@ -47,8 +47,9 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -/* If a USB device is selected for the NSH console then we need to handle some - * special start-up conditions. + +/* If a USB device is selected for the NSH console then we need to handle + * some special start-up conditions. */ #undef HAVE_USB_CONSOLE @@ -138,7 +139,7 @@ void nsh_initialize(void); * ****************************************************************************/ -int nsh_consolemain(int argc, char *argv[]); +int nsh_consolemain(int argc, FAR char *argv[]); /**************************************************************************** * Name: nsh_telnetstart @@ -226,7 +227,7 @@ int platform_user_verify(FAR const char *username, FAR const char *password); * ****************************************************************************/ -int nsh_system(int argc, char *argv[]); +int nsh_system(int argc, FAR char *argv[]); #undef EXTERN #ifdef __cplusplus diff --git a/nshlib/nsh_altconsole.c b/nshlib/nsh_altconsole.c index b6996347b..c0570c70f 100644 --- a/nshlib/nsh_altconsole.c +++ b/nshlib/nsh_altconsole.c @@ -78,7 +78,7 @@ static int nsh_clone_console(FAR struct console_stdio_s *pstate) return -ENODEV; } - /* Close stderr: note we only close stderr if we opened the alternative one */ + /* Close stderr: we only close stderr if we opened the alternative one */ fclose(stderr); @@ -101,7 +101,7 @@ static int nsh_clone_console(FAR struct console_stdio_s *pstate) return -ENODEV; } - /* Close stdout: note we only close stdout if we opened the alternative one */ + /* Close stdout: we only close stdout if we opened the alternative one */ fclose(stdout); @@ -202,7 +202,7 @@ static int nsh_wait_inputdev(FAR struct console_stdio_s *pstate, } while (fd < 0); - /* Close stdin: note we only closed stdin if we opened the alternative one */ + /* Close stdin: we only closed stdin if we opened the alternative one */ fclose(stdin); @@ -212,7 +212,7 @@ static int nsh_wait_inputdev(FAR struct console_stdio_s *pstate, if (fd != 0) { - /* No.. Dup the fd to create standard fd 0. stdin should not know. */ + /* No.. Dup the fd to create standard fd 0. stdin should not know. */ dup2(fd, 0); @@ -266,7 +266,7 @@ static int nsh_wait_inputdev(FAR struct console_stdio_s *pstate, * ****************************************************************************/ -int nsh_consolemain(int argc, char *argv[]) +int nsh_consolemain(int argc, FAR char *argv[]) { FAR struct console_stdio_s *pstate = nsh_newconsole(); FAR const char *msg; @@ -280,7 +280,9 @@ int nsh_consolemain(int argc, char *argv[]) usbtrace_enable(TRACE_BITSET); #endif - /* Execute the one-time start-up script. Any output will go to /dev/console. */ + /* Execute the one-time start-up script. + * Any output will go to /dev/console. + */ #ifdef CONFIG_NSH_ROMFSETC nsh_initscript(&pstate->cn_vtbl); diff --git a/nshlib/nsh_consolemain.c b/nshlib/nsh_consolemain.c index 84f8275d9..59b5d7eba 100644 --- a/nshlib/nsh_consolemain.c +++ b/nshlib/nsh_consolemain.c @@ -79,7 +79,7 @@ * ****************************************************************************/ -int nsh_consolemain(int argc, char *argv[]) +int nsh_consolemain(int argc, FAR char *argv[]) { FAR struct console_stdio_s *pstate = nsh_newconsole(); int ret; diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c index bd8a55f8c..3008c040f 100644 --- a/nshlib/nsh_fscmds.c +++ b/nshlib/nsh_fscmds.c @@ -149,7 +149,7 @@ static int ls_handler(FAR struct nsh_vtbl_s *vtbl, FAR const char *dirpath, } else { - /* A NULL entryp signifies that we are running ls on a single file */ + /* NULL entry signifies that we are running ls on a single file */ ret = stat(dirpath, &buf); } @@ -339,7 +339,7 @@ static int ls_recursive(FAR struct nsh_vtbl_s *vtbl, const char *dirpath, { int ret = OK; - /* Is this entry a directory (and not one of the special directories, . and ..)? */ + /* Is this entry a directory (not a special directories, e.g. . and ..)? */ if (DIRENT_ISDIRECTORY(entryp->d_type) && !ls_specialdir(entryp->d_name)) { @@ -536,7 +536,9 @@ int cmd_cp(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) if (S_ISDIR(buf.st_mode)) { - /* Yes, it is a directory. Remove any trailing '/' characters from the path */ + /* Yes, it is a directory. + * Remove any trailing '/' characters from the path + */ nsh_trimdir(destpath); @@ -728,7 +730,9 @@ int cmd_losetup(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) } } - /* If a bad argument was encountered, then return without processing the command */ + /* If a bad argument was encountered, + * then return without processing the command + */ if (badarg) { @@ -898,7 +902,9 @@ int cmd_losmart(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) } } - /* If a bad argument was encountered, then return without processing the command */ + /* If a bad argument was encountered, + * then return without processing the command + */ if (badarg) { @@ -1105,7 +1111,9 @@ int cmd_ls(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) } } - /* If a bad argument was encountered, then return without processing the command */ + /* If a bad argument was encountered, + * then return without processing the command + */ if (badarg) { @@ -1269,7 +1277,9 @@ int cmd_mkfatfs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) } } - /* If a bad argument was encountered, then return without processing the command */ + /* If a bad argument was encountered, + * then return without processing the command + */ if (badarg) { @@ -1392,7 +1402,9 @@ int cmd_mkrd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) } } - /* If a bad argument was encountered, then return without processing the command */ + /* If a bad argument was encountered, + * then return without processing the command + */ if (badarg) { diff --git a/nshlib/nsh_script.c b/nshlib/nsh_script.c index 4a12b44f6..35231a350 100644 --- a/nshlib/nsh_script.c +++ b/nshlib/nsh_script.c @@ -65,7 +65,7 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, FAR char *pret; int ret = ERROR; - /* The path to the script may be relative to the current working directory */ + /* The path to the script may relative to the current working directory */ fullpath = nsh_getfullpath(vtbl, path); if (!fullpath) @@ -137,7 +137,7 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, if ((vtbl->np.np_flags & NSH_PFLAG_SILENT) == 0) { - nsh_output(vtbl,"%s", buffer); + nsh_output(vtbl, "%s", buffer); } ret = nsh_parse(vtbl, buffer); diff --git a/nshlib/nsh_session.c b/nshlib/nsh_session.c index 00aadcd50..329e3a7fc 100644 --- a/nshlib/nsh_session.c +++ b/nshlib/nsh_session.c @@ -130,7 +130,9 @@ int nsh_session(FAR struct console_stdio_s *pstate, bool login) for (; ; ) { - /* For the case of debugging the USB console... dump collected USB trace data */ + /* For the case of debugging the USB console... + * dump collected USB trace data + */ #ifdef CONFIG_NSH_USBDEV_TRACE nsh_usbtrace(); diff --git a/nshlib/nsh_stdsession.c b/nshlib/nsh_stdsession.c index e5f1e030f..1a2c6c391 100644 --- a/nshlib/nsh_stdsession.c +++ b/nshlib/nsh_stdsession.c @@ -120,7 +120,9 @@ int nsh_session(FAR struct console_stdio_s *pstate, bool login) for (; ; ) { - /* For the case of debugging the USB console... dump collected USB trace data */ + /* For the case of debugging the USB console... + * dump collected USB trace data + */ #ifdef CONFIG_NSH_USBDEV_TRACE nsh_usbtrace(); diff --git a/nshlib/nsh_system.c b/nshlib/nsh_system.c index e866660dd..83fa347b3 100644 --- a/nshlib/nsh_system.c +++ b/nshlib/nsh_system.c @@ -70,7 +70,7 @@ * ****************************************************************************/ -int nsh_system(int argc, char *argv[]) +int nsh_system(int argc, FAR char *argv[]) { FAR struct console_stdio_s *pstate = nsh_newconsole(); FAR struct nsh_vtbl_s *vtbl; diff --git a/nshlib/nsh_telnetd.c b/nshlib/nsh_telnetd.c index a1685492a..b2a75dc00 100644 --- a/nshlib/nsh_telnetd.c +++ b/nshlib/nsh_telnetd.c @@ -257,10 +257,10 @@ int nsh_telnetstart(sa_family_t family) usbtrace_enable(TRACE_BITSET); #endif - /* Execute the startup script. If standard console is also defined, then - * we will not bother with the initscript here (although it is safe to - * call nshinitscript multiple times). - */ + /* Execute the startup script. If standard console is also defined, + * then we will not bother with the initscript here (although it is + * safe to call nshinitscript multiple times). + */ #if defined(CONFIG_NSH_ROMFSETC) && !defined(CONFIG_NSH_CONSOLE) nsh_initscript(vtbl); @@ -286,7 +286,8 @@ int nsh_telnetstart(sa_family_t family) ret = telnetd_start(&config); if (ret < 0) { - _err("ERROR: Failed to start the Telnet IPv4 daemon: %d\n", ret); + _err("ERROR: Failed to start the Telnet IPv4 daemon: %d\n", + ret); } else { @@ -302,7 +303,8 @@ int nsh_telnetstart(sa_family_t family) ret = telnetd_start(&config); if (ret < 0) { - _err("ERROR: Failed to start the Telnet IPv6 daemon: %d\n", ret); + _err("ERROR: Failed to start the Telnet IPv6 daemon: %d\n", + ret); } else { @@ -328,11 +330,11 @@ int nsh_telnetstart(sa_family_t family) * nsh_telnetstart() or it may be started from the NSH command line using * this telnetd command. * - * Normally this command would be suppressed with CONFIG_NSH_DISABLE_TELNETD - * because the Telnet daemon is automatically started in nsh_main.c. The - * exception is when CONFIG_NETINIT_NETLOCAL is selected. IN that case, the - * network is not enabled at initialization but rather must be enabled from - * the NSH command line or via other applications. + * This command would be suppressed with CONFIG_NSH_DISABLE_TELNETD + * normally because the Telnet daemon is automatically started in + * nsh_main.c. The exception is when CONFIG_NETINIT_NETLOCAL is selected. + * IN that case, the network is not enabled at initialization but rather + * must be enabled from the NSH command line or via other applications. * * In that case, calling nsh_telnetstart() before the the network is * initialized will fail. diff --git a/nshlib/nsh_usbconsole.c b/nshlib/nsh_usbconsole.c index c60d96508..b018773e1 100644 --- a/nshlib/nsh_usbconsole.c +++ b/nshlib/nsh_usbconsole.c @@ -89,9 +89,10 @@ static void nsh_configstdio(int fd) dup2(fd, 1); dup2(fd, 2); - /* fdopen to get the stdin, stdout and stderr streams. The following logic depends - * on the fact that the library layer will allocate FILEs in order. And since - * we closed stdin, stdout, and stderr above, that is what we should get. + /* fdopen to get the stdin, stdout and stderr streams. The following logic + * depends on the fact that the library layer will allocate FILEs in order. + * And since we closed stdin, stdout, and stderr above, that is what we + * should get. * * fd = 0 is stdin (read-only) * fd = 1 is stdout (write-only, append) @@ -129,9 +130,9 @@ static int nsh_nullstdio(void) */ if (fd > 2) - { + { close(fd); - } + } return OK; } @@ -171,8 +172,8 @@ restart: fd = open(CONFIG_NSH_USBCONDEV, O_RDWR); if (fd < 0) { - /* ENOTCONN means that the USB device is not yet connected. Anything - * else is bad. + /* ENOTCONN means that the USB device is not yet connected. + * Anything else is bad. */ DEBUGASSERT(errno == ENOTCONN); @@ -230,7 +231,7 @@ restart: nsh_configstdio(fd); - /* We can close the original file descriptor now (unless it was one of 0-2) */ + /* We can close the original file descriptor (unless it was one of 0-2) */ if (fd > 2) { @@ -257,7 +258,7 @@ restart: * operations to handle the cases where the session is lost when the * USB device is unplugged and restarted when the USB device is plugged * in again. - * + * * Input Parameters: * Standard task start-up arguments. These are not used. argc may be * zero and argv may be NULL. @@ -268,7 +269,7 @@ restart: * ****************************************************************************/ -int nsh_consolemain(int argc, char *argv[]) +int nsh_consolemain(int argc, FAR char *argv[]) { FAR struct console_stdio_s *pstate = nsh_newconsole(); struct boardioc_usbdev_ctrl_s ctrl; @@ -327,7 +328,7 @@ int nsh_consolemain(int argc, char *argv[]) /* Now loop, executing creating a session for each USB connection */ - for (;;) + for (; ; ) { /* Wait for the USB to be connected to the host and switch * standard I/O to the USB serial device. diff --git a/system/nsh/nsh_main.c b/system/nsh/nsh_main.c index 5c20be036..9571bbde0 100644 --- a/system/nsh/nsh_main.c +++ b/system/nsh/nsh_main.c @@ -177,7 +177,7 @@ int main(int argc, FAR char *argv[]) #endif #ifdef CONFIG_NSH_CONSOLE - /* If the serial console front end is selected, then run it on this thread */ + /* If the serial console front end is selected, run it on this thread */ ret = nsh_consolemain(0, NULL); diff --git a/system/popen/popen.c b/system/popen/popen.c index 99c0ed3c1..81fe8fc14 100644 --- a/system/popen/popen.c +++ b/system/popen/popen.c @@ -212,15 +212,16 @@ FILE *popen(FAR const char *command, FAR const char *mode) goto errout_with_actions; } - errcode = task_spawnattr_setstacksize(&attr, CONFIG_SYSTEM_POPEN_STACKSIZE); + errcode = task_spawnattr_setstacksize(&attr, + CONFIG_SYSTEM_POPEN_STACKSIZE); if (errcode != 0) { goto errout_with_actions; } - /* If robin robin scheduling is enabled, then set the scheduling policy - * of the new task to SCHED_RR before it has a chance to run. - */ + /* If robin robin scheduling is enabled, then set the scheduling policy + * of the new task to SCHED_RR before it has a chance to run. + */ #if CONFIG_RR_INTERVAL > 0 errcode = posix_spawnattr_setschedpolicy(&attr, SCHED_RR); @@ -332,22 +333,22 @@ errout: * waitpid() with a pid argument less than or equal to 0 or equal to the * process ID of the command line interpreter * - * Any other function not defined in this volume of IEEE Std 1003.1-2001 that - * could do one of the above + * Any other function not defined in this volume of IEEE Std 1003.1-2001 + * that could do one of the above * - * In any case, pclose() will not return before the child process created by - * popen() has terminated. + * In any case, pclose() will not return before the child process created + * by popen() has terminated. * - * If the command language interpreter cannot be executed, the child termination - * status returned by pclose() will be as if the command language interpreter - * terminated using exit(127) or _exit(127). + * If the command language interpreter cannot be executed, the child + * termination status returned by pclose() will be as if the command + * language interpreter terminated using exit(127) or _exit(127). * - * The pclose() function will not affect the termination status of any child of - * the calling process other than the one created by popen() for the associated - * stream. + * The pclose() function will not affect the termination status of any + * child of the calling process other than the one created by popen() for + * the associated stream. * - * If the argument stream to pclose() is not a pointer to a stream created by - * popen(), the result of pclose() is undefined. + * If the argument stream to pclose() is not a pointer to a stream created + * by popen(), the result of pclose() is undefined. * * Description: * stream - The stream reference returned by a previous call to popen() @@ -377,8 +378,8 @@ int pclose(FILE *stream) memcpy(original, &container->copy, sizeof(FILE)); - /* Then close the original and free the container (saving the PID of the shell - * process) + /* Then close the original and free the container (saving the PID of the + * shell process) */ fclose(original); @@ -389,13 +390,13 @@ int pclose(FILE *stream) #ifdef CONFIG_SCHED_WAITPID /* Wait for the shell to exit, retrieving the return value if available. */ - result = waitpid(shell, &status, 0); - if (result < 0) - { - /* The errno has already been set */ + result = waitpid(shell, &status, 0); + if (result < 0) + { + /* The errno has already been set */ - return ERROR; - } + return ERROR; + } return status; #else diff --git a/system/system/system.c b/system/system/system.c index 5f3f1828d..3f2435937 100644 --- a/system/system/system.c +++ b/system/system/system.c @@ -105,15 +105,16 @@ int system(FAR const char *cmd) goto errout_with_attrs; } - errcode = task_spawnattr_setstacksize(&attr, CONFIG_SYSTEM_SYSTEM_STACKSIZE); + errcode = task_spawnattr_setstacksize(&attr, + CONFIG_SYSTEM_SYSTEM_STACKSIZE); if (errcode != 0) { goto errout_with_attrs; } - /* If robin robin scheduling is enabled, then set the scheduling policy - * of the new task to SCHED_RR before it has a chance to run. - */ + /* If robin robin scheduling is enabled, then set the scheduling policy + * of the new task to SCHED_RR before it has a chance to run. + */ #if CONFIG_RR_INTERVAL > 0 errcode = posix_spawnattr_setschedpolicy(&attr, SCHED_RR);