Commit Graph

884 Commits

Author SHA1 Message Date
anjiahao
c843cb8a52 libc/net:use strlcpy instead of strncpy
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-04-12 21:16:11 +08:00
anjiahao
c30705f5f0 libc/lib_glob:use strlcpy instead of memcpy
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-04-12 21:15:45 +08:00
anjiahao
49cd445114 lib_localtime:fix unsigned compare with zero
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-04-12 17:10:14 +08:00
anjiahao
bb6279fe60 libc/lib_localtime:fix deadcode
isdst always is false

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-04-12 01:51:29 +08:00
songlinzhang
8dd5d0d510 netdb/lib_dnsaddserver.c: Do not insert the duplicate DNS address
Signed-off-by: songlinzhang <songlinzhang@xiaomi.com>
2022-04-11 20:31:15 +08:00
Jiuzhu Dong
e93100cb4d lib_lib_vsprintf/backtrace: fix the type issue
using 't': For integer types, causes printf to expect
a ptrdiff_t-sized integer argument.

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2022-04-07 12:14:27 +08:00
Xiang Xiao
ae6bfdc9b9 libc: Avoid the compiler generate code call self(memcpy/memmove/memset/memcmp) recursively
please reference the similar change done by other libc implementation:
https://reviews.llvm.org/D68028?id=224286
85c2e6110c
4a1f55e92f
82dfae9ab0

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-05 13:25:53 +03:00
Xiang Xiao
34e17ba0ce libc/string: Fix the minor style issue
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-05 13:25:53 +03:00
Petro Karashchenko
d08fbca679 nuttx: unify FAR attribute usage across the code
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-04-04 21:32:58 +08:00
Xiang Xiao
499c450d36 libc/netdb: Hold dns lock when operating with resolv.conf
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-04 19:48:36 +09:00
Xiang Xiao
cd695cd0d9 libc/netdb: Remove the temporary unlock in dns_foreach_nameserver
since netdb support the recursive lock

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-04 19:48:36 +09:00
Xiang Xiao
a8cac59864 libc/netdb: Support the recursive lock
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-04-04 19:48:36 +09:00
YAMAMOTO Takashi
75b1358d8e modlib_bind.c: Restore "Relocation address out of range" checks
Restore the checks which got completely broken by the following change.
```
commit 15142a8b10
Author: anjiahao <anjiahao@xiaomi.com>
Date:   Fri Apr 1 16:20:03 2022 +0800

    modlib/modlib_bind:fix unsigned_compare with zero

    Signed-off-by: anjiahao <anjiahao@xiaomi.com>
```
2022-04-04 09:12:37 +03:00
anjiahao
5b214888aa Update libs/libc/modlib/modlib_bind.c
Co-authored-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-04-02 01:05:22 +08:00
anjiahao
c7badac601 Update libs/libc/modlib/modlib_bind.c
u are right

Co-authored-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-04-02 01:05:22 +08:00
anjiahao
15142a8b10 modlib/modlib_bind:fix unsigned_compare with zero
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-04-02 01:05:22 +08:00
anjiahao
2d499ac86d lib_chdir:use change ret judgment method
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-04-01 19:39:33 +03:00
anjiahao
14c5f61e77 libs/libc/lib_err.c:add va_end to vwarn
call va_copy,after need call va_end
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2022-04-01 23:13:25 +08:00
田昕
24bd80eb84 unistd:rename CONFIG_OPEN_MAX to CONFIG_LIBC_OPEN_MAX
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2022-04-01 22:10:51 +08:00
田昕
463a437733 fs and unistd: increase OPEN_MAX by claiming a Kconfig.
Signed-off-by: 田昕 <tianxin7@xiaomi.com>
2022-04-01 12:17:47 +03:00
ligd
a1eb3f66fa rexec: fix free error in error handing
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-29 10:09:04 +08:00
Petro Karashchenko
98ba65c422 c89: get rid of designated initializers in common code
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-03-28 13:39:27 +08:00
Petro Karashchenko
2ac3e3c793 libs/libc/time: update description of strftime
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-03-28 00:30:53 +08:00
Xiang Xiao
de0dd2f569 libc: implement getentropy function
specify here:
https://man7.org/linux/man-pages/man3/getentropy.3.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-25 13:48:33 +02:00
Xiang Xiao
0bd93a2a76 libc/uuid: Call getrandom instaed arc4random_buf
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-25 13:48:33 +02:00
Xiang Xiao
c8ea7a95a3 libc: Implement getrandom on top of "/dev/[u]random"
https://man7.org/linux/man-pages/man2/getrandom.2.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-25 13:48:33 +02:00
Ville Juven
9288ed85e7 RISC-V: Add/fix implementation for arch_elf.c
The jump instruction relocation had an assert that tests for jumps with
an offset of 0. This makes it so that a while(1); statement causes an
assert because the jump instruction points to the same address, which
is perfectly legal.

