From: Bob Beck Date: Tue, 16 Jun 2026 18:49:52 +0000 (-0600) Subject: doc/man3/ASN1_aux_cb.pod: correct return code documentation for the callbacks X-Git-Url: http://git.ipfire.org/index.cgi?a=commitdiff_plain;ds=sidebyside;p=thirdparty%2Fopenssl.git doc/man3/ASN1_aux_cb.pod: correct return code documentation for the callbacks Attempt to make the documentation match the code. Not attempting to change what the code does at this point, it's all very random, and since it's been there, it is effectively established public API now. Reviewed-by: Nikola Pajkovsky Reviewed-by: Tomas Mraz Reviewed-by: Tim Hudson Reviewed-by: Eugene Syromiatnikov MergeDate: Mon Jun 22 11:56:58 2026 (Merged from https://github.com/openssl/openssl/pull/31549) --- diff --git a/doc/man3/ASN1_aux_cb.pod b/doc/man3/ASN1_aux_cb.pod index 68b230ca1af..9a38ab168ff 100644 --- a/doc/man3/ASN1_aux_cb.pod +++ b/doc/man3/ASN1_aux_cb.pod @@ -106,9 +106,11 @@ During the processing of an B object the callbacks set via I or I will be invoked as a result of various events indicated via the I parameter. The value of I<*in> will be the B object being processed based on the template in I. An -additional operation specific parameter may be passed in I. The currently -supported operations are as follows. The callbacks should return a positive -value on success or zero on error, unless otherwise noted below. +additional operation specific parameter may be passed in I. The +currently supported operations are as follows. Unless noted otherwise below, +the callbacks should return a positive value on success and zero on error; +some operations recognise additional return values, and a few do not consult +the return value at all. =over 4 @@ -130,13 +132,15 @@ I<*pval>. Invoked when processing a B, B or B structure immediately before an B is freed. If the callback originally constructed the B via B then it should free it at -this point and return 2 from the callback. Otherwise it should return 1 for -success or 0 on error. +this point and return 2; the caller will then skip its normal freeing. Any +other return value (including zero) causes the caller to proceed with normal +freeing; the hook cannot signal an error. =item B Invoked when processing a B, B or B structure -immediately after B sub-structures are freed. +immediately after B sub-structures are freed. The caller does not +consult the return value from this hook. =item B @@ -162,7 +166,10 @@ immediately after a "i2d" operation for the B. Invoked when processing a B or B structure immediately before printing the B. The I argument will be a pointer to an -B structure (see below). +B structure (see below). If the callback has fully printed the +value itself it should return 2; the caller will then skip the per-field +printing loop and the matching B callback. Return zero on +error or any other positive value to continue with normal printing. =item B @@ -260,8 +267,41 @@ The streaming I/O boundary. =head1 RETURN VALUES -The callbacks return 0 on error and a positive value on success. Some operations -require specific positive success values as noted above. +In general the callbacks return zero on error and a positive value on +success. Several operations have additional or different return-value +semantics, summarised here: + +=over 4 + +=item * + +B recognises a return of 2, meaning that the callback has +allocated the B itself and normal allocation should be skipped. + +=item * + +B recognises a return of 2, meaning that the callback has +freed the B itself and normal freeing should be skipped. Other +return values (including zero) cause normal freeing to proceed; the hook +cannot signal an error. + +=item * + +B's return value is not consulted by the caller. + +=item * + +B recognises a return of 2, meaning that the callback +has printed the value itself; the caller will skip the per-field printing +loop and the matching B invocation. + +=item * + +B, B, B, and +B treat any non-positive return value (zero or +negative) as an error. + +=back =head1 SEE ALSO