Update openssl error handling. 01/71501/5
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 27 May 2016 06:55:01 +0000 (08:55 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 27 May 2016 07:52:28 +0000 (09:52 +0200)
ERROR_DUMP always clears the error queue. ERROR_CLEAR clears the queue
silently. One of them has to be called after an openssl error. ERROR_DUMP
should be called for errors that we do not recognize. ERROR_CLEAR for other
errors.

Change-Id: I90844271378a87f4897f66c9664edf60bcb1e218

src/debug.c
src/internal.h

index 2bdaa74..4192585 100644 (file)
@@ -42,8 +42,10 @@ API void yaca_debug_set_error_cb(yaca_error_cb fn)
 
 void error_dump(const char *file, int line, const char *function, int code)
 {
-       if (error_cb == NULL)
+       if (error_cb == NULL) {
+               ERR_clear_error();
                return;
+       }
 
        static const size_t BUF_SIZE = 512;
        static const char ELLIPSIS[] = "...\n";
index 0aa764a..0e87776 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <stddef.h>
 #include <openssl/ossl_typ.h>
+#include <openssl/err.h>
 
 #include <yaca/types.h>
 
@@ -102,5 +103,6 @@ struct yaca_key_evp_s *key_get_evp(const yaca_key_h key);
 
 void error_dump(const char *file, int line, const char *function, int code);
 #define ERROR_DUMP(code) error_dump(__FILE__, __LINE__, __func__, (code))
+#define ERROR_CLEAR() ERR_clear_error()
 
 #endif /* YACA_INTERNAL_H */