Addend was not handled correctly in several reloc types.

Add ADD32/64 + SUB32/64 relocations, for some reason the compiler
I use likes to add them.
2022-03-23 17:56:54 +08:00
Xiang Xiao
0fcb4575bb sched/dumpstack: Print "backtrace:" only in the first iteration
to avoid the same label print multiple time in one dumpstack

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-23 07:26:19 +09:00
Petro Karashchenko
68902d8732 pid_t: unify usage of special task IDs
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-03-22 21:22:32 +08:00
Xiang Xiao
6b8274fbd8 libc: Change the return type of strerror from "const char *" to "char *"
to follow up the spec here:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-20 23:02:50 +02:00
chao.an
316797a7f6 libc/err: fix unpaired va_end()
each invocation of va_start() must be matched by a corresponding
invocation of va_end() in the same function

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-03-19 10:13:23 +02:00
chao.an
484b930fd1 netdb/getaddrinfo: fix NULL pointer reference
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-03-18 20:11:54 +02:00
chao.an
0f7ccf0c08 netdb/getaddrinfo: fix the compile warning
netdb/lib_getaddrinfo.c: In function ‘alloc_ai’:
netdb/lib_getaddrinfo.c:80:9: warning: ‘strncpy’ specified bound 108 equals destination size [-Wstringop-truncation]
   80 |         strncpy(ai->sa.sun.sun_path, addr, sizeof(ai->sa.sun.sun_path));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

netdb/lib_getaddrinfo.c: In function ‘alloc_ai’:
netdb/lib_getaddrinfo.c:103:9: warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-truncation]
  103 |         strncpy(ai->sa.srp.rp_cpu, addr, sizeof(ai->sa.srp.rp_cpu));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-03-19 00:34:26 +08:00
Xiang Xiao
eea014efb7 Fix error: conflicting types for built-in function 'execl'; expected 'int(const char *, const char *, ...)
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-18 16:38:01 +02:00
Xiang Xiao
8f4421a79e Fix warning: 'argnumber' may be used uninitialized in this function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-18 12:43:17 +02:00
zhuyanlin
5665b7a585 arch:lib_atomic: remove and fix gcc warning declaration-mismatch
Remove GCC ignored warning and fix

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
2022-03-18 13:35:42 +08:00
songlinzhang
e2114378b9 Add dn resolution function
Signed-off-by: songlinzhang <songlinzhang@xiaomi.com>
2022-03-17 09:37:15 +02:00
Xiang Xiao
be2f688cd9 Fix net/lib_nametoindex.c:58:7: error: 'strncpy' specified bound 16 equals destination size
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-10 19:46:01 +02:00
Huang Qi
69cfe8d626 arch/arm: Support setjmp/longjmp for all socs
After check the official specification of ARM ISA
and Thumb ISA, the arch_setjmp_thumb.S are written
by arm unified assembly language,
so it easy to make it works for ARM and thumb ISA.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-03-09 17:13:21 +02:00
chao.an
82f90e4c33 libs/vsprintf: fix the type issue
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-03-09 10:16:54 +02:00
Huang Qi
c6e636a871 arch/risc-v: Save/Load float register in setjmp
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-03-09 10:15:54 +02:00
Xiang Xiao
01517b2ebe libc/gettext: Support the plural format
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-08 15:57:25 -03:00
Xu Xingliang
f38783f4b5 libc/locale: check if mmap failed before proceeding.
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
2022-03-08 15:57:25 -03:00
Xiang Xiao
0e12bf167b libc/stdio: Make %p[V|S|s] work with CONFIG_LIBC_NUMBERED_ARGS
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-08 11:33:54 -03:00
Xiang Xiao
a2e9e83956 libc/stdio: Don't fetch width/prec modifier in parser phase
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-08 11:33:54 -03:00
Xiang Xiao
428ce93ee5 libc/stdio: Skip fetch double argument if !CONFIG_LIBC_FLOATINGPOINT && CONFIG_LIBC_NUMBERED_ARGS
since the argument is already fetched by lib_vsprintf in this case

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-08 11:33:54 -03:00
Xiang Xiao
0c01f0ce5a libc/stdio: Add _s suffix for struct arg in lib_libvsprintf.c
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-08 11:33:54 -03:00
Huang Qi
cfff115f21 arm: Move setjmp to common place
Since some Cortex A core supports thumb mode also,
thus they can share same implementation.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-03-08 21:00:29 +08:00
Alin Jerpelea
c58ac94450 libs: libc: lib_ubsqrt: migrate license to Apache
Haltian has submitted the SGA as a result can migrate the licenses
to Apache

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2022-03-02 18:14:36 +08:00
Xiang Xiao
4a16cf71f9 Fix -Werror=nonnull-compare and -Werror=format-truncation=
Error: module/mod_insmod.c:203:3: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation]
  203 |   strncpy(modp->modname, modname, MODLIB_NAMEMAX);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

