public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH] tcp: Cast timeval fields to unsigned long long for printing
@ 2023-12-24 17:41 Stefano Brivio
  2023-12-27  3:40 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Stefano Brivio @ 2023-12-24 17:41 UTC (permalink / raw)
  To: passt-dev

On x32, glibc defines time_t and suseconds_t (the latter, also known as
__syscall_slong_t) as unsigned long long, whereas "everywhere else",
including x86_64 and i686, those are unsigned long.

See also https://sourceware.org/bugzilla/show_bug.cgi?id=16437 for
all the gory details.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 tcp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tcp.c b/tcp.c
index f506cfd..1e4d2fa 100644
--- a/tcp.c
+++ b/tcp.c
@@ -727,8 +727,9 @@ static void tcp_timer_ctl(const struct ctx *c, struct tcp_tap_conn *conn)
 		it.it_value.tv_sec = ACT_TIMEOUT;
 	}
 
-	flow_dbg(conn, "timer expires in %lu.%03lus", it.it_value.tv_sec,
-		 it.it_value.tv_nsec / 1000 / 1000);
+	flow_dbg(conn, "timer expires in %llu.%03llus",
+		 (unsigned long long)it.it_value.tv_sec,
+		 (unsigned long long)it.it_value.tv_nsec / 1000 / 1000);
 
 	timerfd_settime(conn->timer, 0, &it, NULL);
 }
-- 
@@ -727,8 +727,9 @@ static void tcp_timer_ctl(const struct ctx *c, struct tcp_tap_conn *conn)
 		it.it_value.tv_sec = ACT_TIMEOUT;
 	}
 
-	flow_dbg(conn, "timer expires in %lu.%03lus", it.it_value.tv_sec,
-		 it.it_value.tv_nsec / 1000 / 1000);
+	flow_dbg(conn, "timer expires in %llu.%03llus",
+		 (unsigned long long)it.it_value.tv_sec,
+		 (unsigned long long)it.it_value.tv_nsec / 1000 / 1000);
 
 	timerfd_settime(conn->timer, 0, &it, NULL);
 }
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tcp: Cast timeval fields to unsigned long long for printing
  2023-12-24 17:41 [PATCH] tcp: Cast timeval fields to unsigned long long for printing Stefano Brivio
@ 2023-12-27  3:40 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2023-12-27  3:40 UTC (permalink / raw)
  To: Stefano Brivio; +Cc: passt-dev

[-- Attachment #1: Type: text/plain, Size: 1343 bytes --]

On Sun, Dec 24, 2023 at 06:41:07PM +0100, Stefano Brivio wrote:
> On x32, glibc defines time_t and suseconds_t (the latter, also known as
> __syscall_slong_t) as unsigned long long, whereas "everywhere else",
> including x86_64 and i686, those are unsigned long.
> 
> See also https://sourceware.org/bugzilla/show_bug.cgi?id=16437 for
> all the gory details.
> 
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  tcp.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/tcp.c b/tcp.c
> index f506cfd..1e4d2fa 100644
> --- a/tcp.c
> +++ b/tcp.c
> @@ -727,8 +727,9 @@ static void tcp_timer_ctl(const struct ctx *c, struct tcp_tap_conn *conn)
>  		it.it_value.tv_sec = ACT_TIMEOUT;
>  	}
>  
> -	flow_dbg(conn, "timer expires in %lu.%03lus", it.it_value.tv_sec,
> -		 it.it_value.tv_nsec / 1000 / 1000);
> +	flow_dbg(conn, "timer expires in %llu.%03llus",
> +		 (unsigned long long)it.it_value.tv_sec,
> +		 (unsigned long long)it.it_value.tv_nsec / 1000 / 1000);
>  
>  	timerfd_settime(conn->timer, 0, &it, NULL);
>  }

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-27  3:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-24 17:41 [PATCH] tcp: Cast timeval fields to unsigned long long for printing Stefano Brivio
2023-12-27  3:40 ` David Gibson

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).