chore: Combine unnessessary multi level if into less fewer checks
This commit is contained in:
@ -166,10 +166,8 @@ void ArchNetworkBSD::closeSocketForRead(ArchSocket s)
|
||||
{
|
||||
assert(s != nullptr);
|
||||
|
||||
if (shutdown(s->m_fd, 0) == -1) {
|
||||
if (errno != ENOTCONN) {
|
||||
throwError(errno);
|
||||
}
|
||||
if ((shutdown(s->m_fd, 0) == -1) && (errno != ENOTCONN)) {
|
||||
throwError(errno);
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,10 +175,8 @@ void ArchNetworkBSD::closeSocketForWrite(ArchSocket s)
|
||||
{
|
||||
assert(s != nullptr);
|
||||
|
||||
if (shutdown(s->m_fd, 1) == -1) {
|
||||
if (errno != ENOTCONN) {
|
||||
throwError(errno);
|
||||
}
|
||||
if ((shutdown(s->m_fd, 1) == -1) && (errno != ENOTCONN)) {
|
||||
throwError(errno);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -134,13 +134,11 @@ void App::setupFileLogging()
|
||||
|
||||
void App::loggingFilterWarning() const
|
||||
{
|
||||
if (CLOG->getFilter() > CLOG->getConsoleMaxLevel()) {
|
||||
if (argsBase().m_logFile == nullptr) {
|
||||
LOG(
|
||||
(CLOG_WARN "log messages above %s are NOT sent to console (use file logging)",
|
||||
CLOG->getFilterName(CLOG->getConsoleMaxLevel()))
|
||||
);
|
||||
}
|
||||
if ((CLOG->getFilter() > CLOG->getConsoleMaxLevel()) && (argsBase().m_logFile == nullptr)) {
|
||||
LOG(
|
||||
(CLOG_WARN "log messages above %s are NOT sent to console (use file logging)",
|
||||
CLOG->getFilterName(CLOG->getConsoleMaxLevel()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -25,15 +25,11 @@ void FingerprintDatabase::readStream(QTextStream &in)
|
||||
if (!in.device() && !in.string())
|
||||
return;
|
||||
|
||||
if (in.device()) {
|
||||
if (!in.device()->isReadable())
|
||||
return;
|
||||
}
|
||||
if (in.device() && !in.device()->isReadable())
|
||||
return;
|
||||
|
||||
if (in.string()) {
|
||||
if (in.string()->isEmpty())
|
||||
return;
|
||||
}
|
||||
if (in.string() && in.string()->isEmpty())
|
||||
return;
|
||||
|
||||
QString line;
|
||||
while (!in.atEnd()) {
|
||||
@ -63,10 +59,8 @@ bool FingerprintDatabase::writeStream(QTextStream &out)
|
||||
if (!out.device() && !out.string())
|
||||
return false;
|
||||
|
||||
if (out.device()) {
|
||||
if (!out.device()->isWritable())
|
||||
return false;
|
||||
}
|
||||
if (out.device() && !out.device()->isWritable())
|
||||
return false;
|
||||
|
||||
for (const auto &fingerprint : std::as_const(m_fingerprints)) {
|
||||
out << fingerprint.toDbLine() << "\n";
|
||||
|
||||
@ -443,12 +443,10 @@ int SecureSocket::secureAccept(int socket)
|
||||
|
||||
// If not fatal and no retry, state is good
|
||||
if (retry == 0) {
|
||||
if (m_securityLevel == SecurityLevel::PeerAuth) {
|
||||
if (!verifyCertFingerprint(Settings::tlsTrustedClientsDb())) {
|
||||
retry = 0;
|
||||
disconnect();
|
||||
return -1; // Fail
|
||||
}
|
||||
if (m_securityLevel == SecurityLevel::PeerAuth && !verifyCertFingerprint(Settings::tlsTrustedClientsDb())) {
|
||||
retry = 0;
|
||||
disconnect();
|
||||
return -1; // Fail
|
||||
}
|
||||
m_secureReady = true;
|
||||
LOG((CLOG_INFO "accepted secure socket"));
|
||||
|
||||
@ -108,12 +108,10 @@ void SocketMultiplexer::removeSocket(ISocket *socket)
|
||||
// remove job. rather than removing it from the map we put nullptr
|
||||
// in the list instead so the order of jobs in the list continues
|
||||
// to match the order of jobs in pfds in serviceThread().
|
||||
if (SocketJobMap::iterator i = m_socketJobMap.find(socket); i != m_socketJobMap.end()) {
|
||||
if (*(i->second) != nullptr) {
|
||||
delete *(i->second);
|
||||
*(i->second) = nullptr;
|
||||
m_update = true;
|
||||
}
|
||||
if (SocketJobMap::iterator i = m_socketJobMap.find(socket); i != m_socketJobMap.end() && (*(i->second) != nullptr)) {
|
||||
delete *(i->second);
|
||||
*(i->second) = nullptr;
|
||||
m_update = true;
|
||||
}
|
||||
|
||||
// unlock the job list
|
||||
|
||||
@ -1050,10 +1050,8 @@ void XWindowsScreen::openIM()
|
||||
XIMStyle style = 0;
|
||||
for (unsigned short i = 0; i < styles->count_styles; ++i) {
|
||||
style = styles->supported_styles[i];
|
||||
if ((style & XIMPreeditNothing) != 0) {
|
||||
if ((style & (XIMStatusNothing | XIMStatusNone)) != 0) {
|
||||
break;
|
||||
}
|
||||
if (((style & XIMPreeditNothing) != 0) && ((style & (XIMStatusNothing | XIMStatusNone)) != 0)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
XFree(styles);
|
||||
@ -1148,11 +1146,8 @@ void XWindowsScreen::handleSystemEvent(const Event &event, void *)
|
||||
// this is a hot key
|
||||
onHotKey(xevent->xkey, isRepeat);
|
||||
return;
|
||||
} else if (!m_isOnScreen) {
|
||||
// this might be a hot key
|
||||
if (onHotKey(xevent->xkey, isRepeat)) {
|
||||
return;
|
||||
}
|
||||
} else if (!m_isOnScreen && onHotKey(xevent->xkey, isRepeat)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool down = (isRepeat || xevent->type == KeyPress);
|
||||
|
||||
@ -65,11 +65,9 @@ XWindowsScreenSaver::XWindowsScreenSaver(Display *display, Window window, void *
|
||||
#if HAVE_X11_EXTENSIONS_DPMS_H
|
||||
int eventBase;
|
||||
int errorBase;
|
||||
if (DPMSQueryExtension(m_display, &eventBase, &errorBase)) {
|
||||
if (DPMSCapable(m_display)) {
|
||||
// we have DPMS
|
||||
m_dpms = true;
|
||||
}
|
||||
if (DPMSQueryExtension(m_display, &eventBase, &errorBase) && DPMSCapable(m_display)) {
|
||||
// we have DPMS
|
||||
m_dpms = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -159,11 +157,9 @@ bool XWindowsScreenSaver::handleXEvent(const XEvent *xevent)
|
||||
break;
|
||||
|
||||
case PropertyNotify:
|
||||
if (xevent->xproperty.state == PropertyNewValue) {
|
||||
if (isXScreenSaver(xevent->xproperty.window)) {
|
||||
// found the xscreensaver
|
||||
setXScreenSaver(xevent->xcreatewindow.window);
|
||||
}
|
||||
if (xevent->xproperty.state == PropertyNewValue && isXScreenSaver(xevent->xproperty.window)) {
|
||||
// found the xscreensaver
|
||||
setXScreenSaver(xevent->xcreatewindow.window);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user