From d7734ca783e900d8b3bb3bb6ada895dddc49fab9 Mon Sep 17 00:00:00 2001 From: Tomer Lev Date: Sun, 22 May 2022 07:43:36 +0000 Subject: [PATCH] Return the actual error code instead of a message when compiling to windows --- src/util.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util.cc b/src/util.cc index 9682cd7a87..5d0b9a8341 100644 --- a/src/util.cc +++ b/src/util.cc @@ -2547,7 +2547,12 @@ static void strerror_r_helper(int result, char* buf, size_t buflen) void zeek_strerror_r(int zeek_errno, char* buf, size_t buflen) { +#if defined(_MSC_VER) + auto str = "Error number: " + std::to_string(zeek_errno); + auto res = str.data(); +#else auto res = strerror_r(zeek_errno, buf, buflen); +#endif // GNU vs. XSI flavors make it harder to use strerror_r. strerror_r_helper(res, buf, buflen); }