[PATCH] ctdb: Fix a 32-bit problem

Jérémie Courrèges-Anglas jca at wxcvbn.org
Fri Sep 4 11:45:09 UTC 2015


Volker Lendecke <Volker.Lendecke at SerNet.DE> writes:

> Hi!

Hi Volker,

> Review&push appreciated!

I am mildly concerned with this approach.  At least two
implementations out there use 64 bits time_t on 32 bits (and 64 bits)
systems: NetBSD, OpenBSD.  Linux x32 also uses 64 bits time_t.

The OpenBSD source and ports tree has received loads of fixes.  It turns
out that the most portable way to print time_t is to use %lld and an
explicit (long long) cast.  eg.

@@ -1095,7 +1095,7 @@ static void ctdb_tevent_trace(enum tevent_trace_point tp,
 			if (diff.tv_sec > 3) {
 				DEBUG(DEBUG_CRIT,
 				      ("No event for %lld seconds!\n",
-				       diff.tv_sec));
+				       (long long)diff.tv_sec));
 			}
 		}
 		tevent_after_wait_ts = now;

Samba 4 already assumes that long long is available.

Chances are that 32 bits OSes and Samba will still coexist in 2038.
Would patches using the idiom presented above be welcome in the samba
source tree?

  http://www.openbsd.org/papers/eurobsdcon_2013_time_t/mgp00011.html

> Thanks,
>
> Volker
>
> -- 
> SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
> phone: +49-551-370000-0, fax: +49-551-370000-9
> AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
> http://www.sernet.de, mailto:kontakt at sernet.de
>
> From 0c63606319bdad654135766bffcbd2d2d6c56566 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Thu, 3 Sep 2015 16:25:02 +0200
> Subject: [PATCH] ctdb: Fix a 32-bit problem
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
>  ctdb/server/ctdb_daemon.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
> index ac2db75..563370a 100644
> --- a/ctdb/server/ctdb_daemon.c
> +++ b/ctdb/server/ctdb_daemon.c
> @@ -1083,7 +1083,7 @@ static void ctdb_tevent_trace(enum tevent_trace_point tp,
>  			if (diff.tv_sec > 3) {
>  				DEBUG(DEBUG_ERR,
>  				      ("Handling event took %ld seconds!\n",
> -				       diff.tv_sec));
> +				       (long)diff.tv_sec));
>  			}
>  		}
>  		tevent_before_wait_ts = now;
> @@ -1095,7 +1095,7 @@ static void ctdb_tevent_trace(enum tevent_trace_point tp,
>  			if (diff.tv_sec > 3) {
>  				DEBUG(DEBUG_CRIT,
>  				      ("No event for %ld seconds!\n",
> -				       diff.tv_sec));
> +				       (long)diff.tv_sec));
>  			}
>  		}
>  		tevent_after_wait_ts = now;

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



More information about the samba-technical mailing list