tools/xenstore/xenstored_control.c: correctly print time_t
PATCH 1/1 tools/xenstore/xenstored_control.c: correctly print time_t
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=]
--- tools/xenstore/xenstored_control.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/xenstore/xenstored_control.c +2 -2
@@ -668,10 +668,10 @@ static const char *lu_reject_reason(const void *ctx)list_for_each_entry (conn, &connections, list) {if (conn->ta_start_time && (now - conn->ta_start_time >= lu_status->timeout)) { - ret =talloc_asprintf (ctx,"%s\nDomain %u: %ld s" , + ret =talloc_asprintf (ctx,"%s\nDomain %u: %jd s" , ret ? :"Domains with long running transactions:" , conn->id, - now - conn->ta_start_time); + (intmax_t )now - conn->ta_start_time); } }
Signature · 1 line
2.30.2
Quoted 18 lines · Alexander Kanavin
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 <[email protected]>--- tools/xenstore/xenstored_control.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/xenstore/xenstored_control.c +0
-0@@ -668,10 +668,10 @@ static const char *lu_reject_reason(const void *ctx)list_for_each_entry (conn, &connections, list) { if (conn->ta_start_time &&
tools/xenstore/xenstored_control.c static const char *lu_reject_reason(const void *ctx) · line 677
Quoted 10 lines
tools/xenstore/xenstored_control.c +2
-2(now - conn->ta_start_time >= lu_status->timeout)) { - ret =talloc_asprintf (ctx,"%s\nDomain %u: %ld s" , + ret =talloc_asprintf (ctx,"%s\nDomain %u: %jd s" , ret ? :"Domains with long running transactions:" , conn->id, - now - conn->ta_start_time); + (intmax_t )now - conn->ta_start_time); } }
I'd rather have something like:
tools/xenstore/xenstored_control.c +3 -2
@@ -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);
}
}Juergen
Quoted 14 lines · Juergen Gross
I'd rather have something like:
tools/xenstore/xenstored_control.c +0
-2@@ -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)) {
tools/xenstore/xenstored_control.c static const char *lu_reject_reason(const void · line 677
Quoted 10 lines
tools/xenstore/xenstored_control.c +4
-2+ 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); } }
Thanks, I just sent a v2 that does this.
Signature · 11 lines
Alexander Kanavin Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen Phone: +49 7556 25 999 39; Fax.: +49 7556 25 999 99 Hinweise zum Datenschutz finden Sie hier (Informations on data privacy can be found here): https://linutronix.de/legal/data-protection.php Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner, Sharon Heck, Yulia Beck, Tiffany Silva