diff --git a/src/lib/arch/unix/ArchNetworkBSD.cpp b/src/lib/arch/unix/ArchNetworkBSD.cpp index ed468ab7f..e669fd29b 100644 --- a/src/lib/arch/unix/ArchNetworkBSD.cpp +++ b/src/lib/arch/unix/ArchNetworkBSD.cpp @@ -603,7 +603,7 @@ std::string ArchNetworkBSD::addrToString(ArchNetAddress addr) switch (getAddrFamily(addr)) { case kINET: { - auto *ipAddr = TYPED_ADDR(struct sockaddr_in, addr); + const auto *ipAddr = TYPED_ADDR(struct sockaddr_in, addr); ARCH->lockMutex(m_mutex); std::string s = inet_ntoa(ipAddr->sin_addr); ARCH->unlockMutex(m_mutex); @@ -612,7 +612,7 @@ std::string ArchNetworkBSD::addrToString(ArchNetAddress addr) case kINET6: { char strAddr[INET6_ADDRSTRLEN]; - auto *ipAddr = TYPED_ADDR(struct sockaddr_in6, addr); + const auto *ipAddr = TYPED_ADDR(struct sockaddr_in6, addr); ARCH->lockMutex(m_mutex); inet_ntop(AF_INET6, &ipAddr->sin6_addr, strAddr, INET6_ADDRSTRLEN); ARCH->unlockMutex(m_mutex); @@ -669,12 +669,12 @@ int ArchNetworkBSD::getAddrPort(ArchNetAddress addr) switch (getAddrFamily(addr)) { case kINET: { - auto *ipAddr = TYPED_ADDR(struct sockaddr_in, addr); + const auto *ipAddr = TYPED_ADDR(struct sockaddr_in, addr); return ntohs(ipAddr->sin_port); } case kINET6: { - auto *ipAddr = TYPED_ADDR(struct sockaddr_in6, addr); + const auto *ipAddr = TYPED_ADDR(struct sockaddr_in6, addr); return ntohs(ipAddr->sin6_port); } @@ -690,12 +690,12 @@ bool ArchNetworkBSD::isAnyAddr(ArchNetAddress addr) switch (getAddrFamily(addr)) { case kINET: { - auto *ipAddr = TYPED_ADDR(struct sockaddr_in, addr); + const auto *ipAddr = TYPED_ADDR(struct sockaddr_in, addr); return (ipAddr->sin_addr.s_addr == INADDR_ANY && addr->m_len == static_cast(sizeof(struct sockaddr_in))); } case kINET6: { - auto *ipAddr = TYPED_ADDR(struct sockaddr_in6, addr); + const auto *ipAddr = TYPED_ADDR(struct sockaddr_in6, addr); return ( addr->m_len == (socklen_t)sizeof(struct sockaddr_in6) && memcmp( diff --git a/src/lib/base/EventQueue.cpp b/src/lib/base/EventQueue.cpp index ed94cc0b7..e1e4cab7e 100644 --- a/src/lib/base/EventQueue.cpp +++ b/src/lib/base/EventQueue.cpp @@ -57,7 +57,7 @@ void EventQueue::loop() LOG((CLOG_DEBUG "event queue is ready")); while (!m_pending.empty()) { LOG((CLOG_DEBUG "add pending events to buffer")); - Event &event = m_pending.front(); + const Event &event = m_pending.front(); addEventToBuffer(event); m_pending.pop(); } diff --git a/src/lib/deskflow/ClipboardChunk.cpp b/src/lib/deskflow/ClipboardChunk.cpp index 2d35deb43..6cb49a963 100644 --- a/src/lib/deskflow/ClipboardChunk.cpp +++ b/src/lib/deskflow/ClipboardChunk.cpp @@ -97,11 +97,11 @@ int ClipboardChunk::assemble(deskflow::IStream *stream, std::string &dataCached, void ClipboardChunk::send(deskflow::IStream *stream, void *data) { - auto *clipboardData = static_cast(data); + const auto *clipboardData = static_cast(data); LOG((CLOG_DEBUG1 "sending clipboard chunk")); - char *chunk = clipboardData->m_chunk; + const char *chunk = clipboardData->m_chunk; ClipboardID id = chunk[0]; uint32_t sequence; std::memcpy(&sequence, &chunk[1], 4); diff --git a/src/lib/gui/ServerConfig.cpp b/src/lib/gui/ServerConfig.cpp index f414ad306..a8101d5af 100644 --- a/src/lib/gui/ServerConfig.cpp +++ b/src/lib/gui/ServerConfig.cpp @@ -133,7 +133,7 @@ void ServerConfig::commit() settings().beginWriteArray("screens"); for (int i = 0; i < screens().size(); i++) { settings().setArrayIndex(i); - auto &screen = screens()[i]; + const auto &screen = screens()[i]; screen.saveSettings(settings()); auto screenName = Settings::value(Settings::Core::ScreenName).toString(); if (screen.isServer() && screenName != screen.name()) { diff --git a/src/lib/gui/dialogs/AddClientDialog.cpp b/src/lib/gui/dialogs/AddClientDialog.cpp index 59421375e..928c0e9cf 100644 --- a/src/lib/gui/dialogs/AddClientDialog.cpp +++ b/src/lib/gui/dialogs/AddClientDialog.cpp @@ -57,7 +57,7 @@ AddClientDialog::AddClientDialog(const QString &clientName, QWidget *parent) ui->m_pDialogButtonBox->setLayoutDirection(Qt::RightToLeft); #endif - QPushButton *advanced = ui->m_pDialogButtonBox->addButton("Advanced", QDialogButtonBox::HelpRole); + const auto *advanced = ui->m_pDialogButtonBox->addButton(QStringLiteral("Advanced"), QDialogButtonBox::HelpRole); connect(advanced, &QPushButton::clicked, this, &AddClientDialog::handleButtonAdvanced); } diff --git a/src/lib/net/SecureSocket.cpp b/src/lib/net/SecureSocket.cpp index 0fbdb9923..ba85423bd 100644 --- a/src/lib/net/SecureSocket.cpp +++ b/src/lib/net/SecureSocket.cpp @@ -361,7 +361,7 @@ void SecureSocket::initContext(bool server) } // create new context from method - auto *m = const_cast(method); + const auto *m = const_cast(method); m_ssl->m_context = SSL_CTX_new(m); // Prevent the usage of of all version prior to TLSv1.2 as they are known to diff --git a/src/lib/net/SocketMultiplexer.cpp b/src/lib/net/SocketMultiplexer.cpp index 1f9fa8e27..3cf7c06ec 100644 --- a/src/lib/net/SocketMultiplexer.cpp +++ b/src/lib/net/SocketMultiplexer.cpp @@ -148,7 +148,7 @@ void SocketMultiplexer::serviceThread(void *) JobCursor cursor = newCursor(); JobCursor jobCursor = nextCursor(cursor); while (jobCursor != m_socketJobs.end()) { - if (ISocketMultiplexerJob *job = *jobCursor; job) { + if (const ISocketMultiplexerJob *job = *jobCursor; job) { pfd.m_socket = job->getSocket(); pfd.m_events = 0; if (job->isReadable()) { diff --git a/src/lib/platform/XWindowsClipboard.cpp b/src/lib/platform/XWindowsClipboard.cpp index 2db217f3f..0bef566ed 100644 --- a/src/lib/platform/XWindowsClipboard.cpp +++ b/src/lib/platform/XWindowsClipboard.cpp @@ -145,7 +145,7 @@ bool XWindowsClipboard::addSimpleRequest(Window requestor, Atom target, ::Time t } else if (target == m_atomTimestamp) { type = getTimestampData(data, &format); } else { - IXWindowsClipboardConverter *converter = getConverter(target); + const IXWindowsClipboardConverter *converter = getConverter(target); if (converter != nullptr) { IClipboard::EFormat clipboardFormat = converter->getFormat(); if (m_added[clipboardFormat]) { @@ -190,7 +190,7 @@ bool XWindowsClipboard::processRequest(Window requestor, ::Time /*time*/, Atom p // first property but we'll check 'em all if we have to. ReplyList &replies = index->second; for (auto index2 = replies.begin(); index2 != replies.end(); ++index2) { - Reply *reply = *index2; + const Reply *reply = *index2; if (reply->m_replied && reply->m_property == property) { // if reply is complete then remove it and start the // next one. @@ -467,7 +467,7 @@ void XWindowsClipboard::icccmFillCache() // try each converter in order (because they're in order of // preference). for (ConverterList::const_iterator index = m_converters.begin(); index != m_converters.end(); ++index) { - IXWindowsClipboardConverter *converter = *index; + const IXWindowsClipboardConverter *converter = *index; // skip already handled targets if (m_added[converter->getFormat()]) { @@ -692,7 +692,7 @@ void XWindowsClipboard::motifFillCache() // try each converter in order (because they're in order of // preference). for (ConverterList::const_iterator index = m_converters.begin(); index != m_converters.end(); ++index) { - IXWindowsClipboardConverter *converter = *index; + const IXWindowsClipboardConverter *converter = *index; // skip already handled targets if (m_added[converter->getFormat()]) { @@ -1120,7 +1120,7 @@ Atom XWindowsClipboard::getTargetsData(std::string &data, int *format) const // add targets we can convert to for (auto index = m_converters.begin(); index != m_converters.end(); ++index) { - IXWindowsClipboardConverter *converter = *index; + const IXWindowsClipboardConverter *converter = *index; // skip formats we don't have if (m_added[converter->getFormat()]) { diff --git a/src/lib/platform/XWindowsKeyState.cpp b/src/lib/platform/XWindowsKeyState.cpp index 5e6f3b72f..f7eaa9dbc 100644 --- a/src/lib/platform/XWindowsKeyState.cpp +++ b/src/lib/platform/XWindowsKeyState.cpp @@ -629,7 +629,7 @@ void XWindowsKeyState::updateKeysymMapXKB(deskflow::KeyMap &keyMap) int eGroup = getEffectiveGroup(keycode, group); // get key info - XkbKeyTypePtr type = XkbKeyKeyType(m_xkb, keycode, eGroup); + const XkbKeyTypePtr type = XkbKeyKeyType(m_xkb, keycode, eGroup); // set modifiers the item is sensitive to item.m_sensitive = type->mods.mask; @@ -664,7 +664,7 @@ void XWindowsKeyState::updateKeysymMapXKB(deskflow::KeyMap &keyMap) bool isModifier = false; uint32_t modifierMask = m_xkb->map->modmap[keycode]; if (XkbKeyHasActions(m_xkb, keycode) == True) { - XkbAction *action = XkbKeyActionEntry(m_xkb, keycode, level, eGroup); + const XkbAction *action = XkbKeyActionEntry(m_xkb, keycode, level, eGroup); if (action->type == XkbSA_SetMods || action->type == XkbSA_LockMods) { isModifier = true; @@ -788,7 +788,7 @@ void XWindowsKeyState::updateKeysymMapXKB(deskflow::KeyMap &keyMap) void XWindowsKeyState::remapKeyModifiers(KeyID id, int32_t group, deskflow::KeyMap::KeyItem &item, void *vself) { - auto *self = static_cast(vself); + const auto *self = static_cast(vself); item.m_required = self->mapModifiersFromX(XkbBuildCoreState(item.m_required, group)); item.m_sensitive = self->mapModifiersFromX(XkbBuildCoreState(item.m_sensitive, group)); } @@ -804,13 +804,13 @@ bool XWindowsKeyState::hasModifiersXKB() const int numGroups = XkbKeyNumGroups(m_xkb, keycode); for (int group = 0; group < numGroups; ++group) { // iterate over all shift levels for the button (including none) - XkbKeyTypePtr type = XkbKeyKeyType(m_xkb, keycode, group); + const XkbKeyTypePtr type = XkbKeyKeyType(m_xkb, keycode, group); for (int j = -1; j < type->map_count; ++j) { if (j != -1 && !type->map[j].active) { continue; } int level = ((j == -1) ? 0 : type->map[j].level); - XkbAction *action = XkbKeyActionEntry(m_xkb, keycode, level, group); + const XkbAction *action = XkbKeyActionEntry(m_xkb, keycode, level, group); if (action->type == XkbSA_SetMods || action->type == XkbSA_LockMods) { return true; } diff --git a/src/lib/platform/XWindowsScreen.cpp b/src/lib/platform/XWindowsScreen.cpp index 840eba012..8a6aede4e 100644 --- a/src/lib/platform/XWindowsScreen.cpp +++ b/src/lib/platform/XWindowsScreen.cpp @@ -1112,7 +1112,7 @@ IKeyState *XWindowsScreen::getKeyState() const Bool XWindowsScreen::findKeyEvent(Display *, XEvent *xevent, XPointer arg) { - auto *filter = reinterpret_cast(arg); + const auto *filter = reinterpret_cast(arg); return (xevent->type == filter->m_event && xevent->xkey.window == filter->m_window && xevent->xkey.time == filter->m_time && xevent->xkey.keycode == filter->m_keycode) ? True @@ -1332,7 +1332,7 @@ void XWindowsScreen::handleSystemEvent(const Event &event, void *) default: #if HAVE_XKB_EXTENSION if (m_xkb && xevent->type == m_xkbEventBase) { - auto *xkbEvent = reinterpret_cast(xevent); + const auto *xkbEvent = reinterpret_cast(xevent); switch (xkbEvent->any.xkb_type) { case XkbMapNotify: refreshKeyboard(xevent); diff --git a/src/lib/platform/XWindowsUtil.cpp b/src/lib/platform/XWindowsUtil.cpp index faf721b65..606fedfa3 100644 --- a/src/lib/platform/XWindowsUtil.cpp +++ b/src/lib/platform/XWindowsUtil.cpp @@ -1875,7 +1875,7 @@ void XWindowsUtil::appendTimeData(std::string &data, Time time) Bool XWindowsUtil::propertyNotifyPredicate(Display *, XEvent *xevent, XPointer arg) { - auto *filter = reinterpret_cast(arg); + const auto *filter = reinterpret_cast(arg); return (xevent->type == PropertyNotify && xevent->xproperty.window == filter->m_window && xevent->xproperty.atom == filter->m_property && xevent->xproperty.state == PropertyNewValue) ? True diff --git a/src/lib/server/InputFilter.cpp b/src/lib/server/InputFilter.cpp index c63472b91..a52e7deb9 100644 --- a/src/lib/server/InputFilter.cpp +++ b/src/lib/server/InputFilter.cpp @@ -80,7 +80,7 @@ InputFilter::EFilterStatus InputFilter::KeystrokeCondition::match(const Event &e } // check if it's our hotkey - if (auto *kinfo = static_cast(event.getData()); kinfo->m_id != m_id) { + if (const auto *kinfo = static_cast(event.getData()); kinfo->m_id != m_id) { return kNoMatch; } @@ -156,7 +156,7 @@ InputFilter::EFilterStatus InputFilter::MouseButtonCondition::match(const Event // check if it's the right button and modifiers. ignore modifiers // that cannot be combined with a mouse button. - if (auto *minfo = static_cast(event.getData()); + if (const auto *minfo = static_cast(event.getData()); minfo->m_button != m_button || (minfo->m_mask & ~s_ignoreMask) != m_mask) { return kNoMatch; } @@ -184,7 +184,7 @@ std::string InputFilter::ScreenConnectedCondition::format() const InputFilter::EFilterStatus InputFilter::ScreenConnectedCondition::match(const Event &event) { if (event.getType() == EventTypes::ServerConnected) { - auto *info = static_cast(event.getData()); + const auto *info = static_cast(event.getData()); if (m_screen == info->m_screen || m_screen.empty()) { return kActivate; } @@ -288,7 +288,7 @@ void InputFilter::SwitchToScreenAction::perform(const Event &event) // event if it has one. std::string screen = m_screen; if (screen.empty() && event.getType() == EventTypes::ServerConnected) { - auto *info = static_cast(event.getData()); + const auto *info = static_cast(event.getData()); screen = info->m_screen; } diff --git a/src/lib/server/Server.cpp b/src/lib/server/Server.cpp index 2e96bd71d..a977e7654 100644 --- a/src/lib/server/Server.cpp +++ b/src/lib/server/Server.cpp @@ -440,7 +440,7 @@ void Server::switchScreen(BaseClientProxy *dst, int32_t x, int32_t y, bool forSc // primary screen. if (m_active == m_primaryClient && m_enableClipboard) { for (ClipboardID id = 0; id < kClipboardEnd; ++id) { - ClipboardInfo &clipboard = m_clipboards[id]; + const ClipboardInfo &clipboard = m_clipboards[id]; if (clipboard.m_clipboardOwner == getName(m_primaryClient)) { onClipboardChanged(m_primaryClient, id, clipboard.m_clipboardSeqNum); } @@ -1229,7 +1229,7 @@ void Server::handleClipboardChanged(const Event &event, void *vclient) void Server::handleKeyDownEvent(const Event &event, void *) { - auto *info = static_cast(event.getData()); + const auto *info = static_cast(event.getData()); auto lang = AppUtil::instance().getCurrentLanguageCode(); onKeyDown(info->m_key, info->m_mask, info->m_button, lang, info->m_screens); } @@ -1242,38 +1242,38 @@ void Server::handleKeyUpEvent(const Event &event, void *) void Server::handleKeyRepeatEvent(const Event &event, void *) { - auto *info = static_cast(event.getData()); + const auto *info = static_cast(event.getData()); auto lang = AppUtil::instance().getCurrentLanguageCode(); onKeyRepeat(info->m_key, info->m_mask, info->m_count, info->m_button, lang); } void Server::handleButtonDownEvent(const Event &event, void *) { - auto *info = static_cast(event.getData()); + const auto *info = static_cast(event.getData()); onMouseDown(info->m_button); } void Server::handleButtonUpEvent(const Event &event, void *) { - auto *info = static_cast(event.getData()); + const auto *info = static_cast(event.getData()); onMouseUp(info->m_button); } void Server::handleMotionPrimaryEvent(const Event &event, void *) { - auto *info = static_cast(event.getData()); + const auto *info = static_cast(event.getData()); onMouseMovePrimary(info->m_x, info->m_y); } void Server::handleMotionSecondaryEvent(const Event &event, void *) { - auto *info = static_cast(event.getData()); + const auto *info = static_cast(event.getData()); onMouseMoveSecondary(info->m_x, info->m_y); } void Server::handleWheelEvent(const Event &event, void *) { - auto *info = static_cast(event.getData()); + const auto *info = static_cast(event.getData()); onMouseWheel(info->m_xDelta, info->m_yDelta); } @@ -1335,7 +1335,7 @@ void Server::handleSwitchToScreenEvent(const Event &event, void *) void Server::handleSwitchInDirectionEvent(const Event &event, void *) { - auto *info = static_cast(event.getData()); + const auto *info = static_cast(event.getData()); // jump to screen in chosen direction from center of this screen int32_t x = m_x; @@ -1350,7 +1350,7 @@ void Server::handleSwitchInDirectionEvent(const Event &event, void *) void Server::handleKeyboardBroadcastEvent(const Event &event, void *) { - auto *info = (KeyboardBroadcastInfo *)event.getData(); + const auto *info = (KeyboardBroadcastInfo *)event.getData(); // choose new state bool newState; @@ -1382,7 +1382,7 @@ void Server::handleKeyboardBroadcastEvent(const Event &event, void *) void Server::handleLockCursorToScreenEvent(const Event &event, void *) { - auto *info = (LockCursorToScreenInfo *)event.getData(); + const auto *info = (LockCursorToScreenInfo *)event.getData(); // choose new state bool newState; @@ -2018,7 +2018,7 @@ void Server::removeOldClient(BaseClientProxy *client) void Server::forceLeaveClient(const BaseClientProxy *client) { - if (BaseClientProxy *active = (m_activeSaver != nullptr) ? m_activeSaver : m_active; active == client) { + if (const auto *active = (m_activeSaver != nullptr) ? m_activeSaver : m_active; active == client) { // record new position (center of primary screen) m_primaryClient->getCursorCenter(m_x, m_y);