diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2017-05-01 16:21:37 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2017-05-01 16:21:37 +0300 |
commit | 669a246c175a002e368404fc0037379900bcca04 (patch) | |
tree | 2d50a6775f2ede118fdd6ab3f1ad05a726a891b4 /um/service/src/windows_error.cpp | |
parent | um: strip the 'lib' prefix from namespace names (diff) | |
download | windows7-drivers-669a246c175a002e368404fc0037379900bcca04.tar.gz windows7-drivers-669a246c175a002e368404fc0037379900bcca04.zip |
service: refactoring
* No more compiler-specific macros.
Diffstat (limited to '')
-rw-r--r-- | um/service/src/windows_error.cpp | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/um/service/src/windows_error.cpp b/um/service/src/windows_error.cpp index 5b358ca..c228536 100644 --- a/um/service/src/windows_error.cpp +++ b/um/service/src/windows_error.cpp @@ -11,29 +11,32 @@ namespace service { - std::string WindowsErrorCategory::message(int code) const + namespace windows_error { - char* buf_ptr; + std::string Category::message(int code) const + { + char* buf_ptr; - const auto nbwritten = FormatMessageA( - FORMAT_MESSAGE_ALLOCATE_BUFFER - | FORMAT_MESSAGE_FROM_SYSTEM - | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - code, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - reinterpret_cast<char*>(&buf_ptr), - 0, - NULL); + const auto nbwritten = FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER + | FORMAT_MESSAGE_FROM_SYSTEM + | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + code, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + reinterpret_cast<char*>(&buf_ptr), + 0, + NULL); - if (0 == nbwritten) - { + if (0 == nbwritten) + { + LocalFree(buf_ptr); + return "Couldn't format the error message"; + } + + std::string str(buf_ptr, nbwritten - 2); LocalFree(buf_ptr); - return "Couldn't format error message"; + return str; } - - std::string str(buf_ptr, nbwritten - 2); - LocalFree(buf_ptr); - return str; } } |