]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Modernize header macros for C23 compatibility
authorIgor Ustinov <igus68@gmail.com>
Sun, 2 Nov 2025 16:37:00 +0000 (17:37 +0100)
committerTomas Mraz <tomas@openssl.org>
Tue, 4 Nov 2025 15:02:11 +0000 (16:02 +0100)
Replace old-style (int (*)()) and (char *(*)()) casts with proper typed
prototypes (i2d_of_void *, d2i_of_void *, void *(*)(void)) to comply
with stricter C23 function pointer rules.

Fixes #27938

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29048)

include/openssl/dh.h
include/openssl/dsa.h
include/openssl/ocsp.h.in

index 97024929a40ded921070d821421e5b99ede7f1ad..8906eac4373f37c54940c33e0e17f944d867e6e2 100644 (file)
@@ -175,10 +175,10 @@ DECLARE_ASN1_ITEM(DHparams)
 #   define DH_CHECK_P_NOT_STRONG_PRIME     DH_CHECK_P_NOT_SAFE_PRIME
 
 #   define d2i_DHparams_fp(fp, x) \
-        (DH *)ASN1_d2i_fp((char *(*)())DH_new, \
-                          (char *(*)())d2i_DHparams, \
+        (DH *)ASN1_d2i_fp((void *(*)(void))DH_new, \
+                          (d2i_of_void *)d2i_DHparams, \
                           (fp), \
-                          (unsigned char **)(x))
+                          (void **)(x))
 #   define i2d_DHparams_fp(fp, x) \
         ASN1_i2d_fp(i2d_DHparams,(fp), (unsigned char *)(x))
 #   define d2i_DHparams_bio(bp, x) \
@@ -187,10 +187,10 @@ DECLARE_ASN1_ITEM(DHparams)
         ASN1_i2d_bio_of(DH, i2d_DHparams, bp, x)
 
 #   define d2i_DHxparams_fp(fp,x) \
-        (DH *)ASN1_d2i_fp((char *(*)())DH_new, \
-                          (char *(*)())d2i_DHxparams, \
+        (DH *)ASN1_d2i_fp((void *(*)(void))DH_new, \
+                          (d2i_of_void *)d2i_DHxparams, \
                           (fp), \
-                          (unsigned char **)(x))
+                          (void **)(x))
 #   define i2d_DHxparams_fp(fp, x) \
         ASN1_i2d_fp(i2d_DHxparams,(fp), (unsigned char *)(x))
 #   define d2i_DHxparams_bio(bp, x) \
index 109878e68863e9cd580386ddf19354c46288d699..245a46c7c32a0c90877dfdfc5e9cf29190e47509 100644 (file)
@@ -104,9 +104,9 @@ int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s);
 /* typedef struct dsa_method DSA_METHOD; */
 
 #   define d2i_DSAparams_fp(fp, x) \
-        (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \
-                           (char *(*)())d2i_DSAparams, (fp), \
-                           (unsigned char **)(x))
+        (DSA *)ASN1_d2i_fp((void *(*)(void))DSA_new, \
+                           (d2i_of_void *)d2i_DSAparams, (fp), \
+                           (void **)(x))
 #   define i2d_DSAparams_fp(fp, x) \
         ASN1_i2d_fp(i2d_DSAparams, (fp), (unsigned char *)(x))
 #   define d2i_DSAparams_bio(bp, x) \
index e2cc2716b56bd05666a35f1ffa26539d14bdf000..0481e11951d586b40a70bcbc4ed9bb1842948d00 100644 (file)
@@ -142,19 +142,19 @@ typedef struct ocsp_service_locator_st OCSP_SERVICELOC;
 #  define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p)
 
 #  define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \
-     (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST, \
+     (d2i_of_void *)d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST, \
      bp,(char **)(x),cb,NULL)
 
 #  define PEM_read_bio_OCSP_RESPONSE(bp,x,cb) (OCSP_RESPONSE *)PEM_ASN1_read_bio(\
-     (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE, \
+     (d2i_of_void *)d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE, \
      bp,(char **)(x),cb,NULL)
 
 #  define PEM_write_bio_OCSP_REQUEST(bp,o) \
-    PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\
+    PEM_ASN1_write_bio((i2d_of_void *)i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\
                         bp,(char *)(o), NULL,NULL,0,NULL,NULL)
 
 #  define PEM_write_bio_OCSP_RESPONSE(bp,o) \
-    PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\
+    PEM_ASN1_write_bio((i2d_of_void *)i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\
                         bp,(char *)(o), NULL,NULL,0,NULL,NULL)
 
 #  define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o)