diff options
Diffstat (limited to '')
-rw-r--r-- | src/cmd_line.hpp | 10 | ||||
-rw-r--r-- | src/error.cpp | 2 | ||||
-rw-r--r-- | src/process.cpp | 4 | ||||
-rw-r--r-- | src/sid.cpp | 2 |
4 files changed, 6 insertions, 12 deletions
diff --git a/src/cmd_line.hpp b/src/cmd_line.hpp index b7e1b70..18ea496 100644 --- a/src/cmd_line.hpp +++ b/src/cmd_line.hpp @@ -31,7 +31,7 @@ public: static CommandLine build_from_main(int argc, wchar_t* argv[]) { if (argc < 1) - throw std::range_error(__FUNCTION__ ": invalid argc value"); + throw std::range_error{"invalid argc value"}; std::wstring argv0{argv[0]}; --argc; @@ -82,21 +82,21 @@ public: return safe; } - static constexpr auto sep = L' '; + static constexpr wchar_t sep() { return L' '; } std::wstring join_args() const { - return string::join(sep, escape_args()); + return string::join(sep(), escape_args()); } std::wstring join() const { if (!has_argv0()) - throw std::logic_error(__FUNCTION__ ": doesn't have executable path"); + throw std::logic_error{"argv[0] isn't defined"}; std::wostringstream oss; oss << escape_argv0(); if (has_args()) - oss << sep << string::join(sep, escape_args()); + oss << sep() << string::join(sep(), escape_args()); return oss.str(); } diff --git a/src/error.cpp b/src/error.cpp index e0b4648..edce89f 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -3,8 +3,6 @@ // For details, see https://github.com/egor-tensin/privilege-check. // Distributed under the MIT License. -#pragma once - #include "error.hpp" #include <Windows.h> diff --git a/src/process.cpp b/src/process.cpp index 94765bc..a0618fa 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -23,7 +23,7 @@ namespace process const auto ret = GetModuleFileNameW(NULL, buf.data(), max_path); - if (GetLastError() != ERROR_SUCCESS) + if (ret != ERROR_SUCCESS) error::raise("GetModuleFileNameW"); return buf.data(); @@ -34,8 +34,6 @@ namespace process HWND hwnd, int nShow) { - static constexpr auto sep = L' '; - const auto exe_path = cmd_line.has_argv0() ? cmd_line.get_argv0() : get_executable_path(); diff --git a/src/sid.cpp b/src/sid.cpp index 4a86704..879e4a7 100644 --- a/src/sid.cpp +++ b/src/sid.cpp @@ -3,8 +3,6 @@ // For details, see https://github.com/egor-tensin/privilege-check. // Distributed under the MIT License. -#pragma once - #include "error.hpp" #include "sid.hpp" |