]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: acme: fix build issue on 32-bit archs with 64-bit time_t
authorWilly Tarreau <w@1wt.eu>
Wed, 21 May 2025 08:18:47 +0000 (10:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 21 May 2025 08:18:47 +0000 (10:18 +0200)
The build failed on mips32 with a 64-bit time_t here:

  https://github.com/haproxy/haproxy/actions/runs/15150389164/job/42595310111

Let's just turn the "remain" variable used to show the remaining time
into a more portable ullong and use %llu for all format specifiers,
since long remains limited to 32-bit on 32-bit archs.

No backport needed.

src/acme.c

index 70bd95e8e4bb8f4e56f3f058cc3de31dab8eec35..a1197f3b7f4f2c781c32a37ce950854c3f24a92c 100644 (file)
@@ -2394,7 +2394,7 @@ static int cli_acme_status_io_handler(struct appctx *appctx)
                        char *state;
                        time_t notAfter = 0;
                        time_t sched = 0;
-                       time_t remain = 0;
+                       ullong remain = 0;
                        int running = !!store->acme_task;
 
                        if (global_ssl.acme_scheduler)
@@ -2413,7 +2413,7 @@ static int cli_acme_status_io_handler(struct appctx *appctx)
                                remain = notAfter - date.tv_sec;
                        strftime(str, sizeof(str), "%Y-%m-%dT%H:%M:%SZ", gmtime(&notAfter));
                        chunk_appendf(&trash, "%s\t", str);
-                       chunk_appendf(&trash, "%lud %luh%02lum%02lus\t", remain / 86400, (remain % 86400) / 3600, (remain % 3600) / 60, (remain % 60));
+                       chunk_appendf(&trash, "%llud %lluh%02llum%02llus\t", remain / 86400, (remain % 86400) / 3600, (remain % 3600) / 60, (remain % 60));
 
                        /* Scheduled time */
                        remain = 0;
@@ -2424,7 +2424,7 @@ static int cli_acme_status_io_handler(struct appctx *appctx)
                        strftime(str, sizeof(str), "%Y-%m-%dT%H:%M:%SZ", gmtime(&sched));
                        chunk_appendf(&trash, "%s\t", sched ? str : "-");
                        if (sched)
-                               chunk_appendf(&trash, "%lud %luh%02lum%02lus\n", remain / 86400, (remain % 86400) / 3600, (remain % 3600) / 60, (remain % 60));
+                               chunk_appendf(&trash, "%llud %lluh%02llum%02llus\n", remain / 86400, (remain % 86400) / 3600, (remain % 3600) / 60, (remain % 60));
                        else
                                chunk_appendf(&trash, "%s\n", "-");