Commit Graph

810 Commits

Author SHA1 Message Date
Xiang Xiao
28362eb6d1 nshlib: Remove fdopen for the stdin, stdout and stderr
not really need since these file stream should be opened automatically

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-12-16 07:53:38 +09:00
Masayuki Ishikawa
0c3ee06fb3 nshlib: Fix nsh_usbconsole.c
Summary:
- stdin/stdout/stderr are now preallocated in libc and fs_fd
  in file_struct are also initialized to -1
- So we need to call fdopen() for stdin again as we did before.
- Also, cn_outstream and cn_errstream are not needed to be set.
- See apps/nshlib/nsh_console.h as well

Impact:
- nsh_usbconsole.c only

Testing:
- Tested with stm32f4discovery:usbnsh

Signed-off-by: SUZUKI Keiji <zuki.ebetsu@gmail.com>
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2020-12-14 04:23:26 -06:00
chao.an
fe915679b1 style/Document: remove unnecessary trailing whitespace
N/A

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-28 12:20:10 +01:00
YAMAMOTO Takashi
d6b67eb05e nshlib/nsh_dbgcmds.c: Fix a few printf warnings 2020-11-09 04:10:59 -08:00
Subhra Sankha Sarkar
3b884cfb87 Fixing coding style issues for rest of nshlib directory - except for the false +ve nsh_timcmds.c 2020-11-02 13:30:18 +01:00
Masayuki Ishikawa
305bd0e448 nshlib: Fix nsh_configstdio() in nsh_usbconsole.c
Summary:
- This commit fixes nsh_configstdio() to setup stdout and stderr

Impact:
- Affect nsh_usbconsole only

Testing:
- Tested with stm32f4discovery:usbnsh

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2020-10-29 20:43:59 +09:00
Xiang Xiao
e76ab9c868 Remove all fclose with stdin, stdout and stderr
since it is wrong to close the builtin stream and specially note
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fclose.html:

Since after the call to fclose() any use of stream results in
undefined behavior, fclose() should not be used on stdin, stdout,
or stderr except immediately before process termination (see XBD
Process Termination), so as to avoid triggering undefined behavior
in other standard interfaces that rely on these streams. If there
are any atexit() handlers registered by the application, such a
call to fclose() should not occur until the last handler is
finishing. Once fclose() has been used to close stdin, stdout, or
stderr, there is no standard way to reopen any of these streams.

and it is also unnecessary because the stream always get flushed.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-10-29 20:43:59 +09:00
Subhra Sankha Sarkar
36b1be0609 Fixed coding std issues 2020-10-29 04:20:17 -07:00
Subhra Sankha Sarkar
76e58d9e55 Fixed coding std violations in nsh_fsutils.h 2020-10-28 06:43:43 -07:00
Subhra Sankha Sarkar
0d74608b2c Fixed build issues 2020-10-28 05:57:47 -07:00
Subhra Sankha Sarkar
23ec80fa30 Addressed review comments from @v01d and @xiaoxiang781216 2020-10-28 05:57:47 -07:00
YAMAMOTO Takashi
aa0aa73250 nsh_netcmds.c: Adapt to the new webclient api
As a bonus, check and report errors from write().

tested as: "nsh> wget http://example.com/"
2020-10-01 15:32:25 +08:00
Xiang Xiao
ecae66fe59 Replace all CONFIG_NFILE_STREAMS with CONFIG_FILE_STREAM
follow up the kernel side change

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ic27ad65d7cc2ea570921e0c17098dcb6bfe1893a
2020-09-11 17:57:58 +08:00
spiriou
06c7f06b1d nshlib: remove NSH_HAVE_WRITABLE_MOUNTPOINT to enable mkrd again 2020-08-23 11:38:08 -07:00
Xiang Xiao
9d80399bd5 nsh: Accept the command line arguments like sh
Usage: nsh [<script-path>|-c <command>]

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ifb76b27e7fd09d26b1f6e48c391fed0972018041
2020-08-19 14:32:53 -07:00
Xiang Xiao
74c506b4d1 nsh: Don't check CONFIG_NFILE_STREAMS for mkdir/rename/rmdir/fs_unlink
since these function don't depend on standard input/output function

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I320659eff933d49c4872e43320fa30696d8b8a54
2020-08-17 00:16:21 +01:00
Masayuki Ishikawa
7f48576218 nshlib: Fix memory corruption in nsh_parse.c
Summary:
- Fix memory corruption when pthread_create() failed in nsh_execute()

Impact:

