Fix warnings from Clang (#421)

Clang 9 (in Visual Studio) complains about a mixed signed-unsigned comparison and an unused function.
Replace the naked `int` constant -1 by `std::size_t(-1)` with the same codegen as before (no curlies to avoid narrowing).
Guard the definition of `get_download_folder()` by the same condition as its call-site.

Signed-off-by: Daniela Engert <dani@ngrt.de>
This commit is contained in:
Daniela Engert
2019-03-20 01:25:59 +01:00
committed by Howard Hinnant
parent e31daf8093
commit 10ab6ae9e5

View File

@@ -212,7 +212,7 @@ get_known_folder(const GUID& folderid)
const wchar_t* fptr = folder_ptr.get(); const wchar_t* fptr = folder_ptr.get();
auto state = std::mbstate_t(); auto state = std::mbstate_t();
const auto required = std::wcsrtombs(nullptr, &fptr, 0, &state); const auto required = std::wcsrtombs(nullptr, &fptr, 0, &state);
if (required != 0 && required != -1) if (required != 0 && required != std::size_t(-1))
{ {
folder.resize(required); folder.resize(required);
std::wcsrtombs(&folder[0], &fptr, folder.size(), &state); std::wcsrtombs(&folder[0], &fptr, folder.size(), &state);
@@ -221,6 +221,8 @@ get_known_folder(const GUID& folderid)
return folder; return folder;
} }
# ifndef INSTALL
// Usually something like "c:\Users\username\Downloads". // Usually something like "c:\Users\username\Downloads".
static static
std::string std::string
@@ -229,6 +231,8 @@ get_download_folder()
return get_known_folder(FOLDERID_Downloads); return get_known_folder(FOLDERID_Downloads);
} }
# endif // !INSTALL
# endif // WINRT # endif // WINRT
# else // !_WIN32 # else // !_WIN32