[PATCH v2] tools/xenstore/xenstored_control.c: correctly print time_t

Alexander Kanavin posted 1 patch 1 year ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20230419120710.855128-1-alex@linutronix.de
tools/xenstore/xenstored_control.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[PATCH v2] tools/xenstore/xenstored_control.c: correctly print time_t
Posted by Alexander Kanavin 1 year ago
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>
---
 tools/xenstore/xenstored_control.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/xenstore/xenstored_control.c b/tools/xenstore/xenstored_control.c
index cbd62556c3..403295788a 100644
--- a/tools/xenstore/xenstored_control.c
+++ b/tools/xenstore/xenstored_control.c
@@ -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);
 		}
 	}
 
-- 
2.30.2
Re: [PATCH v2] tools/xenstore/xenstored_control.c: correctly print time_t
Posted by Juergen Gross 1 year ago
On 19.04.23 14:07, Alexander Kanavin wrote:
> 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>


Juergen

Re: [PATCH v2] tools/xenstore/xenstored_control.c: correctly print time_t
Posted by Julien Grall 1 year ago
Hi,

On 19/04/2023 13:42, Juergen Gross wrote:
> On 19.04.23 14:07, Alexander Kanavin wrote:
>> 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>

I have committed it.

Thanks,

-- 
Julien Grall