- nsh builtin command execution in background with errors

Testing:

- Tested with hifive1-revb:nsh
- Set CONFIG_MAX_TASKS=4
- Run 'sleep 1000 &' in 3 times will cause pthread_create error
- Run free, ps command

Reported-by: Yoshinori Sugino <ysgn0101@gmail.com>
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2020-08-11 13:57:02 +02:00
Maciej Wójcik
21049ece6e Rewritten READMEs to Markdown 2020-07-25 01:01:51 -07:00
Maciej Wójcik
51e6645f71 Rename README and README.txt to README.md 2020-07-25 01:01:51 -07:00
Xiang Xiao
942f32e22a Fix nxsytle warning
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I36099dc6c07c7ada2f9fcb06fe0267b8d213a61a
2020-07-12 13:56:00 +01:00
Xiang Xiao
deaa6c5b7b build: Replace $(TOPDIR)/Make.defs with $(APPDIR)/Make.defs
and move NUTTXLIB defintion to the common place

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-07-09 15:17:37 -03:00
Xiang Xiao
95d7e9b191 nshlib: Call symlink if user pass -s for ln command
since NuttX kernel support really support symlink not link.
Note: link equal symlink now because the hard link doesn't support yet

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I47437f5fd8bbab3a5539d0eb6f690f633b422345
2020-07-01 11:59:00 +02:00
Gregory Nutt
192273da2e Revert "nshlib: remove the dependency of date on RTC"
This is a bad change.  It has been show to cause an increase in size by around 2.3Kb in minimal configurations that cannot tolerate that massive size increase.

This reverts commit 4adb83c754.
2020-06-24 16:07:55 -07:00
Xiang Xiao
69f013e74e build: Remve the unnecessary .gitignore
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-23 15:56:35 +01:00
Xiang Xiao
ead498a788 build: Remove the workaround for the inexistence of .config/Make.defs
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-21 17:43:42 +01:00
Masayuki Ishikawa
bd47c468c5 nshlib: Introduce CONFIG_NSH_WGET_BUFF_SIZE
Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2020-05-18 20:00:28 -06:00
chao.an
898c1ce4d2 Revert "This critical behavior was broken by this commit:"
This reverts commit 9b06b508f9.

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-05-18 06:53:57 -06:00
Gregory Nutt
4f54a75c48 apps/nshlib/nsh_parse.c: Add some comments.
Add some comments to nsh_parse.c emphasizing the reason that things are done in the order that they are.  Perhaps such comments will avoid similar breakage in the future.
2020-05-18 10:03:17 +08:00
Gregory Nutt
60428baed6 apps/nshlib/nsh_parse.c: Run through nxstyle. 2020-05-17 23:38:05 +01:00
Gregory Nutt
9b06b508f9 This critical behavior was broken by this commit:
commit 9a28ccf836
    Author: chao.an <anchao@xiaomi.com>
    Date:   Fri Feb 21 09:54:47 2020 +0800

        nsh/parse: try the builtin configuration first

        In the case of enable the BUILTIN_APPS/FILE_APPS at the same time,
        try the builtin list first to ensure that the relevant configuration
        (stacksize, priority) can be set normally.

This commit breaks the feature because it changes the order to that the built-in application is tried first.  Hence, the version on the file system will never replace the built-in version.

That commit must be reverted in order to restore the correct functionality.

    Revert "nsh/parse: try the builtin configuration first"

    This reverts commit 9a28ccf836.
