Commit graph

20 commits

Author SHA1 Message Date
Xiang Xiao
f9f59bd0f8 !apps: drop redundant casts on tv_sec/tv_nsec and fix printf formats
Now that time_t is unconditionally 64-bit (signed int64_t) and the
struct timespec fields tv_sec / tv_nsec are wide enough on their own,
the explicit (uint64_t)/(int64_t)/(int) casts that used to guard the
multiplications and subtractions in *_us / *_ms / *_ns helpers are no
longer needed.  Drop them to keep the timekeeping math readable.

In the same spirit, this commit also normalises the printf-style format
specifiers and casts used to print tv_sec / tv_nsec / tv_usec values.
The prior code was a mix of "%d"/"%u"/"%ld"/"%lu"/"%lld" with matching
(int)/(unsigned long)/(long long) casts; some formats truncated time_t
on 32-bit hosts, others mismatched signedness or width.  Replace all
such cases with the portable POSIX-recommended forms:

  - tv_sec  (time_t,       signed, impl-defined width) -> %jd  + (intmax_t)
  - tv_nsec (long,         signed)                     -> %ld  (no cast)
  - tv_usec (suseconds_t / long)                       -> %ld  (no cast)

Also drop two stale `(FAR const time_t *)&ts.tv_sec` casts that are
unnecessary now that ts.tv_sec is plain time_t.

Arithmetic-cleanup files (existing scope):

  - benchmarks/cyclictest/cyclictest.c:        timediff_us()
  - benchmarks/sd_bench/sd_bench_main.c:       get_time_delta_us()
  - examples/oneshot/oneshot_main.c:           maxus computation
  - examples/watchdog/watchdog_main.c:         current_time_ms (x2)
  - industry/nxmodbus/nxmb_internal.h:         nxmb_util_clock_ms()
  - netutils/ntpclient/ntpclient.c:            timespec2ntp()
  - netutils/ptpd/ptpd.c:                      ptp_adjtime()
  - system/dd/dd_main.c:                       elapsed accounting
  - testing/drivers/drivertest/drivertest_posix_timer.c:
                                               get_timestamp()
  - testing/drivers/sd_stress/sd_stress_main.c:get_time_delta()
  - testing/sched/getprime/getprime_main.c:    elapsed accounting
  - testing/sched/pthread_mutex_perf/pthread_mutex_perf.c:
                                               timespec_avg()

Printf-format-fix files (new in this revision):

  - examples/adjtime/adjtime_main.c
  - examples/charger/charger_main.c
  - examples/netpkt/netpkt_ethercat.c
  - fsutils/mkfatfs/mkfatfs.c
  - graphics/tiff/tiff_initialize.c
  - netutils/ptpd/ptpd.c
  - nshlib/nsh_timcmds.c
  - system/coredump/coredump.c
  - system/ptpd/ptpd_main.c
  - testing/drivers/drivertest/drivertest_oneshot.c
  - testing/mm/kasantest/kasantest.c
  - testing/ostest/semtimed.c
  - testing/sched/pthread_mutex_perf/pthread_mutex_perf.c
  - testing/sched/timerjitter/timerjitter.c
  - testing/testsuites/kernel/time/cases/clock_test_clock01.c
  - testing/testsuites/kernel/time/cases/clock_test_smoke.c

No behavioural change.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-05-22 13:38:25 +08:00
Niccolò Maggioni
0c680bcb8e system/coredump: Fix missing loglevel to logmask conversion.
The current setlogmask call used in the coredump app specifies a raw log level
instead of a bitmask, and this causes wrong evaluations later on when that value
is checked against a mask. Therefore the LOG_UPTO macro is added for conversion.

Signed-off-by: Niccolò Maggioni <nicco.maggioni+nuttx@gmail.com>
2025-07-09 09:54:40 +02:00
yintao
d3a1f80308 coredump: add error print
So we know if coredump exits with error, or there's no coredump.

Signed-off-by: yintao <yintao@xiaomi.com>
2025-01-24 09:34:47 +08:00
xuxingliang
1d1a8ba92e system/coredump: move coredump info to note
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2025-01-24 09:34:47 +08:00
Alin Jerpelea
66e8296230 system: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-12-30 18:02:50 +08:00
buxiasen
22d5d1d9d8 coredump: move definition out of types
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-30 07:36:36 +08:00
buxiasen
b75e404ec1 coredump: use llx to fix coverity report
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-30 07:36:36 +08:00
buxiasen
04f49f179b system/coredump: coredump restore independ and support mtd
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-30 07:36:36 +08:00
buxiasen
52bfcb3ab9 system/coredump: compatible restore name with NAME_MAX 32 Bytes
Coredump should compatible with default 32B NAME_MAX

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-11-30 07:36:36 +08:00
wanggang26
cb24b748a5 coredump app: type of info->time has changed into timespec
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-10-17 08:55:22 +08:00
anjiahao
c98439f9a1 coredump:update memory region init
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-16 17:34:02 +08:00
anjiahao
c693b3064e system/coredump:support coredump can save board memory
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-16 14:22:43 +08:00
anjiahao
9752b57714 system/coredump:upload kernal coredump change
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-16 14:22:43 +08:00
anjiahao
b99f92bac5 system/coredump:fix coverity bug
check read return, avoid dead loop if read return zero

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-16 14:22:43 +08:00
anjiahao
03f3ce7fd4 system/coredump:Increase coredump swap buffer size to improve speed
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-16 14:22:43 +08:00
ouyangxiangzhen
44d2250b6e apps: Fix compilation error after nuttx/arch.h excluded.
This patch fix compilation error after excluding nuttx/arch.h.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2024-10-16 07:12:40 +08:00
xuxin19
2e133feb09 cmake:support system apps CMake build
Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2024-06-30 21:40:25 +08:00
anjiahao
1334306585 coredump:support coredump command restore coredump form block device
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-08 19:28:09 -08:00
chao an
3b2b73de88 coredump/priority: Increase the default priority of coredump to 254
Increase coredump priority to avoid unnecessary task switch during dump

Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-09 15:00:45 +08:00
chao an
6f4546f597 system/coredump: add coredump tool to capture system status
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-25 11:46:22 +08:00