nuttx-apps/system
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
..
adb !apps: Simplify NuttX initialization 2026-05-06 13:27:05 +08:00
adcscope !apps: Simplify NuttX initialization 2026-05-06 13:27:05 +08:00
argtable3 cmake: remove empty strings from FetchContent 2025-03-30 14:20:21 +08:00
batterydump system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
cdcacm include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
cfgdata mtd/nvs: modify config name to MTD_CONFIG_NVS part1 2026-02-02 11:01:19 +08:00
cle include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
composite include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
conntrack system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
coredump !apps: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-22 13:38:25 +08:00
cpuload system/cpuload: Fix application's Make.defs location 2025-02-20 08:34:52 +01:00
critmon system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
cu include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
dd !apps: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-22 13:38:25 +08:00
debugpoint system/debugpoint: fix bug the length option parsing error 2025-02-25 13:07:58 -03:00
dhcp6c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
dhcpc system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
dumpstack system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
fastboot system/fastboot: fix socket() parameter order for TCP transport 2026-03-23 08:46:18 -03:00
fdt system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
flash_eraseall system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
flatbuffers system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
gcov gcov: Output mode judgment is implemented in the kernel layer 2025-06-26 23:48:01 +08:00
gdbstub system/gdbstub: Add depends of LIB_GDBSTUB 2025-07-18 22:42:03 +08:00
gprof system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
hex2bin system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
hexed system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
hostname system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
i2c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
iptables iptables: add file lock to prevent concurrent overwrite 2026-01-15 17:20:03 +08:00
irtest system/irtest: Set irtest command line size to CONFIG_LINE_MAX 2026-04-24 14:58:05 +02:00
libuv libuv: fix sendmsg parameter type in NuttX port 2026-01-16 21:10:55 +08:00
lm75 system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
lsan testing: add missing header files 2026-01-26 19:32:27 +08:00
lzf system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
mdio system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
microros apps/system/microros: Add CMakeLists.txt for CMake support. 2026-05-22 06:49:02 +08:00
netdb system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
ntpc system/ntpc: update ntpc messages 2025-09-05 23:47:36 +02:00
nxcamera include/debug.h: fix checkpatch fallout in touched apps files 2026-04-11 10:39:27 -03:00
nxcodec system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nxdiag system/nxdiag: add CMake support for NXDiag tool 2026-05-21 12:34:05 +08:00
nxlooper include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nxmbclient modbus: add nxmodbus 2026-04-20 12:45:17 -03:00
nxplayer include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nxrecorder include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
ofloader !apps: Simplify NuttX initialization 2026-05-06 13:27:05 +08:00
ping system/ping: Fallback to ping6 for gethost error handling. 2026-05-19 09:56:01 +02:00
ping6 ping: add -I for bind device 2025-12-25 12:24:04 +08:00
popen include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
psmq system/psmq: add proper include path for embedlog 2025-02-20 08:39:13 +01:00
ptpd !apps: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-22 13:38:25 +08:00
readline include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
resmonitor !apps: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-22 13:38:25 +08:00
sched_note system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
sensorscope system/sensorscope: support for fixe16 data 2026-05-06 08:54:32 +02:00
sensortest signals: fix build and runtime issues when signals all isabled 2026-01-19 22:55:19 +08:00
setlogmask system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
settings system/settings: Add spaces after each switch 'case' 2025-06-26 13:22:47 -03:00
smf system/smf: Port SMF .c/.h files to NuttX 2026-01-05 12:50:04 -05:00
spi include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
stackmonitor system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
syslogd system/syslogd: Initial implementation 2025-06-17 20:43:58 +08:00
system include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
taskset apps/system: replace CONFIG_NSH_LINELEN to LINE_MAX 2025-01-14 19:31:54 +08:00
tcpdump pkt: Set sll_protocol for raw socket to ETH_P_ALL 2026-01-04 21:41:21 +08:00
tee include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
telnet system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
telnetd system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
termcurses include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
trace apps/system/trace: support binary dump of noteram 2026-01-26 19:32:42 +08:00
ubloxmodem include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
uniqueid system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
uorb system/uorb: DEBUG_UORB depends on float data 2026-05-06 08:54:32 +02:00
usbmsc include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
vi include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
vncviewer examples/vncviewer: add VNC viewer for LCD display 2026-04-24 14:58:49 +02:00
ymodem apps/system/ymodem: Optimized ymodem for burn during bootloader 2026-02-02 11:00:19 +08:00
zlib apps: Fix minor issues for latest toolchains 2026-01-23 10:00:52 +08:00
zmodem !apps: replace sclock_t with clock_t and drop redundant time_t/off_t casts 2026-05-11 17:38:32 +08:00
.gitignore Remove extra whitespace from files (#43) 2020-01-31 08:29:24 -06:00
CMakeLists.txt system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
Make.defs system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
Makefile system: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00