]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
approxidate: fix empty struct init in C++
authorEric Wong <e@80x24.org>
Fri, 28 Nov 2025 10:09:46 +0000 (10:09 +0000)
committerEric Wong <e@80x24.org>
Mon, 1 Dec 2025 10:25:11 +0000 (10:25 +0000)
C++ and C differs in how empty structs are initialized :x
This was probably harmless or (at worst) caused some search
results to be bogus.

lib/PublicInbox/approxidate.h

index 2ddd02568c59f86ee9ea4c7e8e70e026a3519acc..a5fcf13838d7691549d3f7f305d1834de82c43bb 100644 (file)
@@ -7,6 +7,11 @@
 #include <stdlib.h>
 #include <time.h>
 typedef int64_t git_time_t; // libgit2 include/git2/types.h
+#ifdef __cplusplus
+#      define EMPTY_STRUCT_INIT {}
+#else
+#      define EMPTY_STRUCT_INIT { 0 }
+#endif // C++
 
 // libgit2 src/util/util.h
 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(*x))
@@ -824,7 +829,7 @@ static git_time_t approxidate_str(const char *date, time_t time_sec,
 {
        int number = 0;
        int touched = 0;
-       struct tm tm = {0}, now;
+       struct tm tm = EMPTY_STRUCT_INIT, now;
 
        localtime_r(&time_sec, &tm);
        now = tm;