nuttx-apps/nshlib
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
..
CMakeLists.txt nshlib/nsh_builtin.c : Add support to run builtin dirrectly as command 2025-09-11 20:00:20 +08:00
Kconfig nshlib: add chmod and chown builtins 2026-05-19 09:56:24 +08:00
Make.defs nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
Makefile nshlib/nsh_builtin.c : Add support to run builtin dirrectly as command 2025-09-11 20:00:20 +08:00
nsh.h nshlib: add chmod and chown builtins 2026-05-19 09:56:24 +08:00
nsh_alias.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_altconsole.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nsh_builtin.c sched/signal: Add support to disable partial or all signals 2026-01-15 15:48:54 +08:00
nsh_codeccmd.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nsh_command.c nshlib: add chmod and chown builtins 2026-05-19 09:56:24 +08:00
nsh_console.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nsh_console.h nshlib: Add stderr redirection support 2026-01-27 03:14:00 +08:00
nsh_consolemain.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_dbgcmds.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_envcmds.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_fileapps.c nshlib: Add stderr redirection support 2026-01-27 03:14:00 +08:00
nsh_fscmds.c nshlib: add chmod and chown builtins 2026-05-19 09:56:24 +08:00
nsh_fsutils.c nshlib/nsh_fsutils.c: fix getpid_callback function read size 2025-03-27 09:25:21 +08:00
nsh_init.c !apps: Simplify NuttX initialization 2026-05-06 13:27:05 +08:00
nsh_login.c apps/nshlib: replace CONFIG_NSH_LINELEN to LINE_MAX 2025-01-14 19:31:54 +08:00
nsh_mmcmds.c apps/nshlib: Reuse local variable for cmd_memdump 2025-01-17 23:27:43 +08:00
nsh_mntcmds.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nsh_modcmds.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_netcmds.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nsh_parse.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nsh_passwdcmds.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_printf.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_proccmds.c signals: fix build and runtime issues when signals all isabled 2026-01-19 22:55:19 +08:00
nsh_prompt.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_routecmds.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_script.c nshlib: Add stderr redirection support 2026-01-27 03:14:00 +08:00
nsh_session.c nsh: return EOF when nread is 0 2025-12-10 11:24:14 +08:00
nsh_syscmds.c nsh_syscmds/rpmsg: add rpmsg test command support 2026-01-08 22:50:11 +08:00
nsh_system.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_telnetd.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nsh_telnetlogin.c apps/nshlib: replace CONFIG_NSH_LINELEN to LINE_MAX 2025-01-14 19:31:54 +08:00
nsh_test.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_timcmds.c !apps: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-22 13:38:25 +08:00
nsh_usbconsole.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nsh_usbtrace.c include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
nsh_vars.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
nsh_wait.c nshlib: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
rc.sysinit.template nsh/script: support rc.sysinit script 2022-04-21 12:54:24 +03:00
rcS.template nsh/script: support rc.sysinit script 2022-04-21 12:54:24 +03:00