From 0aad4de5f494900c042b8f137bb6ca31b2ea3bc7 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 27 Aug 2018 09:25:24 +0200 Subject: [PATCH] error: Add ssh_reset_error() function Signed-off-by: Andreas Schneider --- include/libssh/priv.h | 1 + src/error.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/libssh/priv.h b/include/libssh/priv.h index 16c62007..0aab4edb 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -232,6 +232,7 @@ void _ssh_set_error_oom(void *error, const char *function); _ssh_set_error_invalid(error, __func__) void _ssh_set_error_invalid(void *error, const char *function); +void ssh_reset_error(void *error); /* server.c */ #ifdef WITH_SERVER diff --git a/src/error.c b/src/error.c index aa0f4624..22180407 100644 --- a/src/error.c +++ b/src/error.c @@ -103,6 +103,21 @@ void _ssh_set_error_invalid(void *error, const char *function) "Invalid argument in %s", function); } +/** + * @internal + * + * @brief Reset the error code and message + * + * @param error The place to reset the error. + */ +void ssh_reset_error(void *error) +{ + struct ssh_common_struct *err = error; + + ZERO_STRUCT(err->error.error_buffer); + err->error.error_code = 0; +} + /** * @brief Retrieve the error text message from the last error. *