Commit 8f1a0ef5 authored by Sven Strickroth's avatar Sven Strickroth Committed by ch3cooli

Refactoring: Reduce C-style casts and drop unneeded casts

Signed-off-by: Sven Strickroth's avatarSven Strickroth <email@cs-ware.de>
Signed-off-by: ch3cooli's avatarSup Yut Sum <ch3cooli@gmail.com>
parent 09ae16a6
/***************************************************************************
/***************************************************************************
* Copyright (C) 2009-2011 by Stefan Fuhrmann *
* stefanfuhrmann@alice-dsl.de *
* *
......@@ -282,7 +282,7 @@ CJobScheduler::TJob CJobScheduler::AssignJob (SThreadInfo* info)
break;
}
return TJob ((IJob*)NULL, terminateThread);
return TJob(static_cast<IJob*>(nullptr), terminateThread);
}
// extract one job
......@@ -703,4 +703,4 @@ size_t CJobScheduler::GetHWThreadCount()
return sysNumProcs;
}
}
\ No newline at end of file
}
This diff is collapsed.
......@@ -439,12 +439,12 @@ public:
{
winTime -= 116444736000000000LL; /* Windows to Unix Epoch conversion */
winTime /= 10000000; /* Nano to seconds resolution */
return (time_t)winTime;
return static_cast<time_t>(winTime);
}
static inline __int64 filetime_to_time_t(const FILETIME *ft)
{
return filetime_to_time_t(((__int64)ft->dwHighDateTime << 32) + ft->dwLowDateTime);
return filetime_to_time_t(static_cast<__int64>(ft->dwHighDateTime) << 32 | ft->dwLowDateTime);
}
static int GetFileModifyTime(LPCTSTR filename, __int64* time, bool* isDir = nullptr, __int64* size = nullptr, bool* isSymlink = nullptr)
......@@ -452,11 +452,11 @@ public:
WIN32_FILE_ATTRIBUTE_DATA fdata;
if (GetFileAttributesEx(filename, GetFileExInfoStandard, &fdata))
{
if(time)
*time = ((__int64)fdata.ftLastWriteTime.dwHighDateTime << 32) + fdata.ftLastWriteTime.dwLowDateTime;
if (time)
*time = static_cast<__int64>(fdata.ftLastWriteTime.dwHighDateTime) << 32 | fdata.ftLastWriteTime.dwLowDateTime;
if (size)
*size = ((__int64)fdata.nFileSizeHigh << 32) + fdata.nFileSizeLow;
*size = static_cast<__int64>(fdata.nFileSizeHigh) << 32 | fdata.nFileSizeLow;
if(isDir)
*isDir = !!( fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
......@@ -478,7 +478,7 @@ public:
{
shortname = ref.Right(ref.GetLength() - prefix.GetLength());
if (CStringUtils::EndsWith(shortname, L"^{}"))
shortname.Truncate(shortname.GetLength() - (int)wcslen(L"^{}"));
shortname.Truncate(shortname.GetLength() - static_cast<int>(wcslen(L"^{}")));
return TRUE;
}
return FALSE;
......
......@@ -162,7 +162,7 @@ bool GitAdminDir::GetAdminDirPath(const CString& projectTopDir, CString& adminDi
int size = 65536;
CStringA commonDirA;
int length = (int)fread(commonDirA.GetBufferSetLength(size), sizeof(char), size, pFile);
int length = static_cast<int>(fread(commonDirA.GetBufferSetLength(size), sizeof(char), size, pFile));
commonDirA.ReleaseBuffer(length);
CString commonDir = CUnicodeUtils::GetUnicode(commonDirA);
commonDir.TrimRight(L"\r\n");
......@@ -209,13 +209,13 @@ CString GitAdminDir::ReadGitLink(const CString& topDir, const CString& dotGitPat
int size = 65536;
auto buffer = std::make_unique<char[]>(size);
int length = (int)fread(buffer.get(), sizeof(char), size, pFile);
int length = static_cast<int>(fread(buffer.get(), sizeof(char), size, pFile));
CStringA gitPathA(buffer.get(), length);
if (length < 8 || !CStringUtils::StartsWith(gitPathA, "gitdir: "))
return L"";
CString gitPath = CUnicodeUtils::GetUnicode(gitPathA);
// trim after converting to UTF-16, because CStringA trim does not work when having UTF-8 chars
gitPath = gitPath.Trim().Mid((int)wcslen(L"gitdir: "));
gitPath = gitPath.Trim().Mid(static_cast<int>(wcslen(L"gitdir: ")));
if (gitPath.IsEmpty())
return gitPath;
......
// TortoiseGit - a Windows shell extension for easy version control
// Copyright (C) 2016-2018 - TortoiseGit
// Copyright (C) 2016-2019 - TortoiseGit
// Copyright (C) 2007-2014 - TortoiseSVN
// This program is free software; you can redistribute it and/or
......@@ -25,12 +25,12 @@
#include "StringUtils.h"
#include <strsafe.h>
CLIPFORMAT CF_FILECONTENTS = (CLIPFORMAT)RegisterClipboardFormat(CFSTR_FILECONTENTS);
CLIPFORMAT CF_FILEDESCRIPTOR = (CLIPFORMAT)RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR);
CLIPFORMAT CF_PREFERREDDROPEFFECT = (CLIPFORMAT)RegisterClipboardFormat(CFSTR_PREFERREDDROPEFFECT);
CLIPFORMAT CF_INETURL = (CLIPFORMAT)RegisterClipboardFormat(CFSTR_INETURL);
CLIPFORMAT CF_SHELLURL = (CLIPFORMAT)RegisterClipboardFormat(CFSTR_SHELLURL);
CLIPFORMAT CF_FILE_ATTRIBUTES_ARRAY = (CLIPFORMAT)RegisterClipboardFormat(CFSTR_FILE_ATTRIBUTES_ARRAY);
CLIPFORMAT CF_FILECONTENTS = static_cast<CLIPFORMAT>(RegisterClipboardFormat(CFSTR_FILECONTENTS));
CLIPFORMAT CF_FILEDESCRIPTOR = static_cast<CLIPFORMAT>(RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR));
CLIPFORMAT CF_PREFERREDDROPEFFECT = static_cast<CLIPFORMAT>(RegisterClipboardFormat(CFSTR_PREFERREDDROPEFFECT));
CLIPFORMAT CF_INETURL = static_cast<CLIPFORMAT>(RegisterClipboardFormat(CFSTR_INETURL));
CLIPFORMAT CF_SHELLURL = static_cast<CLIPFORMAT>(RegisterClipboardFormat(CFSTR_SHELLURL));
CLIPFORMAT CF_FILE_ATTRIBUTES_ARRAY = static_cast<CLIPFORMAT>(RegisterClipboardFormat(CFSTR_FILE_ATTRIBUTES_ARRAY));
GitDataObject::GitDataObject(const CTGitPathList& gitpaths, const CGitHash& rev, int stripLength)
: m_gitPaths(gitpaths)
......@@ -129,13 +129,13 @@ STDMETHODIMP GitDataObject::GetData(FORMATETC* pformatetcIn, STGMEDIUM* pmedium)
if (m_revision.IsEmpty())
{
if ((pformatetcIn->lindex >= 0) && (pformatetcIn->lindex < (LONG)m_allPaths.size()))
if (pformatetcIn->lindex >= 0 && pformatetcIn->lindex < static_cast<LONG>(m_allPaths.size()))
filepath = g_Git.CombinePath(m_allPaths[pformatetcIn->lindex]);
}
else
{
filepath = CTempFiles::Instance().GetTempFilePath(true).GetWinPathString();
if ((pformatetcIn->lindex >= 0) && (pformatetcIn->lindex < (LONG)m_allPaths.size()))
if (pformatetcIn->lindex >= 0 && pformatetcIn->lindex < static_cast<LONG>(m_allPaths.size()))
{
if (g_Git.GetOneFile(m_revision.ToString(), m_allPaths[pformatetcIn->lindex], filepath))
{
......@@ -167,17 +167,17 @@ STDMETHODIMP GitDataObject::GetData(FORMATETC* pformatetcIn, STGMEDIUM* pmedium)
m_allPaths.push_back(m_gitPaths[i]);
}
size_t dataSize = sizeof(FILEGROUPDESCRIPTOR) + ((max((size_t)1, m_allPaths.size()) - 1) * sizeof(FILEDESCRIPTOR));
size_t dataSize = sizeof(FILEGROUPDESCRIPTOR) + ((max(size_t(1), m_allPaths.size()) - 1) * sizeof(FILEDESCRIPTOR));
HGLOBAL data = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE | GMEM_ZEROINIT, dataSize);
FILEGROUPDESCRIPTOR* files = (FILEGROUPDESCRIPTOR*)GlobalLock(data);
auto files = static_cast<FILEGROUPDESCRIPTOR*>(GlobalLock(data));
files->cItems = static_cast<UINT>(m_allPaths.size());
int index = 0;
for (auto it = m_allPaths.cbegin(); it != m_allPaths.cend(); ++it)
{
CString temp(m_iStripLength > 0 ? it->GetWinPathString().Mid(m_iStripLength + 1) : (m_iStripLength == 0 ? it->GetWinPathString() : it->GetUIFileOrDirectoryName()));
if (temp.GetLength() < MAX_PATH)
wcscpy_s(files->fgd[index].cFileName, (LPCTSTR)temp);
wcscpy_s(files->fgd[index].cFileName, static_cast<LPCTSTR>(temp));
else
{
files->cItems--;
......@@ -213,7 +213,7 @@ STDMETHODIMP GitDataObject::GetData(FORMATETC* pformatetcIn, STGMEDIUM* pmedium)
HGLOBAL data = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE | GMEM_ZEROINIT, sizeof(DWORD));
if (!data)
return E_OUTOFMEMORY;
DWORD* effect = (DWORD*)GlobalLock(data);
auto effect = static_cast<DWORD*>(GlobalLock(data));
if (!effect)
{
GlobalFree(data);
......@@ -244,8 +244,8 @@ STDMETHODIMP GitDataObject::GetData(FORMATETC* pformatetcIn, STGMEDIUM* pmedium)
pmedium->hGlobal = GlobalAlloc(GHND, (texta.GetLength() + 1) * sizeof(char));
if (pmedium->hGlobal)
{
char* pMem = (char*)GlobalLock(pmedium->hGlobal);
strcpy_s(pMem, texta.GetLength() + 1, (LPCSTR)texta);
auto pMem = static_cast<char*>(GlobalLock(pmedium->hGlobal));
strcpy_s(pMem, texta.GetLength() + 1, static_cast<LPCSTR>(texta));
GlobalUnlock(pmedium->hGlobal);
}
pmedium->pUnkForRelease = nullptr;
......@@ -272,8 +272,8 @@ STDMETHODIMP GitDataObject::GetData(FORMATETC* pformatetcIn, STGMEDIUM* pmedium)
pmedium->hGlobal = GlobalAlloc(GHND, (text.GetLength() + 1) * sizeof(TCHAR));
if (pmedium->hGlobal)
{
TCHAR* pMem = (TCHAR*)GlobalLock(pmedium->hGlobal);
wcscpy_s(pMem, text.GetLength() + 1, (LPCTSTR)text);
auto pMem = static_cast<TCHAR*>(GlobalLock(pmedium->hGlobal));
wcscpy_s(pMem, text.GetLength() + 1, static_cast<LPCTSTR>(text));
GlobalUnlock(pmedium->hGlobal);
}
pmedium->pUnkForRelease = nullptr;
......@@ -296,11 +296,11 @@ STDMETHODIMP GitDataObject::GetData(FORMATETC* pformatetcIn, STGMEDIUM* pmedium)
auto pBuffer = std::make_unique<char[]>(nBufferSize);
SecureZeroMemory(pBuffer.get(), nBufferSize);
DROPFILES* df = (DROPFILES*)pBuffer.get();
auto df = reinterpret_cast<DROPFILES*>(pBuffer.get());
df->pFiles = sizeof(DROPFILES);
df->fWide = 1;
TCHAR* pFilenames = (TCHAR*)(pBuffer.get() + sizeof(DROPFILES));
auto pFilenames = reinterpret_cast<TCHAR*>(pBuffer.get() + sizeof(DROPFILES));
TCHAR* pCurrentFilename = pFilenames;
for (int i = 0; i < m_gitPaths.GetCount(); ++i)
......@@ -308,7 +308,7 @@ STDMETHODIMP GitDataObject::GetData(FORMATETC* pformatetcIn, STGMEDIUM* pmedium)
if (m_gitPaths[i].m_Action & (CTGitPath::LOGACTIONS_MISSING | CTGitPath::LOGACTIONS_DELETED) || m_gitPaths[i].IsDirectory())
continue;
CString str = g_Git.CombinePath(m_gitPaths[i]);
wcscpy_s(pCurrentFilename, str.GetLength() + 1, (LPCWSTR)str);
wcscpy_s(pCurrentFilename, str.GetLength() + 1, static_cast<LPCWSTR>(str));
pCurrentFilename += str.GetLength();
*pCurrentFilename = '\0'; // separator between file names
pCurrentFilename++;
......@@ -333,7 +333,7 @@ STDMETHODIMP GitDataObject::GetData(FORMATETC* pformatetcIn, STGMEDIUM* pmedium)
auto pBuffer = std::make_unique<char[]>(nBufferSize);
SecureZeroMemory(pBuffer.get(), nBufferSize);
FILE_ATTRIBUTES_ARRAY* cf = (FILE_ATTRIBUTES_ARRAY*)pBuffer.get();
auto cf = reinterpret_cast<FILE_ATTRIBUTES_ARRAY*>(pBuffer.get());
cf->cItems = m_gitPaths.GetCount();
cf->dwProductFileAttributes = DWORD_MAX;
cf->dwSumFileAttributes = 0;
......@@ -528,19 +528,19 @@ void GitDataObject::CopyMedium(STGMEDIUM* pMedDest, STGMEDIUM* pMedSrc, FORMATET
switch (pMedSrc->tymed)
{
case TYMED_HGLOBAL:
pMedDest->hGlobal = (HGLOBAL)OleDuplicateData(pMedSrc->hGlobal, pFmtSrc->cfFormat, 0);
pMedDest->hGlobal = static_cast<HGLOBAL>(OleDuplicateData(pMedSrc->hGlobal, pFmtSrc->cfFormat, 0));
break;
case TYMED_GDI:
pMedDest->hBitmap = (HBITMAP)OleDuplicateData(pMedSrc->hBitmap, pFmtSrc->cfFormat, 0);
pMedDest->hBitmap = static_cast<HBITMAP>(OleDuplicateData(pMedSrc->hBitmap, pFmtSrc->cfFormat, 0));
break;
case TYMED_MFPICT:
pMedDest->hMetaFilePict = (HMETAFILEPICT)OleDuplicateData(pMedSrc->hMetaFilePict, pFmtSrc->cfFormat, 0);
pMedDest->hMetaFilePict = static_cast<HMETAFILEPICT>(OleDuplicateData(pMedSrc->hMetaFilePict, pFmtSrc->cfFormat, 0));
break;
case TYMED_ENHMF:
pMedDest->hEnhMetaFile = (HENHMETAFILE)OleDuplicateData(pMedSrc->hEnhMetaFile, pFmtSrc->cfFormat, 0);
pMedDest->hEnhMetaFile = static_cast<HENHMETAFILE>(OleDuplicateData(pMedSrc->hEnhMetaFile, pFmtSrc->cfFormat, 0));
break;
case TYMED_FILE:
pMedSrc->lpszFileName = (LPOLESTR)OleDuplicateData(pMedSrc->lpszFileName, pFmtSrc->cfFormat, 0);
pMedSrc->lpszFileName = static_cast<LPOLESTR>(OleDuplicateData(pMedSrc->lpszFileName, pFmtSrc->cfFormat, 0));
break;
case TYMED_ISTREAM:
pMedDest->pstm = pMedSrc->pstm;
......@@ -611,7 +611,7 @@ HRESULT GitDataObject::SetDropDescription(DROPIMAGETYPE image, LPCTSTR format, L
return E_INVALIDARG;
FORMATETC fetc = { 0 };
fetc.cfFormat = (CLIPFORMAT)RegisterClipboardFormat(CFSTR_DROPDESCRIPTION);
fetc.cfFormat = static_cast<CLIPFORMAT>(RegisterClipboardFormat(CFSTR_DROPDESCRIPTION));
fetc.dwAspect = DVASPECT_CONTENT;
fetc.lindex = -1;
fetc.tymed = TYMED_HGLOBAL;
......@@ -621,7 +621,7 @@ HRESULT GitDataObject::SetDropDescription(DROPIMAGETYPE image, LPCTSTR format, L
if (medium.hGlobal == 0)
return E_OUTOFMEMORY;
DROPDESCRIPTION* pDropDescription = (DROPDESCRIPTION*)GlobalLock(medium.hGlobal);
auto pDropDescription = static_cast<DROPDESCRIPTION*>(GlobalLock(medium.hGlobal));
if (!pDropDescription)
return E_FAIL;
StringCchCopy(pDropDescription->szInsert, _countof(pDropDescription->szInsert), insert);
......
// TortoiseGit - a Windows shell extension for easy version control
// TortoiseGit - a Windows shell extension for easy version control
// Copyright (C) 2003-2008,2011, 2014 - TortoiseSVN
// Copyright (C) 2008-2017 - TortoiseGit
// Copyright (C) 2008-2017, 2019 - TortoiseGit
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
......@@ -112,7 +112,7 @@ const FileStatusCacheEntry * GitFolderStatus::BuildCache(const CTGitPath& filepa
FileStatusCacheEntry* ret = nullptr;
if (wcslen(filepath.GetWinPath()) == 3)
ret = &m_cache[(LPCTSTR)filepath.GetWinPathString().Left(2)];
ret = &m_cache[static_cast<LPCTSTR>(filepath.GetWinPathString().Left(2))];
else
ret = &m_cache[filepath.GetWinPath()];
......@@ -134,7 +134,7 @@ const FileStatusCacheEntry * GitFolderStatus::BuildCache(const CTGitPath& filepa
ULONGLONG GitFolderStatus::GetTimeoutValue()
{
ULONGLONG timeout = GITFOLDERSTATUS_CACHETIMEOUT;
ULONGLONG factor = (ULONGLONG)m_cache.size() / 200UL;
ULONGLONG factor = static_cast<ULONGLONG>(m_cache.size()) / 200UL;
if (factor==0)
factor = 1;
return factor*timeout;
......
// TortoiseGit - a Windows shell extension for easy version control
// Copyright (C) 2008-2016 - TortoiseGit
// Copyright (C) 2008-2016, 2019 - TortoiseGit
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
......@@ -54,7 +54,7 @@ static bool FindGitForWindows(CString& sMsysGitPath)
sMsysGitPath += L"\\cmd";
else
{
CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": Git for Windows installation found, but git.exe not exists in %s\n", (LPCTSTR)sMsysGitPath);
CTraceToOutputDebugString::Instance()(_T(__FUNCTION__) L": Git for Windows installation found, but git.exe not exists in %s\n", static_cast<LPCTSTR>(sMsysGitPath));
sMsysGitPath.Empty();
}
}
......
// TortoiseGit - a Windows shell extension for easy version control
// Copyright (C) 2008-2018 - TortoiseGit
// Copyright (C) 2008-2019 - TortoiseGit
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
......@@ -46,11 +46,11 @@ public:
}
CGitHash(const git_oid* oid)
{
git_oid_cpy((git_oid*)m_hash, oid);
git_oid_cpy(reinterpret_cast<git_oid*>(m_hash), oid);
}
CGitHash(const git_oid& oid)
{
git_oid_cpy((git_oid*)m_hash, &oid);
git_oid_cpy(reinterpret_cast<git_oid*>(m_hash), &oid);
}
CGitHash& operator = (const CString& str)
{
......@@ -65,12 +65,12 @@ public:
}
CGitHash& operator = (const git_oid* oid)
{
git_oid_cpy((git_oid*)m_hash, oid);
git_oid_cpy(reinterpret_cast<git_oid*>(m_hash), oid);
return *this;
}
CGitHash& operator = (const git_oid& oid)
{
git_oid_cpy((git_oid*)m_hash, &oid);
git_oid_cpy(reinterpret_cast<git_oid*>(m_hash), &oid);
return *this;
}
CGitHash(const CString &str)
......@@ -152,7 +152,7 @@ public:
operator const git_oid*() const
{
return (const git_oid*)m_hash;
return reinterpret_cast<const git_oid*>(m_hash);
}
explicit operator const unsigned char*() const
......@@ -209,7 +209,7 @@ namespace std
{
std::size_t operator()(const CGitHash& k) const
{
return *(size_t*)k.m_hash;
return reinterpret_cast<const size_t&>(k.m_hash);
}
};
}
This diff is collapsed.
// TortoiseGitMerge - a Diff/Patch program
// Copyright (C) 2012-2013, 2015-2018 - TortoiseGit
// Copyright (C) 2012-2013, 2015-2019 - TortoiseGit
// Copyright (C) 2010-2012 - TortoiseSVN
// This program is free software; you can redistribute it and/or
......@@ -87,7 +87,7 @@ int GitPatch::Init(const CString& patchfile, const CString& targetpath, CSysProg
m_pProgDlg = nullptr;
if ((m_nRejected > ((int)m_filePaths.size() / 3)) && !m_testPath.IsEmpty())
if ((m_nRejected > (static_cast<int>(m_filePaths.size()) / 3)) && !m_testPath.IsEmpty())
{
++m_nStrip;
for (m_nStrip = 0; m_nStrip < STRIP_LIMIT; ++m_nStrip)
......@@ -110,7 +110,7 @@ int GitPatch::Init(const CString& patchfile, const CString& targetpath, CSysProg
if (!ApplyPatches())
m_filePaths.clear();
}
return (int)m_filePaths.size();
return static_cast<int>(m_filePaths.size());
}
bool GitPatch::ApplyPatches()
......@@ -136,7 +136,7 @@ bool GitPatch::PatchFile(int nIndex, CString &datapath)
pr.path = m_patch.GetFilename(nIndex);
if (m_pProgDlg)
m_pProgDlg->FormatPathLine(2, IDS_PATCH_PATHINGFILE, (LPCTSTR)pr.path);
m_pProgDlg->FormatPathLine(2, IDS_PATCH_PATHINGFILE, static_cast<LPCTSTR>(pr.path));
//first, do a "dry run" of patching against the file in place...
if (!m_patch.PatchFile(m_nStrip, nIndex, datapath, sTempFile))
......@@ -153,20 +153,20 @@ bool GitPatch::PatchFile(int nIndex, CString &datapath)
{
if (sVersion.IsEmpty())
{
m_errorStr.Format(IDS_ERR_MAINFRAME_FILECONFLICTNOVERSION, (LPCTSTR)sFilePath);
m_errorStr.Format(IDS_ERR_MAINFRAME_FILECONFLICTNOVERSION, static_cast<LPCTSTR>(sFilePath));
return false; // cannot apply patch which does not apply cleanly w/o git information in patch file.
}
sBaseFile = CTempFiles::Instance().GetTempFilePathString();
if (!CAppUtils::GetVersionedFile(sFilePath, sVersion, sBaseFile, m_pProgDlg))
{
m_errorStr.FormatMessage(IDS_ERR_MAINFRAME_FILEVERSIONNOTFOUND, (LPCTSTR)sVersion, (LPCTSTR)sFilePath);
m_errorStr.FormatMessage(IDS_ERR_MAINFRAME_FILEVERSIONNOTFOUND, static_cast<LPCTSTR>(sVersion), static_cast<LPCTSTR>(sFilePath));
return false;
}
}
if (m_pProgDlg)
m_pProgDlg->FormatPathLine(2, IDS_PATCH_PATHINGFILE, (LPCTSTR)pr.path);
m_pProgDlg->FormatPathLine(2, IDS_PATCH_PATHINGFILE, static_cast<LPCTSTR>(pr.path));
int patchtry = m_patch.PatchFile(m_nStrip, nIndex, datapath, sTempFile, sBaseFile, true);
......@@ -182,13 +182,13 @@ bool GitPatch::PatchFile(int nIndex, CString &datapath)
pr.rejectsPath = m_patch.GetErrorMessage();
}
TRACE(L"comparing %s and %s\nagainst the base file %s\n", (LPCTSTR)sTempFile, (LPCTSTR)sFilePath, (LPCTSTR)sBaseFile);
TRACE(L"comparing %s and %s\nagainst the base file %s\n", static_cast<LPCTSTR>(sTempFile), static_cast<LPCTSTR>(sFilePath), static_cast<LPCTSTR>(sBaseFile));
}
else
{
//"dry run" was successful, so save the patched file somewhere...
pr.rejects = 0;
TRACE(L"comparing %s\nwith the patched result %s\n", (LPCTSTR)sFilePath, (LPCTSTR)sTempFile);
TRACE(L"comparing %s\nwith the patched result %s\n", static_cast<LPCTSTR>(sFilePath), static_cast<LPCTSTR>(sTempFile));
}
pr.resultPath = sTempFile;
......@@ -206,7 +206,7 @@ CString GitPatch::GetPatchRejects(int nIndex) const
{
if (nIndex < 0)
return L"";
if (nIndex < (int)m_filePaths.size())
if (nIndex < static_cast<int>(m_filePaths.size()))
return m_filePaths[nIndex].rejectsPath;
return L"";
......@@ -342,7 +342,7 @@ CString GitPatch::GetStrippedPath(int nIndex) const
{
if (nIndex < 0)
return L"";
if (nIndex < (int)m_filePaths.size())
if (nIndex < static_cast<int>(m_filePaths.size()))
{
CString filepath = Strip(GetFilePath(nIndex));
return filepath;
......
// TortoiseGitMerge - a Diff/Patch program
// TortoiseGitMerge - a Diff/Patch program
// Copyright (C) 2012 - TortoiseGit
// Copyright (C) 2012, 2019 - TortoiseGit
// Copyright (C) 2010-2012, 2015 - TortoiseSVN
// This program is free software; you can redistribute it and/or
......@@ -69,7 +69,7 @@ public:
/**
* returns the number of files that are affected by the patchfile.
*/
int GetNumberOfFiles() const { return (int)m_filePaths.size(); }
int GetNumberOfFiles() const { return static_cast<int>(m_filePaths.size()); }
/**
* Returns the path of the affected file
......
......@@ -135,7 +135,7 @@ int GitRev::ParserFromCommit(const git_commit* commit)
m_Subject = CUnicodeUtils::GetUnicode(msg, encode);
else
{
m_Subject = CUnicodeUtils::GetUnicode(CStringA(msg, (int)(body - msg)), encode);
m_Subject = CUnicodeUtils::GetUnicode(CStringA(msg, static_cast<int>(body - msg)), encode);
m_Body = CUnicodeUtils::GetUnicode(body + 1, encode);
}
......@@ -175,10 +175,10 @@ int GitRev::GetCommit(git_repository* repo, const CString& refname)
void GitRev::DbgPrint()
{
ATLTRACE(L"Commit %s\r\n", (LPCTSTR)this->m_CommitHash.ToString());
ATLTRACE(L"Commit %s\r\n", static_cast<LPCTSTR>(this->m_CommitHash.ToString()));
for (unsigned int i = 0; i < this->m_ParentHash.size(); ++i)
{
ATLTRACE(L"Parent %i %s", i, (LPCTSTR)m_ParentHash[i].ToString());
ATLTRACE(L"Parent %i %s", i, static_cast<LPCTSTR>(m_ParentHash[i].ToString()));
}
ATLTRACE(L"\n");
}
......
// TortoiseGit - a Windows shell extension for easy version control
// TortoiseGit - a Windows shell extension for easy version control
// Copyright (C) 2008-2017 - TortoiseGit
// Copyright (C) 2008-2017, 2019 - TortoiseGit
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
......@@ -112,7 +112,7 @@ public:
GIT_REV_LIST m_ParentHash;
virtual void Clear();
inline int ParentsCount(){ return (int)m_ParentHash.size(); }
inline int ParentsCount() {return static_cast<int>(m_ParentHash.size()); }
int ParserFromCommit(GIT_COMMIT *commit);
int ParserParentFromCommit(GIT_COMMIT *commit);
......
......@@ -229,7 +229,7 @@ int GitRevLoglist::SafeFetchFullInfo(CGit* git)
{
git_diff_find_options diffopts = GIT_DIFF_FIND_OPTIONS_INIT;
diffopts.flags = GIT_DIFF_FIND_COPIES | GIT_DIFF_FIND_RENAMES;
diffopts.rename_threshold = diffopts.copy_threshold = (uint16_t)CGit::ms_iSimilarityIndexThreshold;
diffopts.rename_threshold = diffopts.copy_threshold = static_cast<uint16_t>(CGit::ms_iSimilarityIndexThreshold);
if (git_diff_find_similar(diff, &diffopts) < 0)
return-1;
}
......@@ -365,7 +365,7 @@ int GitRevLoglist::SafeFetchFullInfo(CGit* git)
CGit::StringAppend(&stroldname, oldname, CP_UTF8);
path.SetFromGit(strnewname, &stroldname, &isDir);
}
path.ParserAction((BYTE)status);
path.ParserAction(static_cast<BYTE>(status));
path.m_ParentNo = i;
m_Action |= path.m_Action;
......@@ -421,7 +421,7 @@ int GitRevLoglist::GetRefLog(const CString& ref, std::vector<GitRevLoglist>& ref
GitRevLoglist rev;
rev.m_CommitHash = git_reflog_entry_id_new(entry);
rev.m_Ref.Format(L"%s@{%zu}", (LPCTSTR)ref, i);
rev.m_Ref.Format(L"%s@{%zu}", static_cast<LPCTSTR>(ref), i);
rev.GetCommitterDate() = CTime(git_reflog_entry_committer(entry)->when.time);
if (git_reflog_entry_message(entry) != nullptr)
{
......@@ -446,9 +446,9 @@ int GitRevLoglist::GetRefLog(const CString& ref, std::vector<GitRevLoglist>& ref
// no error checking, because the only error which could occur is file not found
git_for_each_reflog_ent(CUnicodeUtils::GetUTF8(ref), [](struct GIT_OBJECT_OID* /*old_oid*/, struct GIT_OBJECT_OID* new_oid, const char* /*committer*/, unsigned long long time, int /*sz*/, const char* msg, void* data)
{
std::vector<GitRevLoglist>* vector = (std::vector<GitRevLoglist>*)data;
auto vector = static_cast<std::vector<GitRevLoglist>*>(data);
GitRevLoglist rev;
rev.m_CommitHash = (const unsigned char*)new_oid->hash;
rev.m_CommitHash = static_cast<const unsigned char*>(new_oid->hash);
rev.GetCommitterDate() = CTime(time);
CString one = CUnicodeUtils::GetUnicode(msg);
......@@ -468,7 +468,7 @@ int GitRevLoglist::GetRefLog(const CString& ref, std::vector<GitRevLoglist>& ref
for (size_t i = tmp.size(), id = 0; i > 0; --i, ++id)
{
GitRevLoglist rev = tmp[i - 1];