Fix various MSVC 2015 /W3 warnings
* The compiler doesn't like implicit conversions to bool. (it emits a "performance warning") * It also doesn't like an unused argument in an exception catch block.
This commit is contained in:
parent
9f0d7e6b4e
commit
a850639a87
@ -147,8 +147,8 @@ Agent::Agent(LPCWSTR controlPipeName,
|
||||
int mouseMode,
|
||||
int initialCols,
|
||||
int initialRows) :
|
||||
m_useConerr(agentFlags & WINPTY_FLAG_CONERR),
|
||||
m_plainMode(agentFlags & WINPTY_FLAG_PLAIN_OUTPUT),
|
||||
m_useConerr((agentFlags & WINPTY_FLAG_CONERR) != 0),
|
||||
m_plainMode((agentFlags & WINPTY_FLAG_PLAIN_OUTPUT) != 0),
|
||||
m_mouseMode(mouseMode)
|
||||
{
|
||||
trace("Agent::Agent entered");
|
||||
@ -310,7 +310,7 @@ void Agent::pollControlPipe()
|
||||
ReadBuffer buffer(std::move(packetData));
|
||||
buffer.getRawValue<uint64_t>(); // Discard the size.
|
||||
handlePacket(buffer);
|
||||
} catch (const ReadBuffer::DecodeError &error) {
|
||||
} catch (const ReadBuffer::DecodeError&) {
|
||||
ASSERT(false && "Decode error");
|
||||
}
|
||||
}
|
||||
@ -349,8 +349,8 @@ void Agent::handleStartProcessPacket(ReadBuffer &packet)
|
||||
ASSERT(!m_closingOutputPipes);
|
||||
|
||||
const uint64_t spawnFlags = packet.getInt64();
|
||||
const bool wantProcessHandle = packet.getInt32();
|
||||
const bool wantThreadHandle = packet.getInt32();
|
||||
const bool wantProcessHandle = packet.getInt32() != 0;
|
||||
const bool wantThreadHandle = packet.getInt32() != 0;
|
||||
const auto program = packet.getWString();
|
||||
const auto cmdline = packet.getWString();
|
||||
const auto cwd = packet.getWString();
|
||||
@ -403,8 +403,8 @@ void Agent::handleStartProcessPacket(ReadBuffer &packet)
|
||||
}
|
||||
CloseHandle(pi.hThread);
|
||||
m_childProcess = pi.hProcess;
|
||||
m_autoShutdown = (spawnFlags & WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN);
|
||||
m_exitAfterShutdown = (spawnFlags & WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN);
|
||||
m_autoShutdown = (spawnFlags & WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN) != 0;
|
||||
m_exitAfterShutdown = (spawnFlags & WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN) != 0;
|
||||
reply.putInt32(static_cast<int32_t>(StartProcessResult::ProcessCreated));
|
||||
reply.putInt64(replyProcess);
|
||||
reply.putInt64(replyThread);
|
||||
|
@ -288,10 +288,10 @@ void ConsoleInput::flushIncompleteEscapeCode()
|
||||
void ConsoleInput::updateInputFlags(bool forceTrace)
|
||||
{
|
||||
const DWORD mode = inputConsoleMode();
|
||||
const bool newFlagEE = mode & ENABLE_EXTENDED_FLAGS;
|
||||
const bool newFlagMI = mode & ENABLE_MOUSE_INPUT;
|
||||
const bool newFlagQE = mode & ENABLE_QUICK_EDIT_MODE;
|
||||
const bool newFlagEI = mode & 0x200;
|
||||
const bool newFlagEE = (mode & ENABLE_EXTENDED_FLAGS) != 0;
|
||||
const bool newFlagMI = (mode & ENABLE_MOUSE_INPUT) != 0;
|
||||
const bool newFlagQE = (mode & ENABLE_QUICK_EDIT_MODE) != 0;
|
||||
const bool newFlagEI = (mode & 0x200) != 0;
|
||||
if (forceTrace ||
|
||||
newFlagEE != m_enableExtendedEnabled ||
|
||||
newFlagMI != m_mouseInputEnabled ||
|
||||
@ -591,9 +591,9 @@ void ConsoleInput::appendKeyPress(std::vector<INPUT_RECORD> &records,
|
||||
uint32_t codePoint,
|
||||
uint16_t keyState)
|
||||
{
|
||||
const bool ctrl = keyState & LEFT_CTRL_PRESSED;
|
||||
const bool alt = keyState & LEFT_ALT_PRESSED;
|
||||
const bool shift = keyState & SHIFT_PRESSED;
|
||||
const bool ctrl = (keyState & LEFT_CTRL_PRESSED) != 0;
|
||||
const bool alt = (keyState & LEFT_ALT_PRESSED) != 0;
|
||||
const bool shift = (keyState & SHIFT_PRESSED) != 0;
|
||||
|
||||
if (isTracingEnabled()) {
|
||||
static bool debugInput = hasDebugFlag("input");
|
||||
|
@ -330,12 +330,12 @@ void Scraper::syncConsoleContentAndSize(
|
||||
}
|
||||
|
||||
const ConsoleScreenBufferInfo info = m_consoleBuffer->bufferInfo();
|
||||
BOOL cursorVisible = true;
|
||||
bool cursorVisible = true;
|
||||
CONSOLE_CURSOR_INFO cursorInfo = {};
|
||||
if (!GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursorInfo)) {
|
||||
trace("GetConsoleCursorInfo failed");
|
||||
} else {
|
||||
cursorVisible = cursorInfo.bVisible;
|
||||
cursorVisible = cursorInfo.bVisible != 0;
|
||||
}
|
||||
|
||||
// If an app resizes the buffer height, then we enter "direct mode", where
|
||||
|
@ -108,7 +108,7 @@ static void translateException(winpty_error_ptr_t *&err) {
|
||||
try {
|
||||
try {
|
||||
throw;
|
||||
} catch (const ReadBuffer::DecodeError &e) {
|
||||
} catch (const ReadBuffer::DecodeError&) {
|
||||
ret = const_cast<winpty_error_ptr_t>(&kBadRpcPacket);
|
||||
} catch (const LibWinptyException &e) {
|
||||
std::unique_ptr<winpty_error_t> obj(new winpty_error_t);
|
||||
@ -125,7 +125,7 @@ static void translateException(winpty_error_ptr_t *&err) {
|
||||
obj->msgDynamic = new std::shared_ptr<std::wstring>(msg);
|
||||
ret = obj.release();
|
||||
}
|
||||
} catch (const std::bad_alloc &e) {
|
||||
} catch (const std::bad_alloc&) {
|
||||
ret = const_cast<winpty_error_ptr_t>(&kOutOfMemory);
|
||||
} catch (...) {
|
||||
ret = const_cast<winpty_error_ptr_t>(&kUncaughtException);
|
||||
@ -703,7 +703,7 @@ WINPTY_API HANDLE winpty_agent_process(winpty_t *wp) {
|
||||
static const wchar_t *cstrFromWStringOrNull(const std::wstring &str) {
|
||||
try {
|
||||
return str.c_str();
|
||||
} catch (const std::bad_alloc &e) {
|
||||
} catch (const std::bad_alloc&) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ GenRandom::GenRandom() : m_advapi32(L"advapi32.dll") {
|
||||
// Fall back to the crypto API.
|
||||
m_cryptProvIsValid =
|
||||
CryptAcquireContext(&m_cryptProv, nullptr, nullptr,
|
||||
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
||||
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT) != 0;
|
||||
if (!m_cryptProvIsValid) {
|
||||
trace("GenRandom: CryptAcquireContext failed: %u",
|
||||
static_cast<unsigned>(GetLastError()));
|
||||
@ -68,14 +68,15 @@ bool GenRandom::fillBuffer(void *buffer, size_t size) {
|
||||
memset(buffer, 0, size);
|
||||
bool success = false;
|
||||
if (m_rtlGenRandom != nullptr) {
|
||||
success = m_rtlGenRandom(buffer, size);
|
||||
success = m_rtlGenRandom(buffer, size) != 0;
|
||||
if (!success) {
|
||||
trace("GenRandom: RtlGenRandom/SystemFunction036 failed: %u",
|
||||
static_cast<unsigned>(GetLastError()));
|
||||
}
|
||||
} else if (m_cryptProvIsValid) {
|
||||
success = CryptGenRandom(m_cryptProv, size,
|
||||
reinterpret_cast<BYTE*>(buffer));
|
||||
success =
|
||||
CryptGenRandom(m_cryptProv, size,
|
||||
reinterpret_cast<BYTE*>(buffer)) != 0;
|
||||
if (!success) {
|
||||
trace("GenRandom: CryptGenRandom failed, size=%d, lasterror=%u",
|
||||
static_cast<int>(size),
|
||||
|
@ -232,7 +232,7 @@ void dumpWindowsVersion() {
|
||||
fb << "F:" << versionToString(fileVersionFromInfo(info)) << '/'
|
||||
<< "P:" << versionToString(productVersionFromInfo(info));
|
||||
return fb.str_moved();
|
||||
} catch (const ModuleNotFound &e) {
|
||||
} catch (const ModuleNotFound&) {
|
||||
return utf8FromWide(dllPath) + ":none";
|
||||
} catch (const WinptyException &e) {
|
||||
trace("Error getting %s version: %s",
|
||||
|
Loading…
Reference in New Issue
Block a user