Browse code

test_options_parse: Do not use uintmax_t instead of LargestIntegralType

At least on OpenBSD it seems that uintmax_t maps
to unsigned long long always, but LargestIntegralType
is unsigned long. So if we have a version of cmocka.h
that defines LargestIntegralType then respect that.

Change-Id: I59a49696acd665d43b21e5c23f24b86c15989cd6
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1256
Message-Id: <20251008133338.23652-1-gert@greenie.muc.de>
URL: https://sourceforge.net/p/openvpn/mailman/message/59243971/
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Frank Lichtenheld authored on 2025/10/08 22:33:31
Showing 1 changed files
... ...
@@ -198,14 +198,25 @@ read_single_config(struct options *options, const char *config)
198 198
                        &option_types_found, &es);
199 199
 }
200 200
 
201
+/* compat with various versions of cmocka.h
202
+ * Older versions have LargestIntegralType. Newer
203
+ * versions use uintmax_t. But LargestIntegralType
204
+ * is not guaranteed to be equal to uintmax_t, so
205
+ * we can't use that unconditionally. So we only use
206
+ * it if cmocka.h does not define LargestIntegralType.
207
+ */
208
+#ifndef LargestIntegralType
209
+#define LargestIntegralType uintmax_t
210
+#endif
211
+
201 212
 union tokens_parameter
202 213
 {
203
-    uintmax_t as_int;
214
+    LargestIntegralType as_int;
204 215
     void *as_pointer;
205 216
 };
206 217
 
207 218
 static int
208
-check_tokens(const uintmax_t value, const uintmax_t expected)
219
+check_tokens(const LargestIntegralType value, const LargestIntegralType expected)
209 220
 {
210 221
     union tokens_parameter temp;
211 222
     temp.as_int = value;