Some invalid handle values are -1 or INVALID_HANDLE_VALUE, hence our
handle template has a specific invalid handle value parameter we should
always test against. Time and again, I find my code simply comparing
handle against zero.
Signed-off-by: Simon Rozman <simon@rozman.si>
Using operator bool() hid ambiguity when handle was polymorfic with
bool. Using operator!() reqired !! to test for validity which results in
awkward code.
Signed-off-by: Simon Rozman <simon@rozman.si>
Using operator bool() hid ambiguity when handle was polymorfic with
bool. Using operator!() reqired !! to test for validity which results in
awkward code.
Signed-off-by: Simon Rozman <simon@rozman.si>
Using operator bool() hid ambiguity when handle was polymorfic with
bool. Using operator!() reqired !! to test for validity which results in
awkward code.
Signed-off-by: Simon Rozman <simon@rozman.si>
Code analysis got quite good and we'd better keep warnings on our radar.
Either:
1. Research and resolve the reason for the warning.
2. Remove silencing and let code analysis complain.
3. Comment why some warning silencing is there.
Signed-off-by: Simon Rozman <simon@rozman.si>
Visual Studio is using different output folder convention for Win32
builds. This makes it a royal-pain-in-the-ass to automate artifact
paths.
Signed-off-by: Simon Rozman <simon@rozman.si>
WinHTTP errors don't get resolved by FormatMessage by default. We need
to format them using WINHTTP.DLL resources.
Signed-off-by: Simon Rozman <simon@rozman.si>
When resources are compiled with /n (default), all strings are zero
terminated and LoadStringW returns number of characters including this
terminator.
Signed-off-by: Simon Rozman <simon@rozman.si>
This was overlooked in b7de0817889088bc524d0e6a9d9eff3e412aec49 and
2d9e445e1838d67ff642af06fb9417920e36ca7a.
Signed-off-by: Simon Rozman <simon@rozman.si>
Otherwise what() returns nullptr and it makes catch handlers somewhat
inconvenient if they need to test for this too.
Signed-off-by: Simon Rozman <simon@rozman.si>
It's trivial and used at the point from which no C++ exceptions are
expected, as the handle is no longer a subject to RAAI.
Signed-off-by: Simon Rozman <simon@rozman.si>
We generally don't care when our functions are called with invalid
arguments (validation should be performed on arguments input, not every
use). However, we do use asserts to validate arguments in Debug builds.
Unfortunately, this makes Code Analysis unhappy in the Release builds.
Let's make an exception on this one, since the check is not expensive
compared to the rest of the function.
Signed-off-by: Simon Rozman <simon@rozman.si>