[Openvpn-devel,v1] test_options_parse: Do not use uintmax_t instead of LargestIntegralType

Message ID 20251008133338.23652-1-gert@greenie.muc.de
State New
Headers show
Series [Openvpn-devel,v1] test_options_parse: Do not use uintmax_t instead of LargestIntegralType | expand

Commit Message

Gert Doering Oct. 8, 2025, 1:33 p.m. UTC
From: Frank Lichtenheld <frank@lichtenheld.com>

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
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1256
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <gert@greenie.muc.de>

Comments

Gert Doering Oct. 8, 2025, 1:40 p.m. UTC | #1
Explanation makes sense, code change appeases the loud complaints from
OpenBSD BB with -Werror.  In it goes :-)

Your patch has been applied to the master branch.

commit 5b8e0563f950aa5d246f32785afffd8824d9f9ab
Author: Frank Lichtenheld
Date:   Wed Oct 8 15:33:31 2025 +0200

     test_options_parse: Do not use uintmax_t instead of LargestIntegralType

     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>


--
kind regards,

Gert Doering

Patch

diff --git a/tests/unit_tests/openvpn/test_options_parse.c b/tests/unit_tests/openvpn/test_options_parse.c
index e552dd7..0ae37f5 100644
--- a/tests/unit_tests/openvpn/test_options_parse.c
+++ b/tests/unit_tests/openvpn/test_options_parse.c
@@ -198,14 +198,25 @@ 
                        &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;