wqueue/kwork_thread.c: In function 'work_start_lowpri':
Error: wqueue/kwork_thread.c:212:22: error: '%lx' directive output may be truncated writing between 1 and 16 bytes into a region of size 14 [-Werror=format-truncation=]
  212 |   snprintf(args, 16, "0x%" PRIxPTR, (uintptr_t)wqueue);

local/local_sockif.c: In function 'local_getsockname':
Error: local/local_sockif.c:392:11: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
  392 |           strncpy(unaddr->sun_path, conn->lc_path, namelen);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

chip/esp32_wifi_utils.c: In function 'esp_wifi_scan_event_parse':
Error: chip/esp32_wifi_utils.c:373:37: error: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]
   memset(ap_list_buffer, 0x0, sizeof(ap_list_buffer));
                                     ^

stdio/lib_fputs.c: In function 'fputs':
Error: stdio/lib_fputs.c:99:9: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s == NULL || stream == NULL)
         ^
Error: stdio/lib_fputs.c:99:27: error: nonnull argument 'stream' compared to NULL [-Werror=nonnull-compare]
   if (s == NULL || stream == NULL)
                           ^

stdio/lib_vfprintf.c: In function 'vfprintf':
Error: stdio/lib_vfprintf.c:40:6: error: nonnull argument 'stream' compared to NULL [-Werror=nonnull-compare]
   if (stream)
      ^

string/lib_strdup.c: In function 'strdup':
Error: string/lib_strdup.c:39:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s)
      ^

string/lib_strndup.c: In function 'strndup':
Error: string/lib_strndup.c:56:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s)
      ^

string/lib_strpbrk.c: In function 'strpbrk':
Error: string/lib_strpbrk.c:39:7: error: nonnull argument 'str' compared to NULL [-Werror=nonnull-compare]
   if (!str || !charset)
       ^~~~
Error: string/lib_strpbrk.c:39:15: error: nonnull argument 'charset' compared to NULL [-Werror=nonnull-compare]
   if (!str || !charset)
               ^~~~~~~~

string/lib_strrchr.c: In function 'strrchr':
Error: string/lib_strrchr.c:40:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s)
      ^

Error: time/lib_asctimer.c:73:50: error: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 12 [-Werror=format-truncation=]
   snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
                                                  ^~
time/lib_asctimer.c:73:21: note: directive argument in the range [-2147481748, 2147483647]
   snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
time/lib_asctimer.c:73:3: note: 'snprintf' output between 17 and 68 bytes into a destination of size 26
   snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            g_wday_name[tp->tm_wday], g_mon_name[tp->tm_mon],
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec,
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            1900 + tp->tm_year);
            ~~~~~~~~~~~~~~~~~~~

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-02 15:55:38 +08:00