clang-tidy on Windows
Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
f981c51eea
commit
bb311ba728
@ -1669,7 +1669,7 @@ std::string temporaryPath() {
|
||||
auto guard = std::scoped_lock(cs);
|
||||
|
||||
#if defined(_WIN32)
|
||||
HANDLE process = 0;
|
||||
HANDLE process = nullptr;
|
||||
DWORD pid = ::GetProcessId(process);
|
||||
#else
|
||||
pid_t pid = ::getpid();
|
||||
|
||||
@ -1280,15 +1280,15 @@ bool parseCmdLines(ModifyCmds& modifyCmds, const Params::CmdLines& cmdLines) {
|
||||
} // parseCmdLines
|
||||
|
||||
#ifdef _WIN32
|
||||
static std::string formatArg(const char* arg) {
|
||||
std::string result = "";
|
||||
std::string formatArg(const char* arg) {
|
||||
std::string result;
|
||||
char b = ' ';
|
||||
char e = '\\';
|
||||
std::string E = std::string("\\");
|
||||
char q = '\'';
|
||||
std::string Q = std::string("'");
|
||||
bool qt = false;
|
||||
char* a = (char*)arg;
|
||||
char* a = const_cast<char*>(arg);
|
||||
while (*a) {
|
||||
if (*a == b || *a == e || *a == q)
|
||||
qt = true;
|
||||
|
||||
@ -206,7 +206,6 @@ class QuickTimeVideo : public Image {
|
||||
*/
|
||||
void aspectRatio();
|
||||
|
||||
private:
|
||||
//! Variable which stores Time Scale unit, used to calculate time.
|
||||
uint64_t timeScale_ = 0;
|
||||
//! Variable which stores current stream being processsed.
|
||||
|
||||
@ -199,9 +199,9 @@ int FileIo::munmap() {
|
||||
#elif defined _WIN32
|
||||
UnmapViewOfFile(p_->pMappedArea_);
|
||||
CloseHandle(p_->hMap_);
|
||||
p_->hMap_ = 0;
|
||||
p_->hMap_ = nullptr;
|
||||
CloseHandle(p_->hFile_);
|
||||
p_->hFile_ = 0;
|
||||
p_->hFile_ = nullptr;
|
||||
#else
|
||||
#error Platforms without mmap are not supported. See https://github.com/Exiv2/exiv2/issues/2380
|
||||
if (p_->isWriteable_) {
|
||||
@ -259,19 +259,19 @@ byte* FileIo::mmap(bool isWriteable) {
|
||||
flProtect = PAGE_READWRITE;
|
||||
}
|
||||
HANDLE hPh = GetCurrentProcess();
|
||||
HANDLE hFd = (HANDLE)_get_osfhandle(fileno(p_->fp_));
|
||||
auto hFd = reinterpret_cast<HANDLE>(_get_osfhandle(fileno(p_->fp_)));
|
||||
if (hFd == INVALID_HANDLE_VALUE) {
|
||||
throw Error(ErrorCode::kerCallFailed, path(), "MSG1", "_get_osfhandle");
|
||||
}
|
||||
if (!DuplicateHandle(hPh, hFd, hPh, &p_->hFile_, 0, false, DUPLICATE_SAME_ACCESS)) {
|
||||
throw Error(ErrorCode::kerCallFailed, path(), "MSG2", "DuplicateHandle");
|
||||
}
|
||||
p_->hMap_ = CreateFileMapping(p_->hFile_, 0, flProtect, 0, (DWORD)p_->mappedLength_, 0);
|
||||
if (p_->hMap_ == 0) {
|
||||
p_->hMap_ = CreateFileMapping(p_->hFile_, nullptr, flProtect, 0, static_cast<DWORD>(p_->mappedLength_), nullptr);
|
||||
if (p_->hMap_ == nullptr) {
|
||||
throw Error(ErrorCode::kerCallFailed, path(), "MSG3", "CreateFileMapping");
|
||||
}
|
||||
void* rc = MapViewOfFile(p_->hMap_, dwAccess, 0, 0, 0);
|
||||
if (rc == 0) {
|
||||
if (rc == nullptr) {
|
||||
throw Error(ErrorCode::kerCallFailed, path(), "MSG4", "CreateFileMapping");
|
||||
}
|
||||
p_->pMappedArea_ = static_cast<byte*>(rc);
|
||||
@ -367,7 +367,7 @@ void FileIo::transfer(BasicIo& src) {
|
||||
using ReplaceFileA_t = BOOL(WINAPI*)(LPCSTR, LPCSTR, LPCSTR, DWORD, LPVOID, LPVOID);
|
||||
HMODULE hKernel = ::GetModuleHandleA("kernel32.dll");
|
||||
if (hKernel) {
|
||||
ReplaceFileA_t pfcn_ReplaceFileA = (ReplaceFileA_t)GetProcAddress(hKernel, "ReplaceFileA");
|
||||
auto pfcn_ReplaceFileA = reinterpret_cast<ReplaceFileA_t>(GetProcAddress(hKernel, "ReplaceFileA"));
|
||||
if (pfcn_ReplaceFileA) {
|
||||
BOOL ret =
|
||||
pfcn_ReplaceFileA(pf, fileIo->path().c_str(), nullptr, REPLACEFILE_IGNORE_MERGE_ERRORS, nullptr, nullptr);
|
||||
|
||||
@ -1439,7 +1439,7 @@ bool swapBytes(std::string& str) {
|
||||
bool mb2wc(UINT cp, std::string& str) {
|
||||
if (str.empty())
|
||||
return true;
|
||||
int len = MultiByteToWideChar(cp, 0, str.c_str(), (int)str.size(), 0, 0);
|
||||
int len = MultiByteToWideChar(cp, 0, str.c_str(), static_cast<int>(str.size()), nullptr, 0);
|
||||
if (len == 0) {
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
EXV_DEBUG << "mb2wc: Failed to determine required size of output buffer.\n";
|
||||
@ -1448,7 +1448,8 @@ bool mb2wc(UINT cp, std::string& str) {
|
||||
}
|
||||
std::vector<std::string::value_type> out;
|
||||
out.resize(len * 2);
|
||||
int ret = MultiByteToWideChar(cp, 0, str.c_str(), (int)str.size(), (LPWSTR)&out[0], len * 2);
|
||||
int ret = MultiByteToWideChar(cp, 0, str.c_str(), static_cast<int>(str.size()), reinterpret_cast<LPWSTR>(out.data()),
|
||||
len * 2);
|
||||
if (ret == 0) {
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
EXV_DEBUG << "mb2wc: Failed to convert the input string to a wide character string.\n";
|
||||
@ -1468,7 +1469,8 @@ bool wc2mb(UINT cp, std::string& str) {
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
int len = WideCharToMultiByte(cp, 0, (LPCWSTR)str.data(), (int)str.size() / 2, 0, 0, 0, 0);
|
||||
int len = WideCharToMultiByte(cp, 0, reinterpret_cast<LPCWSTR>(str.data()), static_cast<int>(str.size()) / 2, nullptr,
|
||||
0, nullptr, nullptr);
|
||||
if (len == 0) {
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
EXV_DEBUG << "wc2mb: Failed to determine required size of output buffer.\n";
|
||||
@ -1477,7 +1479,8 @@ bool wc2mb(UINT cp, std::string& str) {
|
||||
}
|
||||
std::vector<std::string::value_type> out;
|
||||
out.resize(len);
|
||||
int ret = WideCharToMultiByte(cp, 0, (LPCWSTR)str.data(), (int)str.size() / 2, (LPSTR)&out[0], len, 0, 0);
|
||||
int ret = WideCharToMultiByte(cp, 0, reinterpret_cast<LPCWSTR>(str.data()), static_cast<int>(str.size()) / 2,
|
||||
static_cast<LPSTR>(out.data()), len, nullptr, nullptr);
|
||||
if (ret == 0) {
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
EXV_DEBUG << "wc2mb: Failed to convert the input string to a multi byte string.\n";
|
||||
|
||||
@ -123,10 +123,10 @@ static std::vector<std::string> getLoadedLibraries() {
|
||||
// enumerate loaded libraries and determine path to executable
|
||||
HMODULE handles[200];
|
||||
DWORD cbNeeded;
|
||||
if (EnumProcessModules(GetCurrentProcess(), handles, DWORD(std::size(handles)), &cbNeeded)) {
|
||||
if (EnumProcessModules(GetCurrentProcess(), handles, static_cast<DWORD>(std::size(handles)), &cbNeeded)) {
|
||||
char szFilename[_MAX_PATH];
|
||||
for (DWORD h = 0; h < cbNeeded / sizeof(handles[0]); h++) {
|
||||
GetModuleFileNameA(handles[h], szFilename, DWORD(std::size(szFilename)));
|
||||
GetModuleFileNameA(handles[h], szFilename, static_cast<DWORD>(std::size(szFilename)));
|
||||
std::string path(szFilename);
|
||||
pushPath(path, libs, paths);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user