chore: use const for more local ref and pointer vars

This commit is contained in:
sithlord48
2025-05-23 15:43:13 -04:00
committed by Nick Bolton
parent 9c56fa5dda
commit e6a374369b
13 changed files with 42 additions and 42 deletions

View File

@ -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<socklen_t>(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(

View File

@ -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();
}

View File

@ -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<ClipboardChunk *>(data);
const auto *clipboardData = static_cast<ClipboardChunk *>(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);

View File

@ -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()) {

View File

@ -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);
}

View File

@ -361,7 +361,7 @@ void SecureSocket::initContext(bool server)
}
// create new context from method
auto *m = const_cast<SSL_METHOD *>(method);
const auto *m = const_cast<SSL_METHOD *>(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

View File

@ -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()) {

View File

@ -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()]) {

View File

@ -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<XWindowsKeyState *>(vself);
const auto *self = static_cast<XWindowsKeyState *>(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;
}

View File

@ -1112,7 +1112,7 @@ IKeyState *XWindowsScreen::getKeyState() const
Bool XWindowsScreen::findKeyEvent(Display *, XEvent *xevent, XPointer arg)
{
auto *filter = reinterpret_cast<KeyEventFilter *>(arg);
const auto *filter = reinterpret_cast<KeyEventFilter *>(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<XkbEvent *>(xevent);
const auto *xkbEvent = reinterpret_cast<XkbEvent *>(xevent);
switch (xkbEvent->any.xkb_type) {
case XkbMapNotify:
refreshKeyboard(xevent);

View File

@ -1875,7 +1875,7 @@ void XWindowsUtil::appendTimeData(std::string &data, Time time)
Bool XWindowsUtil::propertyNotifyPredicate(Display *, XEvent *xevent, XPointer arg)
{
auto *filter = reinterpret_cast<PropertyNotifyPredicateInfo *>(arg);
const auto *filter = reinterpret_cast<PropertyNotifyPredicateInfo *>(arg);
return (xevent->type == PropertyNotify && xevent->xproperty.window == filter->m_window &&
xevent->xproperty.atom == filter->m_property && xevent->xproperty.state == PropertyNewValue)
? True

View File

@ -80,7 +80,7 @@ InputFilter::EFilterStatus InputFilter::KeystrokeCondition::match(const Event &e
}
// check if it's our hotkey
if (auto *kinfo = static_cast<IPlatformScreen::HotKeyInfo *>(event.getData()); kinfo->m_id != m_id) {
if (const auto *kinfo = static_cast<IPlatformScreen::HotKeyInfo *>(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<IPlatformScreen::ButtonInfo *>(event.getData());
if (const auto *minfo = static_cast<IPlatformScreen::ButtonInfo *>(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<Server::ScreenConnectedInfo *>(event.getData());
const auto *info = static_cast<Server::ScreenConnectedInfo *>(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<Server::ScreenConnectedInfo *>(event.getData());
const auto *info = static_cast<Server::ScreenConnectedInfo *>(event.getData());
screen = info->m_screen;
}

View File

@ -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<IPlatformScreen::KeyInfo *>(event.getData());
const auto *info = static_cast<IPlatformScreen::KeyInfo *>(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<IPlatformScreen::KeyInfo *>(event.getData());
const auto *info = static_cast<IPlatformScreen::KeyInfo *>(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<IPlatformScreen::ButtonInfo *>(event.getData());
const auto *info = static_cast<IPlatformScreen::ButtonInfo *>(event.getData());
onMouseDown(info->m_button);
}
void Server::handleButtonUpEvent(const Event &event, void *)
{
auto *info = static_cast<IPlatformScreen::ButtonInfo *>(event.getData());
const auto *info = static_cast<IPlatformScreen::ButtonInfo *>(event.getData());
onMouseUp(info->m_button);
}
void Server::handleMotionPrimaryEvent(const Event &event, void *)
{
auto *info = static_cast<IPlatformScreen::MotionInfo *>(event.getData());
const auto *info = static_cast<IPlatformScreen::MotionInfo *>(event.getData());
onMouseMovePrimary(info->m_x, info->m_y);
}
void Server::handleMotionSecondaryEvent(const Event &event, void *)
{
auto *info = static_cast<IPlatformScreen::MotionInfo *>(event.getData());
const auto *info = static_cast<IPlatformScreen::MotionInfo *>(event.getData());
onMouseMoveSecondary(info->m_x, info->m_y);
}
void Server::handleWheelEvent(const Event &event, void *)
{
auto *info = static_cast<IPlatformScreen::WheelInfo *>(event.getData());
const auto *info = static_cast<IPlatformScreen::WheelInfo *>(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<SwitchInDirectionInfo *>(event.getData());
const auto *info = static_cast<SwitchInDirectionInfo *>(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);