From be6fd465ded13b4dd5b8ea10834a296efb8f1424 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 14 Jan 2019 19:03:53 +0100 Subject: Return -2 if an error occured in NK_get_progress_bar_value NK_get_progress_bar_value returns the progress value from 0 to 100 or -1 if there is no pending operation. In the previous implementation, it also returned zero if an error occurred, making it impossible to distinguish progress zero and an error. Therefore, we change the return value to -2 if an error occured. --- NK_C_API.cc | 4 ++-- NK_C_API.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/NK_C_API.cc b/NK_C_API.cc index 7d0a10e..aa2d452 100644 --- a/NK_C_API.cc +++ b/NK_C_API.cc @@ -697,9 +697,9 @@ NK_C_API char* NK_get_SD_usage_data_as_string() { NK_C_API int NK_get_progress_bar_value() { auto m = NitrokeyManager::instance(); - return get_with_result([&]() { + return std::get<1>(get_with_status([&]() { return m->get_progress_bar_value(); - }); + }, -2)); } NK_C_API int NK_get_major_firmware_version() { diff --git a/NK_C_API.h b/NK_C_API.h index b1bdf1e..43e5631 100644 --- a/NK_C_API.h +++ b/NK_C_API.h @@ -747,7 +747,8 @@ extern "C" { /** * Get progress value of current long operation. * Storage only - * @return int in range 0-100 or -1 if device is not busy + * @return int in range 0-100 or -1 if device is not busy or -2 if an + * error occured */ NK_C_API int NK_get_progress_bar_value(); -- cgit v1.2.1