From 8ebf69da7e48e9aa4693bc30cc49bf9bfbfbf999 Mon Sep 17 00:00:00 2001 From: Peter Meerwald-Stadler Date: Fri, 10 Dec 2021 17:05:35 +0100 Subject: [PATCH 1/3] Use C++ includes --- src/build.cpp | 6 +++--- src/error.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/build.cpp b/src/build.cpp index c1b425f..5f3d88f 100644 --- a/src/build.cpp +++ b/src/build.cpp @@ -5,9 +5,9 @@ #include "fs.hpp" #include -#include +#include #include -#include +#include #include namespace cmkr { @@ -94,4 +94,4 @@ int cmkr_build_install(void) { } catch (...) { return cmkr::error::Status(cmkr::error::Status::Code::InstallError); } -} \ No newline at end of file +} diff --git a/src/error.cpp b/src/error.cpp index a8d2552..853b814 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -1,6 +1,6 @@ #include "error.hpp" -#include +#include namespace cmkr { namespace error { From 19101cd7267ee157cf021fd66ae27283dd7b12e2 Mon Sep 17 00:00:00 2001 From: Peter Meerwald-Stadler Date: Fri, 10 Dec 2021 17:06:16 +0100 Subject: [PATCH 2/3] Reduce scope of err_string; add missing error codes --- src/error.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/error.cpp b/src/error.cpp index 853b814..ef2423d 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -14,8 +14,9 @@ Status::Code Status::code() const noexcept { return ec_; } } // namespace error } // namespace cmkr -const char *err_string[] = { - "Success", "Runtime error", "Initialization error", "CMake generation error", "Build error", +// strings for cmkr::error::Status::Code +static const char *err_string[] = { + "Success", "Runtime error", "Initialization error", "CMake generation error", "Build error", "Clean error", "Install error", }; const char *cmkr_error_status(int i) { From 31cc1c94819ec3791cbc4de9df2d473b0b57706e Mon Sep 17 00:00:00 2001 From: Peter Meerwald-Stadler Date: Fri, 10 Dec 2021 17:07:11 +0100 Subject: [PATCH 3/3] Avoid explicit number of error strings in cmkr_error_status() --- src/error.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/error.cpp b/src/error.cpp index ef2423d..1415bbe 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -20,6 +20,6 @@ static const char *err_string[] = { }; const char *cmkr_error_status(int i) { - assert(i >= 0 && i < 5); + assert(i >= 0 && i < (sizeof(err_string) / sizeof(*(err_string)))); return err_string[i]; -} \ No newline at end of file +}