From 552a0a3a284194dc4f9dac3d72259e9d622813e1 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 30 Apr 2024 14:18:03 +0200 Subject: [PATCH 1/2] lib: fix `time_t` print without cast The gcc plugin wasn't warning about printing `suseconds_t` (which is `time_t`, but in `struct timeval`.) It needs to be printed with a cast, just like `time_t`. Luckily there is only one such usage. Signed-off-by: David Lamparter --- lib/northbound_oper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/northbound_oper.c b/lib/northbound_oper.c index 7e7190f5a4..5f38c970c7 100644 --- a/lib/northbound_oper.c +++ b/lib/northbound_oper.c @@ -1556,8 +1556,9 @@ static enum nb_error nb_op_yield(struct nb_op_yield_state *ys) unsigned long min_us = MAX(1, NB_OP_WALK_INTERVAL_US / 50000); struct timeval tv = { .tv_sec = 0, .tv_usec = min_us }; - DEBUGD(&nb_dbg_events, "NB oper-state: yielding %s for %lus (should_batch %d)", - ys->xpath, tv.tv_usec, ys->should_batch); + DEBUGD(&nb_dbg_events, + "NB oper-state: yielding %s for %lldus (should_batch %d)", + ys->xpath, (long long)tv.tv_usec, ys->should_batch); if (ys->should_batch) { /* From da3677e7199e1911e55a70ab37b2a2ebac2db6a9 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 30 Apr 2024 14:13:22 +0200 Subject: [PATCH 2/2] tools/gcc-plugins: warn for `suseconds_t` format The plugin was already catching attempts to print `time_t` without casting it first (there is no valid printf specifier without a cast), but `__suseconds64_t` needs the same treatment. (Probably `__suseconds_t` too, if it exists, which I'm not sure it does - but that doesn't matter, the plugin ignores non-existing types.) Signed-off-by: David Lamparter --- tools/gcc-plugins/frr-format.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/gcc-plugins/frr-format.c b/tools/gcc-plugins/frr-format.c index 4e2c2d3ba9..963741e479 100644 --- a/tools/gcc-plugins/frr-format.c +++ b/tools/gcc-plugins/frr-format.c @@ -66,6 +66,8 @@ static GTY(()) tree local_pid_t_node; static GTY(()) tree local_uid_t_node; static GTY(()) tree local_gid_t_node; static GTY(()) tree local_time_t_node; +static GTY(()) tree local_suseconds_t_node; +static GTY(()) tree local_suseconds64_t_node; static GTY(()) tree local_socklen_t_node; static GTY(()) tree local_in_addr_t_node; @@ -85,6 +87,8 @@ static struct type_special { { &local_uid_t_node, NULL, &local_uid_t_node, }, { &local_gid_t_node, NULL, &local_gid_t_node, }, { &local_time_t_node, NULL, &local_time_t_node, }, + { &local_suseconds_t_node, NULL, &local_suseconds_t_node, }, + { &local_suseconds64_t_node, NULL, &local_suseconds64_t_node, }, { NULL, NULL, NULL, } }; @@ -4176,6 +4180,8 @@ handle_finish_parse (void *event_data, void *data) setup_type ("uid_t", &local_uid_t_node); setup_type ("gid_t", &local_gid_t_node); setup_type ("time_t", &local_time_t_node); + setup_type ("__suseconds_t", &local_suseconds_t_node); + setup_type ("__suseconds64_t", &local_suseconds64_t_node); setup_type ("socklen_t", &local_socklen_t_node); setup_type ("in_addr_t", &local_in_addr_t_node);