nuttx/drivers/syslog
Xiang Xiao 9ff99c6d0f !nuttx: 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 and
consistent with the previous sclock_t/time_t cleanup.

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 across arch/, drivers/,
  fs/, sched/ and libs/.  The prior code was a mix of
  "%d"/"%u"/"%ld"/"%lu"/"%lld"/PRIu32/PRIu64 with matching
  (int)/(unsigned long)/(long long)/PRIu* 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)

  Add #include <stdint.h> where required.

* Drops a few stale `(FAR const time_t *)&ts.tv_sec` casts and
  related `(FAR struct tm *)` / `(const time_t *)` casts in
  gmtime_r() / localtime_r() / gmtime() callers; ts.tv_sec is plain
  time_t now and the casts only obscured the type.

* Fixes one overflow in fs/procfs/fs_procfscritmon.c where
  all_time.tv_sec * 1000000 could overflow on 32-bit time_t before
  being multiplied again; cast to uint64_t at the start.

No behavioural change.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-05-19 16:21:28 +08:00
..
CMakeLists.txt sched/syslog: Add early_syslog() for early boot or system down debugging 2025-10-31 08:29:17 -03:00
Kconfig drivers/syslog: add millisecond option for syslog timestamp formatting 2026-02-27 08:09:31 -03:00
Make.defs Documentation: Add description for early_syslog() 2025-10-31 08:29:17 -03:00
ramlog.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
syslog.h syslog/inbuffer: refactor intbuffer to circbuf 2024-12-17 20:48:23 +08:00
syslog_channel.c drivers/syslog/syslog_channel.c: fix incompatible-pointer-types compile errors 2025-08-07 10:16:20 -03:00
syslog_chardev.c drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
syslog_console.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
syslog_consolechannel.c drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
syslog_devchannel.c drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
syslog_device.c style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
syslog_early.c sched/syslog: Add early_syslog() for early boot or system down debugging 2025-10-31 08:29:17 -03:00
syslog_filechannel.c drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
syslog_flush.c drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
syslog_initialize.c drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
syslog_intbuffer.c sched/spin_lock: rename raw_spin_lock to spin_lock_notrace 2025-02-13 20:48:15 +08:00
syslog_rpmsg.c syslog/rpmsg: disable force put char to lower putc 2025-06-03 17:33:03 +08:00
syslog_rpmsg.h drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
syslog_rpmsg_server.c syslog/rpmsg_server: fix build break if enable SYSLOG_RPMSG/SYSLOG_RPMSG_SERVER 2025-02-25 10:51:37 +01:00
syslog_stream.c drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
syslog_write.c sched/signal: Add support for partially disabling signals 2026-01-18 08:24:13 -03:00
vsyslog.c !nuttx: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-19 16:21:28 +08:00
vsyslog_rfc5424.c drivers/syslog: Add RFC 5424 protocol support 2025-06-13 20:26:57 +08:00