aboutsummaryrefslogtreecommitdiff
path: root/fuzzers/include/fuzzing.hh
diff options
context:
space:
mode:
Diffstat (limited to 'fuzzers/include/fuzzing.hh')
-rw-r--r--fuzzers/include/fuzzing.hh16
1 files changed, 13 insertions, 3 deletions
diff --git a/fuzzers/include/fuzzing.hh b/fuzzers/include/fuzzing.hh
index e4f5eb9..b27c396 100644
--- a/fuzzers/include/fuzzing.hh
+++ b/fuzzers/include/fuzzing.hh
@@ -53,13 +53,15 @@ T check_errno(
return value;
}
-size_t check_session(
- OlmSession * session,
+template<typename T, typename F>
+size_t check_error(
+ F f,
+ T * object,
const char * message,
size_t value
) {
if (value == olm_error()) {
- const char * olm_message = olm_session_last_error(session);
+ const char * olm_message = f(object);
ssize_t ignored;
ignored = write(STDERR_FILENO, message, strlen(message));
ignored = write(STDERR_FILENO, ": ", 2);
@@ -70,3 +72,11 @@ size_t check_session(
}
return value;
}
+
+size_t check_session(
+ OlmSession * session,
+ const char * message,
+ size_t value
+) {
+ return check_error(olm_session_last_error, session, message, value);
+}