snips.sh

 1From 89e1c9415fb8438310036d5810cdb7da75ee3a7f Mon Sep 17 00:00:00 2001
 2From: Khem Raj <raj.khem@gmail.com>
 3Date: Wed, 26 Jul 2023 12:27:14 -0700
 4Subject: [PATCH] Adjust printf formats for 64bit time_t on 32bit systems
 5
 6Fixes format specifier mismatch warnings as well while here
 7
 8e.g.
 9warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'time_t'
10
11Upstream-Status: Pending
12
13Signed-off-by: Khem Raj <raj.khem@gmail.com>
14---
15 src/createrepo_c.c    | 4 ++--
16 src/misc.c            | 4 ++--
17 src/xml_dump_repomd.c | 2 +-
18 3 files changed, 5 insertions(+), 5 deletions(-)
19
20diff --git a/src/createrepo_c.c b/src/createrepo_c.c
21index 8681419..0f9048a 100644
22--- a/src/createrepo_c.c
23+++ b/src/createrepo_c.c
24@@ -582,9 +582,9 @@ duplicates_warning(const char *nevra, GArray *locations, CmdDupNevra option)
25   for (size_t i=0; i<locations->len; i++) {
26       struct DuplicateLocation location = g_array_index(locations, struct
27                                                         DuplicateLocation, i);
28-      g_warning("    Sourced from location: \'%s\', build timestamp: %ld%s",
29+      g_warning("    Sourced from location: \'%s\', build timestamp: %jd%s",
30                 location.location,
31-                location.pkg->time_build,
32+                (intmax_t) location.pkg->time_build,
33                 location.pkg->skip_dump ? skip_reason : "");
34 
35   }
36diff --git a/src/misc.c b/src/misc.c
37index 8511ca2..7866c7b 100644
38--- a/src/misc.c
39+++ b/src/misc.c
40@@ -1512,11 +1512,11 @@ cr_append_pid_and_datetime(const char *str, const char *suffix)
41     gettimeofday(&tv, NULL);
42     timeinfo = localtime (&(tv.tv_sec));
43     strftime(datetime, 80, "%Y%m%d%H%M%S", timeinfo);
44-    gchar *result = g_strdup_printf("%s%jd.%s.%ld%s",
45+    gchar *result = g_strdup_printf("%s%jd.%s.%jd%s",
46                                     str ? str : "",
47                                     (intmax_t) getpid(),
48                                     datetime,
49-                                    tv.tv_usec,
50+                                    (intmax_t) tv.tv_usec,
51                                     suffix ? suffix : "");
52     return result;
53 }
54diff --git a/src/xml_dump_repomd.c b/src/xml_dump_repomd.c
55index 33b0e09..9d24249 100644
56--- a/src/xml_dump_repomd.c
57+++ b/src/xml_dump_repomd.c
58@@ -143,7 +143,7 @@ cr_xml_dump_repomd_body(xmlNodePtr root, cr_Repomd *repomd)
59                            BAD_CAST repomd->revision);
60     } else {
61         // Use the current time if no revision was explicitly specified
62-        gchar *rev = g_strdup_printf("%ld", time(NULL));
63+        gchar *rev = g_strdup_printf("%jd", (intmax_t) time(NULL));
64         xmlNewChild(root, NULL, BAD_CAST "revision", BAD_CAST rev);
65         g_free(rev);
66     }
67-- 
682.41.0
69