]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
test_options_parse: Do not use uintmax_t instead of LargestIntegralType
authorFrank Lichtenheld <frank@lichtenheld.com>
Wed, 8 Oct 2025 13:33:31 +0000 (15:33 +0200)
committerGert Doering <gert@greenie.muc.de>
Wed, 8 Oct 2025 13:38:43 +0000 (15:38 +0200)
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>
tests/unit_tests/openvpn/test_options_parse.c

index e552dd70c6f8cd0cab7995b0364ca0eea364c7ee..0ae37f597ba9dbc88d1d3982a327c03cd71ffbd7 100644 (file)
@@ -198,14 +198,25 @@ read_single_config(struct options *options, const char *config)
                        &option_types_found, &es);
 }
 
+/* compat with various versions of cmocka.h
+ * Older versions have LargestIntegralType. Newer
+ * versions use uintmax_t. But LargestIntegralType
+ * is not guaranteed to be equal to uintmax_t, so
+ * we can't use that unconditionally. So we only use
+ * it if cmocka.h does not define LargestIntegralType.
+ */
+#ifndef LargestIntegralType
+#define LargestIntegralType uintmax_t
+#endif
+
 union tokens_parameter
 {
-    uintmax_t as_int;
+    LargestIntegralType as_int;
     void *as_pointer;
 };
 
 static int
-check_tokens(const uintmax_t value, const uintmax_t expected)
+check_tokens(const LargestIntegralType value, const LargestIntegralType expected)
 {
     union tokens_parameter temp;
     temp.as_int = value;