Address some additional code analysis warnings
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
4846cdbc9f
commit
51c7ed11c0
@ -59,7 +59,7 @@ int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
|||||||
delete wxLog::SetActiveTarget(new wxLogStderr(log_file.fp()));
|
delete wxLog::SetActiveTarget(new wxLogStderr(log_file.fp()));
|
||||||
|
|
||||||
wxUpdCheckThread worker(lang_ui == wxLANGUAGE_DEFAULT ? wxT("en_US") : wxLocale::GetLanguageCanonicalName(lang_ui));
|
wxUpdCheckThread worker(lang_ui == wxLANGUAGE_DEFAULT ? wxT("en_US") : wxLocale::GetLanguageCanonicalName(lang_ui));
|
||||||
wxUpdCheckThread::wxResult res = worker.CheckForUpdate();
|
const wxUpdCheckThread::wxResult res = worker.CheckForUpdate();
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case wxUpdCheckThread::wxResult::UpdateAvailable: return worker.LaunchUpdate(NULL, true) ? 0 : 1;
|
case wxUpdCheckThread::wxResult::UpdateAvailable: return worker.LaunchUpdate(NULL, true) ? 0 : 1;
|
||||||
case wxUpdCheckThread::wxResult::UpToDate : return 0;
|
case wxUpdCheckThread::wxResult::UpToDate : return 0;
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
wxUpdCheckThread(const wxString &langId, wxEvtHandler *parent = NULL);
|
wxUpdCheckThread(const wxString &langId, wxEvtHandler *parent = NULL);
|
||||||
virtual ~wxUpdCheckThread();
|
~wxUpdCheckThread();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Checks for updates and safely downloads update package when available.
|
/// Checks for updates and safely downloads update package when available.
|
||||||
@ -73,7 +73,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// Aborts current update check
|
/// Aborts current update check
|
||||||
///
|
///
|
||||||
inline void Abort()
|
inline void Abort() noexcept
|
||||||
{
|
{
|
||||||
m_abort = true;
|
m_abort = true;
|
||||||
}
|
}
|
||||||
@ -84,12 +84,12 @@ protected:
|
|||||||
///
|
///
|
||||||
/// \returns Exit code
|
/// \returns Exit code
|
||||||
///
|
///
|
||||||
virtual ExitCode Entry();
|
ExitCode Entry() override;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Overrriden method to allow custom termination when Updater is launched in the main thread.
|
/// Overrriden method to allow custom termination when Updater is launched in the main thread.
|
||||||
///
|
///
|
||||||
virtual bool TestDestroy();
|
bool TestDestroy() override;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Checks for updates and safely downloads update package when available.
|
/// Checks for updates and safely downloads update package when available.
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include <codeanalysis\warnings.h>
|
#include <codeanalysis\warnings.h>
|
||||||
#ifndef WXWIDGETS_CODE_ANALYSIS_WARNINGS
|
#ifndef WXWIDGETS_CODE_ANALYSIS_WARNINGS
|
||||||
#define WXWIDGETS_CODE_ANALYSIS_WARNINGS ALL_CODE_ANALYSIS_WARNINGS 26812
|
#define WXWIDGETS_CODE_ANALYSIS_WARNINGS ALL_CODE_ANALYSIS_WARNINGS 26812 26814
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -82,7 +82,7 @@ wxThread::ExitCode wxUpdCheckThread::Entry()
|
|||||||
wxQueueEvent(m_parent, e);
|
wxQueueEvent(m_parent, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (wxThread::ExitCode)(static_cast<intptr_t>(result) & 0xffffffff);
|
return reinterpret_cast<wxThread::ExitCode>(static_cast<intptr_t>(result) & 0xffffffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ wxXmlDocument* wxUpdCheckThread::GetCatalogue()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
wxScopedPtr<wxInputStream> httpStream(http.GetInputStream(wxS(UPDATER_HTTP_PATH)));
|
wxScopedPtr<wxInputStream> httpStream(http.GetInputStream(wxS(UPDATER_HTTP_PATH)));
|
||||||
int status = http.GetResponse();
|
const int status = http.GetResponse();
|
||||||
if (status == 304) {
|
if (status == 304) {
|
||||||
wxLogStatus(_("Repository did not change since the last time."));
|
wxLogStatus(_("Repository did not change since the last time."));
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -185,13 +185,13 @@ wxXmlDocument* wxUpdCheckThread::GetCatalogue()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
wxMemoryBuffer buf(4*1024);
|
wxMemoryBuffer buf(4*1024);
|
||||||
char *data = (char*)buf.GetData();
|
char *data = static_cast<char*>(buf.GetData());
|
||||||
size_t nBlock = buf.GetBufSize();
|
const size_t nBlock = buf.GetBufSize();
|
||||||
do {
|
do {
|
||||||
if (TestDestroy()) return NULL;
|
if (TestDestroy()) return NULL;
|
||||||
|
|
||||||
httpStream->Read(data, nBlock);
|
httpStream->Read(data, nBlock);
|
||||||
size_t nRead = httpStream->LastRead();
|
const size_t nRead = httpStream->LastRead();
|
||||||
file.Write(data, nRead);
|
file.Write(data, nRead);
|
||||||
if (file.Error()) {
|
if (file.Error()) {
|
||||||
wxLogError(_("Can not write to %s file."), fileName.c_str());
|
wxLogError(_("Can not write to %s file."), fileName.c_str());
|
||||||
@ -218,14 +218,14 @@ wxXmlDocument* wxUpdCheckThread::GetCatalogue()
|
|||||||
for (wxXmlNode *prolog = document->GetChildren(); prolog; prolog = prolog->GetNext()) {
|
for (wxXmlNode *prolog = document->GetChildren(); prolog; prolog = prolog->GetNext()) {
|
||||||
if (prolog->GetType() == wxXML_COMMENT_NODE) {
|
if (prolog->GetType() == wxXML_COMMENT_NODE) {
|
||||||
wxString content = prolog->GetContent();
|
wxString content = prolog->GetContent();
|
||||||
size_t content_len = content.length();
|
const size_t content_len = content.length();
|
||||||
if (content_len >= _countof(wxS(UPDATER_SIGNATURE_MARK)) - 1 &&
|
if (content_len >= _countof(wxS(UPDATER_SIGNATURE_MARK)) - 1 &&
|
||||||
memcmp((const wxStringCharType*)content, wxS(UPDATER_SIGNATURE_MARK), sizeof(wxStringCharType)*(_countof(wxS(UPDATER_SIGNATURE_MARK)) - 1)) == 0)
|
memcmp((const wxStringCharType*)content, wxS(UPDATER_SIGNATURE_MARK), sizeof(wxStringCharType)*(_countof(wxS(UPDATER_SIGNATURE_MARK)) - 1)) == 0)
|
||||||
{
|
{
|
||||||
// Read the signature.
|
// Read the signature.
|
||||||
size_t signature_len = content_len - (_countof(wxS(UPDATER_SIGNATURE_MARK)) - 1);
|
const size_t signature_len = content_len - (_countof(wxS(UPDATER_SIGNATURE_MARK)) - 1);
|
||||||
size_t len = wxBase64DecodedSize(signature_len);
|
const size_t len = wxBase64DecodedSize(signature_len);
|
||||||
size_t res = wxBase64Decode(sig.GetWriteBuf(len), len, content.Right(signature_len), wxBase64DecodeMode_SkipWS);
|
const size_t res = wxBase64Decode(sig.GetWriteBuf(len), len, content.Right(signature_len), wxBase64DecodeMode_SkipWS);
|
||||||
if (res != wxCONV_FAILED) {
|
if (res != wxCONV_FAILED) {
|
||||||
sig.SetDataLen(res);
|
sig.SetDataLen(res);
|
||||||
|
|
||||||
@ -333,8 +333,8 @@ bool wxUpdCheckThread::ParseCatalogue(const wxXmlDocument &doc)
|
|||||||
else if (name == wxT("hash")) {
|
else if (name == wxT("hash")) {
|
||||||
// Read the hash.
|
// Read the hash.
|
||||||
wxString content(elLocaleNote->GetNodeContent());
|
wxString content(elLocaleNote->GetNodeContent());
|
||||||
size_t len = wxHexDecodedSize(content.length());
|
const size_t len = wxHexDecodedSize(content.length());
|
||||||
size_t res = wxHexDecode(hash.GetWriteBuf(len), len, content, wxHexDecodeMode::SkipWS);
|
const size_t res = wxHexDecode(hash.GetWriteBuf(len), len, content, wxHexDecodeMode::SkipWS);
|
||||||
if (res != wxCONV_FAILED)
|
if (res != wxCONV_FAILED)
|
||||||
hash.SetDataLen(res);
|
hash.SetDataLen(res);
|
||||||
else
|
else
|
||||||
@ -408,8 +408,8 @@ bool wxUpdCheckThread::ReadUpdatePackageMeta()
|
|||||||
|
|
||||||
if (m_config.Read(wxT("PackageHash"), &str)) {
|
if (m_config.Read(wxT("PackageHash"), &str)) {
|
||||||
// Convert to binary.
|
// Convert to binary.
|
||||||
size_t len = wxHexDecodedSize(str.length());
|
const size_t len = wxHexDecodedSize(str.length());
|
||||||
size_t res = wxHexDecode(m_hash.GetWriteBuf(len), len, str, wxHexDecodeMode::SkipWS);
|
const size_t res = wxHexDecode(m_hash.GetWriteBuf(len), len, str, wxHexDecodeMode::SkipWS);
|
||||||
if (res != wxCONV_FAILED) {
|
if (res != wxCONV_FAILED) {
|
||||||
m_hash.SetDataLen(res);
|
m_hash.SetDataLen(res);
|
||||||
return true;
|
return true;
|
||||||
@ -481,13 +481,13 @@ bool wxUpdCheckThread::DownloadUpdatePackage()
|
|||||||
// Save update package to file, and calculate hash.
|
// Save update package to file, and calculate hash.
|
||||||
wxCryptoHashSHA1 ch(*m_cs);
|
wxCryptoHashSHA1 ch(*m_cs);
|
||||||
wxMemoryBuffer buf(4*1024);
|
wxMemoryBuffer buf(4*1024);
|
||||||
char *data = (char*)buf.GetData();
|
char *data = static_cast<char*>(buf.GetData());
|
||||||
size_t nBlock = buf.GetBufSize();
|
const size_t nBlock = buf.GetBufSize();
|
||||||
do {
|
do {
|
||||||
if (TestDestroy()) return false;
|
if (TestDestroy()) return false;
|
||||||
|
|
||||||
stream->Read(data, nBlock);
|
stream->Read(data, nBlock);
|
||||||
size_t nRead = stream->LastRead();
|
const size_t nRead = stream->LastRead();
|
||||||
file.Write(data, nRead);
|
file.Write(data, nRead);
|
||||||
if (file.Error()) {
|
if (file.Error()) {
|
||||||
wxLogError(_("Can not write to %s file."), m_fileName.c_str());
|
wxLogError(_("Can not write to %s file."), m_fileName.c_str());
|
||||||
@ -530,7 +530,7 @@ bool wxUpdCheckThread::LaunchUpdate(WXHWND hParent, bool headless)
|
|||||||
param += fileNameLog;
|
param += fileNameLog;
|
||||||
param += wxT("\"");
|
param += wxT("\"");
|
||||||
|
|
||||||
intptr_t result = (intptr_t)::ShellExecute(hParent, NULL, wxT("msiexec.exe"), param, NULL, SW_SHOWNORMAL);
|
const intptr_t result = reinterpret_cast<intptr_t>(::ShellExecute(hParent, NULL, wxT("msiexec.exe"), param, NULL, SW_SHOWNORMAL));
|
||||||
if (result > 32) {
|
if (result > 32) {
|
||||||
wxLogStatus(_("msiexec.exe launch succeeded. For detailed information, see %s file."), fileNameLog.c_str());
|
wxLogStatus(_("msiexec.exe launch succeeded. For detailed information, see %s file."), fileNameLog.c_str());
|
||||||
return true;
|
return true;
|
||||||
|
@ -29,7 +29,7 @@ HINSTANCE g_hInstance = NULL;
|
|||||||
///
|
///
|
||||||
/// Main function
|
/// Main function
|
||||||
///
|
///
|
||||||
BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved)
|
BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved) noexcept
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(lpvReserved);
|
UNREFERENCED_PARAMETER(lpvReserved);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user