Summary:
Warning: /home/runner/work/nuttx/nuttx/nuttx/libs/libc/stdio/lib_remove.c:59:32: warning: Wrong column position of comment right of code
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
Summary:
When the deleted path is a file, the return value of get_errno is -EISDIR, so in Condition Two
(get_errno() ! = EPERM && /* .... . try to remove it. */
rmdir(path) ! = 0)
The judgment holds directly, so it can't actually execute to rmdir
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
"stdio/lib_dtoa_engine.c", line 102: error #166: invalid floating constant
if (x < MIN_MANT)
^
"stdio/lib_dtoa_engine.c", line 102: warning #1626-D: concatenation with "("
in macro "PASTE" does not create a valid token
if (x < MIN_MANT)
^
"stdio/lib_dtoa_engine.c", line 102: error #109: expression preceding
parentheses of apparent call must have (pointer-to-) function type
if (x < MIN_MANT)
^
"stdio/lib_dtoa_engine.c", line 107: error #166: invalid floating constant
if (y < MAX_MANT)
^
"stdio/lib_dtoa_engine.c", line 107: warning #1626-D: concatenation with "("
in macro "PASTE" does not create a valid token
if (y < MAX_MANT)
^
"stdio/lib_dtoa_engine.c", line 107: error #109: expression preceding
parentheses of apparent call must have (pointer-to-) function type
if (y < MAX_MANT)
^
"stdio/lib_dtoa_engine.c", line 119: error #166: invalid floating constant
if (y >= MIN_MANT)
^
"stdio/lib_dtoa_engine.c", line 119: warning #1626-D: concatenation with "("
in macro "PASTE" does not create a valid token
if (y >= MIN_MANT)
^
"stdio/lib_dtoa_engine.c", line 119: error #109: expression preceding
parentheses of apparent call must have (pointer-to-) function type
if (y >= MIN_MANT)
^
"stdio/lib_dtoa_engine.c", line 144: error #166: invalid floating constant
if (x >= MAX_MANT)
^
"stdio/lib_dtoa_engine.c", line 144: warning #1626-D: concatenation with "("
in macro "PASTE" does not create a valid token
if (x >= MAX_MANT)
^
"stdio/lib_dtoa_engine.c", line 144: error #109: expression preceding
parentheses of apparent call must have (pointer-to-) function type
if (x >= MAX_MANT)
^
"stdio/lib_dtoa_engine.c", line 153: error #166: invalid floating constant
uint64_t decimal = MIN_MANT_INT;
^
"stdio/lib_dtoa_engine.c", line 153: warning #1626-D: concatenation with "("
in macro "PASTE" does not create a valid token
uint64_t decimal = MIN_MANT_INT;
^
"stdio/lib_dtoa_engine.c", line 153: error #109: expression preceding
parentheses of apparent call must have (pointer-to-) function type
uint64_t decimal = MIN_MANT_INT;
Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
Adds support for POSIX interface open_memstream() that allows writing
to dynamic memory buffer stream. The stream is dynamically reallocated
as the buffer grows with initial size set to zero.
The caller has to free the buffer after the stream is closed.
The implementation uses fopencookie() for custom stream operations and
callbacks.
Signed-off-by: Michal Lenc <michallenc@seznam.cz>
Add support for POSIX interface fmemopen(). This interface open a memory
buffer as a stream and permits access to this buffer specified by mode.
This allows I/O operations to be performed on the memory buffer.
The implementation uses fopencookie() for custom stream operations and
callbacks.
Signed-off-by: Michal Lenc <michallenc@seznam.cz>
__dtoa is not used because currently NuttX uses other
function called __dtoa_engine() to do the same thing
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit adds support for custom stream via fopencookie function.
The function allows the programmer the create his own custom stream
for IO operations and hook his custom functions to it.
This is a non POSIX interface defined in Standard C library and implemented
according to it. The only difference is in usage of off_t instead of
off64_t. Programmer can use 64 bits offset if CONFIG_FS_LARGEFILE is
enabled. In that case off_t is defined as int64_t (int32_t otherwise).
Field fs_fd is removed from file_struct and fs_cookie is used instead
as a shared variable for file descriptor or user defined cookie.
The interface will be useful for future fmemopen implementation.
Signed-off-by: Michal Lenc <michallenc@seznam.cz>
both functions aren't suitable to be put into libc,
because they call the kernel internal functions directly.
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
If the gulp size in the stdio buffer the remaining user buffer size it will:
- Corrupt memory in dest (user memory) and
- Keep corrupting KERNEL memory via the stdio character buffer until the
whole system crashes, as the 'remaining' count underflows
This patch fixes this behavior.
libs/libc/stdio/lib_libgetstreams.c: C source, UTF-8 Unicode text
->
libs/libc/stdio/lib_libgetstreams.c: C source, ASCII text
Signed-off-by: chao an <anchao@xiaomi.com>
For "%e" conversion, the exponent always contains at least two digits.
That means if the value is zero, the exponent is 00, not 0.
Such as code:
printf(buffer, sizeof(buffer), "%e", 1.232323232323);
printf(buffer, sizeof(buffer), "%e", 12.32323232323);
printf(buffer, sizeof(buffer), "%e", 123.2323232323);
Expected output:
1.232323e+00
1.232323e+01
1.232323e+02
But real output:
1.232323e+0
1.232323e+1
1.232323e+2
Signed-off-by: Sunny <zxcvbnm37425@gmail.com>
1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)
------------------
How to test
From within nuttx/. Configure:
cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja
(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja
This uses ninja generator (install with sudo apt install ninja-build). To build:
$ cmake --build build
menuconfig:
$ cmake --build build -t menuconfig
--------------------------
2. cmake/build: reformat the cmake style by cmake-format
https://github.com/cheshirekow/cmake_format
$ pip install cmakelang
$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done
Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>
With double value=3.141593 initialized in va_list ap,
such code:
vsnprintf(buffer, sizeof(buffer), "%#.0f", ap);
expected output string: "3."
but real output string: ".3"
Signed-off-by: Sunny <zxcvbnm37425@gmail.com>
Separately checking the state of a file before operating on it may allow
an attacker to modify the file between the two operations.
Reference:
CWE-367
4290aed051/sysdeps/posix/remove.c (L29-L41)
Signed-off-by: Mingjie Shen <shen497@purdue.edu>