Clarify ERR_print_errors_* clear the error queue.
Change-Id: Ifaa0129cbacb2346a8d206436eca783060181a85
Reviewed-on: https://boringssl-review.googlesource.com/20004
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/crypto/test/gtest_main.h b/crypto/test/gtest_main.h
index 759aaf7..d21af10 100644
--- a/crypto/test/gtest_main.h
+++ b/crypto/test/gtest_main.h
@@ -38,13 +38,14 @@
~ErrorTestEventListener() override {}
void OnTestEnd(const testing::TestInfo &test_info) override {
- // If the test failed, print any errors left in the error queue.
if (test_info.result()->Failed()) {
+ // The test failed. Print any errors left in the error queue.
ERR_print_errors_fp(stdout);
+ } else {
+ // The test succeeded, so any failed operations are expected. Clear the
+ // error queue without printing.
+ ERR_clear_error();
}
-
- // Clean up the error queue for the next run.
- ERR_clear_error();
}
};
diff --git a/include/openssl/err.h b/include/openssl/err.h
index 63e79d5..0a64925 100644
--- a/include/openssl/err.h
+++ b/include/openssl/err.h
@@ -224,17 +224,14 @@
typedef int (*ERR_print_errors_callback_t)(const char *str, size_t len,
void *ctx);
-// ERR_print_errors_cb calls |callback| with a string representation of each
-// error in the current thread's error queue, from the least recent to the most
-// recent error.
+// ERR_print_errors_cb clears the current thread's error queue, calling
+// |callback| with a string representation of each error, from the least recent
+// to the most recent error.
//
// The string will have the following format (which differs from
// |ERR_error_string|):
//
-// [thread id]:error:[error code]:[library name]:OPENSSL_internal:
-// [reason string]:[file]:[line number]:[optional string data]
-//
-// (All in one line.)
+// [thread id]:error:[error code]:[library name]:OPENSSL_internal:[reason string]:[file]:[line number]:[optional string data]
//
// The callback can return one to continue the iteration or zero to stop it.
// The |ctx| argument is an opaque value that is passed through to the
@@ -242,8 +239,8 @@
OPENSSL_EXPORT void ERR_print_errors_cb(ERR_print_errors_callback_t callback,
void *ctx);
-// ERR_print_errors_fp prints the current contents of the error stack to |file|
-// using human readable strings where possible.
+// ERR_print_errors_fp clears the current thread's error queue, printing each
+// error to |file|. See |ERR_print_errors_cb| for the format.
OPENSSL_EXPORT void ERR_print_errors_fp(FILE *file);