Added a macro OSSL_DISPATCH_END as marker of the end of OSSL_DISPATCH arrays
authorIrak Rigia <tarakrigia@gmail.com>
Wed, 19 Apr 2023 14:06:29 +0000 (19:36 +0530)
committerTomas Mraz <tomas@openssl.org>
Fri, 21 Apr 2023 14:16:14 +0000 (16:16 +0200)
Also updated the corresponding documentations.

Fixes #20710

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20745)

doc/man3/OSSL_DISPATCH.pod
doc/man7/provider-base.pod
include/openssl/core.h
util/other.syms

index 1aca4019dcbc18b932a68f0761562ebd4549e4f0..52b7f3994505fbb8f618174882beeefd1d704eb3 100644 (file)
@@ -2,7 +2,7 @@
 
 =head1 NAME
 
-OSSL_DISPATCH - OpenSSL Core type to define a dispatchable function table
+OSSL_DISPATCH, OSSL_DISPATCH_END - OpenSSL Core type to define a dispatchable function table
 
 =head1 SYNOPSIS
 
@@ -14,14 +14,15 @@ OSSL_DISPATCH - OpenSSL Core type to define a dispatchable function table
      void (*function)(void);
  };
 
+ #define OSSL_DISPATCH_END
+
 =head1 DESCRIPTION
 
 This type is a tuple of function identity and function pointer.
 Arrays of this type are passed between the OpenSSL libraries and the
 providers to describe what functionality one side provides to the other.
 
-Arrays of this type must be terminated with a tuple having function identity
-zero and function pointer NULL.
+Arrays of this type must be terminated with the OSSL_DISPATCH_END macro.
 
 =head2 B<OSSL_DISPATCH> fields
 
index 4c38edb2353324b61e57ab5f0dd706dfe78c7ce8..9f50771b38f3df75b4c791677e6f2a1eefcad6d2 100644 (file)
@@ -751,7 +751,7 @@ operation C<BAR>.
 
  static const OSSL_ITEM reasons[] = {
      { E_MALLOC, "memory allocation failure" }.
-     { 0, NULL } /* Termination */
+     OSSL_DISPATCH_END
  };
 
  /*
@@ -831,7 +831,7 @@ operation C<BAR>.
      { OSSL_FUNC_BAR_INIT, (void (*)(void))foo_init },
      { OSSL_FUNC_BAR_UPDATE, (void (*)(void))foo_update },
      { OSSL_FUNC_BAR_FINAL, (void (*)(void))foo_final },
-     { 0, NULL }
+     OSSL_DISPATCH_END
  };
 
  static const OSSL_ALGORITHM bars[] = {
@@ -863,7 +863,7 @@ operation C<BAR>.
      { OSSL_FUNC_PROVIDER_TEARDOWN, (void (*)(void))p_teardown },
      { OSSL_FUNC_PROVIDER_QUERY_OPERATION, (void (*)(void))p_query },
      { OSSL_FUNC_PROVIDER_GET_REASON_STRINGS, (void (*)(void))p_reasons },
-     { 0, NULL }
+     OSSL_DISPATCH_END
  };
 
  int OSSL_provider_init(const OSSL_CORE_HANDLE *handle,
index 9683ac70a55cff6108da62f3e6817748c9dd1c98..b35392656cb843925e52d10077ad947381a388c5 100644 (file)
@@ -42,6 +42,9 @@ struct ossl_dispatch_st {
     void (*function)(void);
 };
 
+# define OSSL_DISPATCH_END \
+    { 0, NULL }
+
 /*
  * Other items, essentially an int<->pointer map element.
  *
index 91a1559b5d692500eb2d532a9ec49650ccba8e0d..daa3be067f1ce35393fd8fe82af10b37e1a6312f 100644 (file)
@@ -468,6 +468,7 @@ OSSL_PARAM_construct_TYPE               generic
 OSSL_PARAM_utf8_string                  define
 OSSL_PARAM_get_TYPE                     generic
 OSSL_PARAM_END                          define
+OSSL_DISPATCH_END                       define
 OSSL_PARAM_set_TYPE                     generic
 OSSL_ENCODER_PUBKEY_TO_DER_PQ           define
 OSSL_ENCODER_PrivateKey_TO_DER_PQ       define