[Openvpn-devel,v2] httpdigest: replace IN/OUT macros with plain const

Message ID 20261111163935.6604-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v2] httpdigest: replace IN/OUT macros with plain const |

Commit Message

Gert Doering Nov. 11, 2026, 4:39 p.m. UTC
  From: Steffan Karger <steffan@karger.me>

httpdigest.h defines IN as const, and never undefines it. This leaks
into the pkcs11-helper headers that proxy.c includes later on, which
use IN/OUT as empty annotations and only define them if not defined
yet. That changes the pkcs11-helper declarations proxy.c sees ('IN
void * const' becomes 'const void * const'), and makes clang spit out
over a hundred -Wduplicate-decl-specifier warnings.

Just use const where we used IN, and drop OUT. No functional change.

Change-Id: I2490a0780a6e7c98a270e97b415b0387093d37be
Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Razvan Cojocaru <razvanc@mailbox.org>
Acked-by: Arne Schwabe <arne-openvpn@rfc2549.org>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2166
---

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/+/2166
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):
Razvan Cojocaru <razvanc@mailbox.org>
Arne Schwabe <arne-openvpn@rfc2549.org>
  

Patch

diff --git a/src/openvpn/httpdigest.c b/src/openvpn/httpdigest.c
index 52df383..9bfa074 100644
--- a/src/openvpn/httpdigest.c
+++ b/src/openvpn/httpdigest.c
@@ -32,7 +32,7 @@ 
 #include "httpdigest.h"
 
 static void
-CvtHex(IN HASH Bin, OUT HASHHEX Hex)
+CvtHex(const HASH Bin, HASHHEX Hex)
 {
     for (unsigned short i = 0; i < HASHLEN; i++)
     {
@@ -60,8 +60,8 @@ 
 
 /* calculate H(A1) as per spec */
 void
-DigestCalcHA1(IN char *pszAlg, IN char *pszUserName, IN char *pszRealm, IN char *pszPassword,
-              IN char *pszNonce, IN char *pszCNonce, OUT HASHHEX SessionKey)
+DigestCalcHA1(const char *pszAlg, const char *pszUserName, const char *pszRealm, const char *pszPassword,
+              const char *pszNonce, const char *pszCNonce, HASHHEX SessionKey)
 {
     HASH HA1;
     md_ctx_t *md5_ctx = md_ctx_new();
@@ -90,15 +90,15 @@ 
 
 /* calculate request-digest/response-digest as per HTTP Digest spec */
 void
-DigestCalcResponse(IN HASHHEX HA1,         /* H(A1) */
-                   IN char *pszNonce,      /* nonce from server */
-                   IN char *pszNonceCount, /* 8 hex digits */
-                   IN char *pszCNonce,     /* client nonce */
-                   IN char *pszQop,        /* qop-value: "", "auth", "auth-int" */
-                   IN char *pszMethod,     /* method from the request */
-                   IN char *pszDigestUri,  /* requested URL */
-                   IN HASHHEX HEntity,     /* H(entity body) if qop="auth-int" */
-                   OUT HASHHEX Response    /* request-digest or response-digest */
+DigestCalcResponse(const HASHHEX HA1,         /* H(A1) */
+                   const char *pszNonce,      /* nonce from server */
+                   const char *pszNonceCount, /* 8 hex digits */
+                   const char *pszCNonce,     /* client nonce */
+                   const char *pszQop,        /* qop-value: "", "auth", "auth-int" */
+                   const char *pszMethod,     /* method from the request */
+                   const char *pszDigestUri,  /* requested URL */
+                   const HASHHEX HEntity,     /* H(entity body) if qop="auth-int" */
+                   HASHHEX Response           /* request-digest or response-digest */
 )
 {
     HASH HA2;
diff --git a/src/openvpn/httpdigest.h b/src/openvpn/httpdigest.h
index 9f3b075..37f3d98 100644
--- a/src/openvpn/httpdigest.h
+++ b/src/openvpn/httpdigest.h
@@ -26,25 +26,21 @@ 
 typedef unsigned char HASH[HASHLEN];
 #define HASHHEXLEN 32
 typedef unsigned char HASHHEX[HASHHEXLEN + 1];
-#undef IN
-#undef OUT
-#define IN const
-#define OUT
 
 /* calculate H(A1) as per HTTP Digest spec */
-void DigestCalcHA1(IN char *pszAlg, IN char *pszUserName, IN char *pszRealm, IN char *pszPassword,
-                   IN char *pszNonce, IN char *pszCNonce, OUT HASHHEX SessionKey);
+void DigestCalcHA1(const char *pszAlg, const char *pszUserName, const char *pszRealm, const char *pszPassword,
+                   const char *pszNonce, const char *pszCNonce, HASHHEX SessionKey);
 
 /* calculate request-digest/response-digest as per HTTP Digest spec */
-void DigestCalcResponse(IN HASHHEX HA1,         /* H(A1) */
-                        IN char *pszNonce,      /* nonce from server */
-                        IN char *pszNonceCount, /* 8 hex digits */
-                        IN char *pszCNonce,     /* client nonce */
-                        IN char *pszQop,        /* qop-value: "", "auth", "auth-int" */
-                        IN char *pszMethod,     /* method from the request */
-                        IN char *pszDigestUri,  /* requested URL */
-                        IN HASHHEX HEntity,     /* H(entity body) if qop="auth-int" */
-                        OUT HASHHEX Response    /* request-digest or response-digest */
+void DigestCalcResponse(const HASHHEX HA1,         /* H(A1) */
+                        const char *pszNonce,      /* nonce from server */
+                        const char *pszNonceCount, /* 8 hex digits */
+                        const char *pszCNonce,     /* client nonce */
+                        const char *pszQop,        /* qop-value: "", "auth", "auth-int" */
+                        const char *pszMethod,     /* method from the request */
+                        const char *pszDigestUri,  /* requested URL */
+                        const HASHHEX HEntity,     /* H(entity body) if qop="auth-int" */
+                        HASHHEX Response           /* request-digest or response-digest */
 );
 
 #endif /* if PROXY_DIGEST_AUTH */