]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
tools/xenstore/xenstored_control.c: correctly print time_t
authorAlexander Kanavin <alex@linutronix.de>
Wed, 19 Apr 2023 12:07:09 +0000 (14:07 +0200)
committerJulien Grall <jgrall@amazon.com>
Wed, 19 Apr 2023 18:31:04 +0000 (19:31 +0100)
On 32 bit systems with 64 bit time_t (hello, Y2038 problem),
the following error occurs otherwise:

| xenstored_control.c: In function 'lu_reject_reason':
| xenstored_control.c:646:70: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'time_t' {aka 'long long int'} [-Werror=format=]

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Reviewed-by: Juergen Gross <jgross@suse.com>
tools/xenstore/xenstored_control.c

index cbd62556c3ae50a9d539de14d28890c8d9a9f81a..403295788ab4509612aaabe8dd03bc981a604d1a 100644 (file)
@@ -666,12 +666,12 @@ static const char *lu_reject_reason(const void *ctx)
        time_t now = time(NULL);
 
        list_for_each_entry(conn, &connections, list) {
-               if (conn->ta_start_time &&
-                   (now - conn->ta_start_time >= lu_status->timeout)) {
+               unsigned long tdiff = now - conn->ta_start_time;
+
+               if (conn->ta_start_time && (tdiff >= lu_status->timeout)) {
                        ret = talloc_asprintf(ctx, "%s\nDomain %u: %ld s",
                                              ret ? : "Domains with long running transactions:",
-                                             conn->id,
-                                             now - conn->ta_start_time);
+                                             conn->id, tdiff);
                }
        }