2020-05-17 23:38:05 +01:00
Gregory Nutt
b2d8c501f6 Remove use of set_errno() from application code.
The normal assignment errno = errcode should work fine now.
2020-05-07 22:23:19 +01:00
Xiang Xiao
e72608e0d8 Fix nxstyle issue
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-05-02 09:45:44 -06:00
Ouss4
679896328d nshlib/nsh_telnetd.c: Print the end line of the MOTD correctly. 2020-04-29 14:46:13 +08:00
Juha Niskanen
f18b283ea8 nshlib: add printf command to README.TXT
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-04-21 08:02:32 -06:00
Xiang Xiao
a82d74b8a1 nshlib: Call BOARDIOC_FINALINIT in nsh_telnetstart if CONFIG_NSH_CONSOLE not define
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-19 10:15:23 -06:00
Xiang Xiao
b1b45de3db Revert "nshlib: Move BOARDIOC_FINALINIT into nsh_initscript"
This reverts commit ac5632fc50.
2020-04-19 10:15:23 -06:00
Xiang Xiao
650b58d6b2 nshlib: Fix nxstyle warning
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-19 08:07:06 -06:00
Xiang Xiao
3f9302561c nshlib: Enhance nsh to execute the shell script
and support the interactive shell too

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-19 08:07:06 -06:00
Xiang Xiao
d307758c3c nshlib: Rename 'sh' command to 'source' command
since this command change the parent environment variable and
add new '.' command which has the same functionality as 'source'

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-19 08:07:06 -06:00
Xiang Xiao
9ab5e2ff45 nshlib: Add login argument to nsh_session for controling the login process
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-19 08:07:06 -06:00
Xiang Xiao
9dbdc73df6 nshlib: Reset NSH_NP_SET_OPTIONS_INIT in nsh_initscript
to ensure the reset get executed in all console implementation

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-19 08:07:06 -06:00
Xiang Xiao
ac5632fc50 nshlib: Move BOARDIOC_FINALINIT into nsh_initscript
1.Avoid the code duplication
2.Call BOARDIOC_FINALINIT onnce and only once
3.Ensure BOARDIOC_FINALINIT get called in all case

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-19 08:07:06 -06:00
Xiang Xiao
6c4dc44e04 nshlib: Ensure nsh_initscript always follow usbtrace_enable immediately
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-19 08:07:06 -06:00
chao.an
4adb83c754 nshlib: remove the dependency of date on RTC
Change-Id: I98bd022fdc901ecb4e2e45a0faf779d83c260844
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-04-18 07:35:40 -06:00
Alan C. Assis
6e403fc343 Fix remaining issues with nxstyle 2020-04-16 20:39:47 -06:00
Alan C. Assis
d10eb2ae3a Fix nxstyle issue for Juha patch 2020-04-16 20:39:47 -06:00
Juha Niskanen
89b981bdb6 nshlib/nsh_codeccmd.c: fix potential NULL dereference and check malloc return values 2020-04-16 20:39:47 -06:00
Xiang Xiao
8fd8aad5c4 Fix nxstyle warning
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-04-13 08:32:42 -06:00
Xiang Xiao
5720d72b71 apps: Fix the nightly build warning
src/cwindowfactory.cxx: In member function 'void Twm4Nx::CWindowFactory::redrawIcons(const nxgl_rect_s*)':
src/cwindowfactory.cxx:461:38: warning: 'iconPos.nxgl_point_s::y' may be used uninitialized in this function [-Wmaybe-uninitialized]
  461 |           iconBounds.pt2.y = iconPos.y + iconSize.h - 1;
      |                              ~~~~~~~~^
src/cwindowfactory.cxx:460:38: warning: 'iconPos.nxgl_point_s::x' may be used uninitialized in this function [-Wmaybe-uninitialized]
  460 |           iconBounds.pt2.x = iconPos.x + iconSize.w - 1;
      |                              ~~~~~~~~^

nsh_netcmds.c:424:20: warning: 'nsh_addrconv' defined but not used [-Wunused-function]
 static inline bool nsh_addrconv(FAR const char *hwstr,
                    ^
nsh_netcmds.c:446:20: warning: 'nsh_sethwaddr' defined but not used [-Wunused-function]
 static inline void nsh_sethwaddr(FAR const char *ifname,
                    ^

nsh_envcmds.c:94:21: warning: 'nsh_getdirpath' defined but not used [-Wunused-function]
 static inline char *nsh_getdirpath(FAR struct nsh_vtbl_s *vtbl,
                     ^

In file included from bas.c:84:0:
bas.c: In function 'bas_interpreter':
bas_error.h:110:37: warning: left-hand operand of comma expression has no effect [-Wunused-value]
 #define NOSUCHLINE         STATIC+40, _("No such line")
                                     ^
bas.c:2425:52: note: in expansion of macro 'NOSUCHLINE'
                           FS_putChars(STDCHANNEL, (NOSUCHLINE));
                                                    ^~~~~~~~~~
bas_fs.c:107:22: warning: 'g_vt100_colormap' defined but not used [-Wunused-const-variable=]
 static const uint8_t g_vt100_colormap[8] =
                      ^~~~~~~~~~~~~~~~
<stdout>:4048:16: warning: 'input' defined but not used [-Wunused-function]

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I62610b4c90e67637250cbd0107c2935c8abc542f
2020-04-13 08:32:42 -06:00
chao.an
9968461c2b nsh/command: do not show the module application in built-in list
Change-Id: Ia6dd5dcf7d7eb829fde67c522f7ee2155a4051ce
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-04-03 15:59:45 +09:00