From 4c15ec1b99cc560709ebb22c62ca9630ceaee47f Mon Sep 17 00:00:00 2001 From: akallabeth Date: Fri, 23 Jan 2026 19:45:10 +0100 Subject: [PATCH] [client,sdl] add nodiscard to functions --- .../dialogs/res/sdl3_resource_manager.hpp | 2 +- .../SDL/SDL3/dialogs/sdl_blend_mode_guard.hpp | 2 +- client/SDL/SDL3/dialogs/sdl_button.cpp | 4 +- client/SDL/SDL3/dialogs/sdl_buttons.cpp | 6 +- client/SDL/SDL3/dialogs/sdl_buttons.hpp | 18 +++--- .../SDL3/dialogs/sdl_connection_dialog.cpp | 57 ++++++++++++------- .../SDL3/dialogs/sdl_connection_dialog.hpp | 38 ++++++------- .../dialogs/sdl_connection_dialog_wrapper.cpp | 12 ++-- .../dialogs/sdl_connection_dialog_wrapper.hpp | 6 +- client/SDL/SDL3/dialogs/sdl_dialogs.hpp | 43 +++++++------- client/SDL/SDL3/dialogs/sdl_input_widget.hpp | 2 +- .../SDL3/dialogs/sdl_input_widget_pair.cpp | 4 +- .../SDL3/dialogs/sdl_input_widget_pair.hpp | 14 ++--- .../dialogs/sdl_input_widget_pair_list.cpp | 14 +++-- .../dialogs/sdl_input_widget_pair_list.hpp | 10 ++-- client/SDL/SDL3/dialogs/sdl_select.cpp | 2 +- client/SDL/SDL3/dialogs/sdl_select_list.cpp | 18 +++--- client/SDL/SDL3/dialogs/sdl_select_list.hpp | 4 +- .../SDL3/dialogs/sdl_selectable_widget.hpp | 6 +- client/SDL/SDL3/dialogs/sdl_widget.cpp | 25 ++++---- client/SDL/SDL3/dialogs/sdl_widget.hpp | 26 +++++---- client/SDL/SDL3/dialogs/sdl_widget_list.cpp | 8 ++- client/SDL/SDL3/dialogs/sdl_widget_list.hpp | 8 +-- client/SDL/SDL3/sdl_clip.cpp | 10 ++-- client/SDL/SDL3/sdl_disp.hpp | 4 +- client/SDL/SDL3/sdl_freerdp.cpp | 14 +++-- client/SDL/SDL3/sdl_kbd.cpp | 16 +++--- client/SDL/SDL3/sdl_monitor.cpp | 15 +++-- client/SDL/SDL3/sdl_pointer.cpp | 10 ++-- client/SDL/SDL3/sdl_utils.hpp | 2 +- client/SDL/common/aad/sdl_webview.hpp | 4 +- client/SDL/common/aad/webview_impl.hpp | 3 +- .../SDL/common/res/sdl_resource_manager.hpp | 13 +++-- client/SDL/common/sdl_prefs.hpp | 7 ++- 34 files changed, 235 insertions(+), 192 deletions(-) diff --git a/client/SDL/SDL3/dialogs/res/sdl3_resource_manager.hpp b/client/SDL/SDL3/dialogs/res/sdl3_resource_manager.hpp index 638435708..93970ae63 100644 --- a/client/SDL/SDL3/dialogs/res/sdl3_resource_manager.hpp +++ b/client/SDL/SDL3/dialogs/res/sdl3_resource_manager.hpp @@ -34,5 +34,5 @@ class SDL3ResourceManager : public SDLResourceManager SDL3ResourceManager& operator=(const SDL3ResourceManager& other) = delete; SDL3ResourceManager& operator=(SDL3ResourceManager&& other) = delete; - static SDL_IOStream* get(const std::string& type, const std::string& id); + [[nodiscard]] static SDL_IOStream* get(const std::string& type, const std::string& id); }; diff --git a/client/SDL/SDL3/dialogs/sdl_blend_mode_guard.hpp b/client/SDL/SDL3/dialogs/sdl_blend_mode_guard.hpp index 1262133f2..2057e7e6b 100644 --- a/client/SDL/SDL3/dialogs/sdl_blend_mode_guard.hpp +++ b/client/SDL/SDL3/dialogs/sdl_blend_mode_guard.hpp @@ -37,7 +37,7 @@ class SdlBlendModeGuard SdlBlendModeGuard& operator=(const SdlBlendModeGuard& other) = delete; SdlBlendModeGuard& operator=(SdlBlendModeGuard&& other) = delete; - bool update(SDL_BlendMode mode); + [[nodiscard]] bool update(SDL_BlendMode mode); private: SDL_BlendMode _restore_mode = SDL_BLENDMODE_INVALID; diff --git a/client/SDL/SDL3/dialogs/sdl_button.cpp b/client/SDL/SDL3/dialogs/sdl_button.cpp index 28704dec8..ef625e1cd 100644 --- a/client/SDL/SDL3/dialogs/sdl_button.cpp +++ b/client/SDL/SDL3/dialogs/sdl_button.cpp @@ -31,8 +31,8 @@ SdlButton::SdlButton(std::shared_ptr& renderer, const std::string& _highlightcolor = { 0xcd, 0xca, 0x35, 0x60 }; _mouseovercolor = { 0x66, 0xff, 0x66, 0x60 }; _fontcolor = { 0xd1, 0xcf, 0xcd, 0xff }; - update_text(label); - update(); + (void)update_text(label); + (void)update(); } SdlButton::SdlButton(SdlButton&& other) noexcept = default; diff --git a/client/SDL/SDL3/dialogs/sdl_buttons.cpp b/client/SDL/SDL3/dialogs/sdl_buttons.cpp index aadb32ab2..f7d54fd37 100644 --- a/client/SDL/SDL3/dialogs/sdl_buttons.cpp +++ b/client/SDL/SDL3/dialogs/sdl_buttons.cpp @@ -95,8 +95,10 @@ bool SdlButtonList::update() { for (auto& btn : _list) { - btn->highlight(btn == _highlighted); - btn->mouseover(btn == _mouseover); + if (!btn->highlight(btn == _highlighted)) + return false; + if (!btn->mouseover(btn == _mouseover)) + return false; if (!btn->update()) return false; diff --git a/client/SDL/SDL3/dialogs/sdl_buttons.hpp b/client/SDL/SDL3/dialogs/sdl_buttons.hpp index 281cf2b63..733380894 100644 --- a/client/SDL/SDL3/dialogs/sdl_buttons.hpp +++ b/client/SDL/SDL3/dialogs/sdl_buttons.hpp @@ -17,17 +17,17 @@ class SdlButtonList SdlButtonList& operator=(const SdlButtonList& other) = delete; SdlButtonList& operator=(SdlButtonList&& other) = delete; - bool populate(std::shared_ptr& renderer, const std::vector& labels, - const std::vector& ids, Sint32 total_width, Sint32 offsetY, Sint32 width, - Sint32 height); + [[nodiscard]] bool populate(std::shared_ptr& renderer, + const std::vector& labels, const std::vector& ids, + Sint32 total_width, Sint32 offsetY, Sint32 width, Sint32 height); - bool update(); - std::shared_ptr get_selected(const SDL_MouseButtonEvent& button); - std::shared_ptr get_selected(float x, float y); + [[nodiscard]] bool update(); + [[nodiscard]] std::shared_ptr get_selected(const SDL_MouseButtonEvent& button); + [[nodiscard]] std::shared_ptr get_selected(float x, float y); - bool set_highlight_next(bool reset = false); - bool set_highlight(size_t index); - bool set_mouseover(float x, float y); + [[nodiscard]] bool set_highlight_next(bool reset = false); + [[nodiscard]] bool set_highlight(size_t index); + [[nodiscard]] bool set_mouseover(float x, float y); void clear(); diff --git a/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp b/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp index a2c935093..904a735a8 100644 --- a/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp +++ b/client/SDL/SDL3/dialogs/sdl_connection_dialog.cpp @@ -34,7 +34,7 @@ static const Uint32 hpadding = 5; SDLConnectionDialog::SDLConnectionDialog(rdpContext* context) : _context(context) { - hide(); + (void)hide(); } SDLConnectionDialog::~SDLConnectionDialog() @@ -109,7 +109,8 @@ bool SDLConnectionDialog::updateMsg(SdlConnectionDialogWrapper::MsgType type) case SdlConnectionDialogWrapper::MSG_WARN: case SdlConnectionDialogWrapper::MSG_ERROR: _type_active = type; - createWindow(); + if (!createWindow()) + return false; break; case SdlConnectionDialogWrapper::MSG_DISCARD: resetTimer(); @@ -192,7 +193,8 @@ bool SDLConnectionDialog::handle(const SDL_Event& event) if (visible()) { auto& ev = reinterpret_cast(event); - update(); + if (!update()) + return false; switch (event.key.key) { case SDLK_RETURN: @@ -206,7 +208,8 @@ bool SDLConnectionDialog::handle(const SDL_Event& event) } break; case SDLK_TAB: - _buttons.set_highlight_next(); + if (!_buttons.set_highlight_next()) + return false; break; default: break; @@ -220,8 +223,10 @@ bool SDLConnectionDialog::handle(const SDL_Event& event) { auto& ev = reinterpret_cast(event); - _buttons.set_mouseover(event.button.x, event.button.y); - update(); + if (!_buttons.set_mouseover(event.button.x, event.button.y)) + return false; + if (!update()) + return false; return windowID == ev.windowID; } return false; @@ -230,7 +235,8 @@ bool SDLConnectionDialog::handle(const SDL_Event& event) if (visible()) { auto& ev = reinterpret_cast(event); - update(); + if (!update()) + return false; auto button = _buttons.get_selected(event.button); if (button) @@ -249,7 +255,8 @@ bool SDLConnectionDialog::handle(const SDL_Event& event) if (visible()) { auto& ev = reinterpret_cast(event); - update(); + if (!update()) + return false; return windowID == ev.windowID; } return false; @@ -258,7 +265,8 @@ bool SDLConnectionDialog::handle(const SDL_Event& event) if (visible()) { auto& ev = reinterpret_cast(event); - update(); + if (!update()) + return false; return windowID == ev.windowID; } return false; @@ -276,8 +284,10 @@ bool SDLConnectionDialog::handle(const SDL_Event& event) } break; default: - update(); - setModal(); + if (!update()) + return false; + if (!setModal()) + return false; break; } @@ -304,7 +314,8 @@ bool SDLConnectionDialog::createWindow() if (!reset(_title, widget_width, total_height)) return false; - setModal(); + if (!setModal()) + return false; SDL_Color res_bgcolor; switch (_type_active) @@ -369,19 +380,25 @@ bool SDLConnectionDialog::createWindow() #endif widget_cfg_t w{ textcolor, _backgroundcolor, { _renderer, rect } }; - w.widget.set_wrap(true, widget_width); + if (!w.widget.set_wrap(true, widget_width)) + return false; _list.emplace_back(std::move(w)); rect.y += widget_height + vpadding; const std::vector buttonids = { 1 }; const std::vector buttonlabels = { "cancel" }; - _buttons.populate(_renderer, buttonlabels, buttonids, widget_width, - total_height - widget_height - vpadding, - static_cast(widget_width / 2), static_cast(widget_height)); - _buttons.set_highlight(0); + if (!_buttons.populate(_renderer, buttonlabels, buttonids, widget_width, + total_height - widget_height - vpadding, + static_cast(widget_width / 2), + static_cast(widget_height))) + return false; + if (!_buttons.set_highlight(0)) + return false; - SDL_ShowWindow(_window.get()); - SDL_RaiseWindow(_window.get()); + if (!SDL_ShowWindow(_window.get())) + return false; + if (!SDL_RaiseWindow(_window.get())) + return false; return true; } @@ -455,7 +472,7 @@ Uint32 SDLConnectionDialog::timeout(void* pvthis, [[maybe_unused]] SDL_TimerID t [[maybe_unused]] Uint32 intervalMS) { auto self = static_cast(pvthis); - self->hide(); + (void)self->hide(); self->_running = false; return 0; } diff --git a/client/SDL/SDL3/dialogs/sdl_connection_dialog.hpp b/client/SDL/SDL3/dialogs/sdl_connection_dialog.hpp index 6021af251..051da4843 100644 --- a/client/SDL/SDL3/dialogs/sdl_connection_dialog.hpp +++ b/client/SDL/SDL3/dialogs/sdl_connection_dialog.hpp @@ -42,40 +42,40 @@ class SDLConnectionDialog : public SdlWidgetList SDLConnectionDialog& operator=(const SDLConnectionDialog& other) = delete; SDLConnectionDialog& operator=(SDLConnectionDialog&& other) = delete; - bool setTitle(const char* fmt, ...); - bool showInfo(const char* fmt, ...); - bool showWarn(const char* fmt, ...); - bool showError(const char* fmt, ...); + [[nodiscard]] bool setTitle(const char* fmt, ...); + [[nodiscard]] bool showInfo(const char* fmt, ...); + [[nodiscard]] bool showWarn(const char* fmt, ...); + [[nodiscard]] bool showError(const char* fmt, ...); - bool show(); - bool hide(); + [[nodiscard]] bool show(); + [[nodiscard]] bool hide(); - bool running() const; - bool wait(bool ignoreRdpContextQuit = false); + [[nodiscard]] bool running() const; + [[nodiscard]] bool wait(bool ignoreRdpContextQuit = false); - bool handle(const SDL_Event& event); + [[nodiscard]] bool handle(const SDL_Event& event); - bool visible() const override; + [[nodiscard]] bool visible() const override; protected: - bool updateInternal() override; + [[nodiscard]] bool updateInternal() override; private: - bool createWindow(); + [[nodiscard]] bool createWindow(); void destroyWindow(); - bool updateMsg(SdlConnectionDialogWrapper::MsgType type); + [[nodiscard]] bool updateMsg(SdlConnectionDialogWrapper::MsgType type); - bool setModal(); + [[nodiscard]] bool setModal(); - bool show(SdlConnectionDialogWrapper::MsgType type, const char* fmt, va_list ap); - bool show(SdlConnectionDialogWrapper::MsgType type); + [[nodiscard]] bool show(SdlConnectionDialogWrapper::MsgType type, const char* fmt, va_list ap); + [[nodiscard]] bool show(SdlConnectionDialogWrapper::MsgType type); - static std::string print(const char* fmt, va_list ap); - bool setTimer(Uint32 timeoutMS = 15000); + [[nodiscard]] static std::string print(const char* fmt, va_list ap); + [[nodiscard]] bool setTimer(Uint32 timeoutMS = 15000); void resetTimer(); - static Uint32 timeout(void* pvthis, SDL_TimerID timerID, Uint32 intervalMS); + [[nodiscard]] static Uint32 timeout(void* pvthis, SDL_TimerID timerID, Uint32 intervalMS); struct widget_cfg_t { diff --git a/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.cpp b/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.cpp index 57e7e8523..45e775c6a 100644 --- a/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.cpp +++ b/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.cpp @@ -166,7 +166,7 @@ void SdlConnectionDialogWrapper::handleShow() if (arg.hasTitle() && _connection_dialog) { - _connection_dialog->setTitle(arg.title().c_str()); + (void)_connection_dialog->setTitle(arg.title().c_str()); } if (arg.hasType() && arg.hasMessage()) @@ -175,19 +175,19 @@ void SdlConnectionDialogWrapper::handleShow() { case SdlConnectionDialogWrapper::MSG_INFO: if (_connection_dialog) - _connection_dialog->showInfo(arg.message().c_str()); + (void)_connection_dialog->showInfo(arg.message().c_str()); else WLog_Print(_log, WLOG_INFO, "%s", arg.message().c_str()); break; case SdlConnectionDialogWrapper::MSG_WARN: if (_connection_dialog) - _connection_dialog->showWarn(arg.message().c_str()); + (void)_connection_dialog->showWarn(arg.message().c_str()); else WLog_Print(_log, WLOG_WARN, "%s", arg.message().c_str()); break; case SdlConnectionDialogWrapper::MSG_ERROR: if (_connection_dialog) - _connection_dialog->showError(arg.message().c_str()); + (void)_connection_dialog->showError(arg.message().c_str()); else WLog_Print(_log, WLOG_ERROR, "%s", arg.message().c_str()); break; @@ -199,9 +199,9 @@ void SdlConnectionDialogWrapper::handleShow() if (arg.hasVisibility() && _connection_dialog) { if (arg.visible()) - _connection_dialog->show(); + (void)_connection_dialog->show(); else - _connection_dialog->hide(); + (void)_connection_dialog->hide(); } } } diff --git a/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.hpp b/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.hpp index db96b689c..ed4665ea2 100644 --- a/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.hpp +++ b/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.hpp @@ -57,10 +57,10 @@ class SdlConnectionDialogWrapper void create(rdpContext* context); void destroy(); - bool isRunning() const; - bool isVisible() const; + [[nodiscard]] bool isRunning() const; + [[nodiscard]] bool isVisible() const; - bool handleEvent(const SDL_Event& event); + [[nodiscard]] bool handleEvent(const SDL_Event& event); WINPR_ATTR_FORMAT_ARG(2, 3) void setTitle(WINPR_FORMAT_ARG const char* fmt, ...); diff --git a/client/SDL/SDL3/dialogs/sdl_dialogs.hpp b/client/SDL/SDL3/dialogs/sdl_dialogs.hpp index db15de5c7..627b36934 100644 --- a/client/SDL/SDL3/dialogs/sdl_dialogs.hpp +++ b/client/SDL/SDL3/dialogs/sdl_dialogs.hpp @@ -25,32 +25,35 @@ #include "../sdl_types.hpp" #include "../sdl_utils.hpp" -BOOL sdl_authenticate_ex(freerdp* instance, char** username, char** password, char** domain, - rdp_auth_reason reason); -BOOL sdl_choose_smartcard(freerdp* instance, SmartcardCertInfo** cert_list, DWORD count, - DWORD* choice, BOOL gateway); +[[nodiscard]] BOOL sdl_authenticate_ex(freerdp* instance, char** username, char** password, + char** domain, rdp_auth_reason reason); +[[nodiscard]] BOOL sdl_choose_smartcard(freerdp* instance, SmartcardCertInfo** cert_list, + DWORD count, DWORD* choice, BOOL gateway); -SSIZE_T sdl_retry_dialog(freerdp* instance, const char* what, size_t current, void* userarg); +[[nodiscard]] SSIZE_T sdl_retry_dialog(freerdp* instance, const char* what, size_t current, + void* userarg); -DWORD sdl_verify_certificate_ex(freerdp* instance, const char* host, UINT16 port, - const char* common_name, const char* subject, const char* issuer, - const char* fingerprint, DWORD flags); +[[nodiscard]] DWORD sdl_verify_certificate_ex(freerdp* instance, const char* host, UINT16 port, + const char* common_name, const char* subject, + const char* issuer, const char* fingerprint, + DWORD flags); -DWORD sdl_verify_changed_certificate_ex(freerdp* instance, const char* host, UINT16 port, - const char* common_name, const char* subject, - const char* issuer, const char* new_fingerprint, - const char* old_subject, const char* old_issuer, - const char* old_fingerprint, DWORD flags); +[[nodiscard]] DWORD +sdl_verify_changed_certificate_ex(freerdp* instance, const char* host, UINT16 port, + const char* common_name, const char* subject, const char* issuer, + const char* new_fingerprint, const char* old_subject, + const char* old_issuer, const char* old_fingerprint, DWORD flags); -int sdl_logon_error_info(freerdp* instance, UINT32 data, UINT32 type); +[[nodiscard]] int sdl_logon_error_info(freerdp* instance, UINT32 data, UINT32 type); -BOOL sdl_present_gateway_message(freerdp* instance, UINT32 type, BOOL isDisplayMandatory, - BOOL isConsentMandatory, size_t length, const WCHAR* message); +[[nodiscard]] BOOL sdl_present_gateway_message(freerdp* instance, UINT32 type, + BOOL isDisplayMandatory, BOOL isConsentMandatory, + size_t length, const WCHAR* message); -BOOL sdl_message_dialog_show(const char* title, const char* message, Sint32 flags); -BOOL sdl_cert_dialog_show(const char* title, const char* message); -BOOL sdl_scard_dialog_show(const char* title, Sint32 count, const char** list); -BOOL sdl_auth_dialog_show(const SDL_UserAuthArg* args); +[[nodiscard]] BOOL sdl_message_dialog_show(const char* title, const char* message, Sint32 flags); +[[nodiscard]] BOOL sdl_cert_dialog_show(const char* title, const char* message); +[[nodiscard]] BOOL sdl_scard_dialog_show(const char* title, Sint32 count, const char** list); +[[nodiscard]] BOOL sdl_auth_dialog_show(const SDL_UserAuthArg* args); void sdl_dialogs_init(); void sdl_dialogs_uninit(); diff --git a/client/SDL/SDL3/dialogs/sdl_input_widget.hpp b/client/SDL/SDL3/dialogs/sdl_input_widget.hpp index 92c35279f..26235e79f 100644 --- a/client/SDL/SDL3/dialogs/sdl_input_widget.hpp +++ b/client/SDL/SDL3/dialogs/sdl_input_widget.hpp @@ -36,7 +36,7 @@ class SdlInputWidget : public SdlSelectableWidget ~SdlInputWidget() override; - std::string text() const; + [[nodiscard]] std::string text() const; private: void init(); diff --git a/client/SDL/SDL3/dialogs/sdl_input_widget_pair.cpp b/client/SDL/SDL3/dialogs/sdl_input_widget_pair.cpp index 5b014f6fa..319f6eb88 100644 --- a/client/SDL/SDL3/dialogs/sdl_input_widget_pair.cpp +++ b/client/SDL/SDL3/dialogs/sdl_input_widget_pair.cpp @@ -40,8 +40,8 @@ SdlInputWidgetPair::SdlInputWidgetPair(std::shared_ptr& renderer, static_cast(offset * (height + _vpadding)), static_cast(width), static_cast(height) }) { - _label.update_text(label); - update_input_text(initial); + (void)_label.update_text(label); + (void)update_input_text(initial); } SdlInputWidgetPair::SdlInputWidgetPair(SdlInputWidgetPair&& other) noexcept = default; diff --git a/client/SDL/SDL3/dialogs/sdl_input_widget_pair.hpp b/client/SDL/SDL3/dialogs/sdl_input_widget_pair.hpp index f872c10da..ebbcec0f5 100644 --- a/client/SDL/SDL3/dialogs/sdl_input_widget_pair.hpp +++ b/client/SDL/SDL3/dialogs/sdl_input_widget_pair.hpp @@ -45,22 +45,22 @@ class SdlInputWidgetPair SdlInputWidgetPair& operator=(const SdlInputWidgetPair& other) = delete; SdlInputWidgetPair& operator=(SdlInputWidgetPair&& other) = delete; - bool set_mouseover(bool mouseOver); - bool set_highlight(bool highlight); + [[nodiscard]] bool set_mouseover(bool mouseOver); + [[nodiscard]] bool set_highlight(bool highlight); - bool set_str(const std::string& text); - bool remove_str(size_t count); - bool append_str(const std::string& text); + [[nodiscard]] bool set_str(const std::string& text); + [[nodiscard]] bool remove_str(size_t count); + [[nodiscard]] bool append_str(const std::string& text); [[nodiscard]] const SDL_FRect& input_rect() const; [[nodiscard]] std::string value() const; [[nodiscard]] bool readonly() const; - bool update(); + [[nodiscard]] bool update(); protected: - bool update_input_text(const std::string& txt); + [[nodiscard]] bool update_input_text(const std::string& txt); Uint32 _vpadding = 5; Uint32 _hpadding = 10; diff --git a/client/SDL/SDL3/dialogs/sdl_input_widget_pair_list.cpp b/client/SDL/SDL3/dialogs/sdl_input_widget_pair_list.cpp index 261024c57..08b4cfd77 100644 --- a/client/SDL/SDL3/dialogs/sdl_input_widget_pair_list.cpp +++ b/client/SDL/SDL3/dialogs/sdl_input_widget_pair_list.cpp @@ -55,10 +55,10 @@ SdlInputWidgetPairList::SdlInputWidgetPairList(const std::string& title, m_list.emplace_back(widget); } - _buttons.populate(_renderer, buttonlabels, buttonids, total_width, - static_cast(input_height), static_cast(widget_width), - static_cast(widget_heigth)); - _buttons.set_highlight(0); + (void)_buttons.populate( + _renderer, buttonlabels, buttonids, total_width, static_cast(input_height), + static_cast(widget_width), static_cast(widget_heigth)); + (void)_buttons.set_highlight(0); m_currentActiveTextInput = selected; } } @@ -211,7 +211,8 @@ int SdlInputWidgetPairList::run(std::vector& result) if (cur) { auto text = SDL_GetClipboardText(); - cur->set_str(text); + if (!cur->set_str(text)) + throw; } } break; @@ -245,7 +246,8 @@ int SdlInputWidgetPairList::run(std::vector& result) throw; } - _buttons.set_mouseover(event.button.x, event.button.y); + if (!_buttons.set_mouseover(event.button.x, event.button.y)) + throw; } break; case SDL_EVENT_MOUSE_BUTTON_DOWN: diff --git a/client/SDL/SDL3/dialogs/sdl_input_widget_pair_list.hpp b/client/SDL/SDL3/dialogs/sdl_input_widget_pair_list.hpp index 0b42cca16..5de4762cd 100644 --- a/client/SDL/SDL3/dialogs/sdl_input_widget_pair_list.hpp +++ b/client/SDL/SDL3/dialogs/sdl_input_widget_pair_list.hpp @@ -41,11 +41,11 @@ class SdlInputWidgetPairList : public SdlWidgetList SdlInputWidgetPairList& operator=(const SdlInputWidgetPairList& other) = delete; SdlInputWidgetPairList& operator=(SdlInputWidgetPairList&& other) = delete; - int run(std::vector& result); + [[nodiscard]] int run(std::vector& result); protected: - bool updateInternal() override; - ssize_t get_index(const SDL_MouseButtonEvent& button); + [[nodiscard]] bool updateInternal() override; + [[nodiscard]] ssize_t get_index(const SDL_MouseButtonEvent& button); private: enum @@ -54,9 +54,9 @@ class SdlInputWidgetPairList : public SdlWidgetList INPUT_BUTTON_CANCEL = -2 }; - ssize_t next(ssize_t current); + [[nodiscard]] ssize_t next(ssize_t current); [[nodiscard]] bool valid(ssize_t current) const; - std::shared_ptr get(ssize_t index); + [[nodiscard]] std::shared_ptr get(ssize_t index); std::vector> m_list; ssize_t m_currentActiveTextInput = -1; diff --git a/client/SDL/SDL3/dialogs/sdl_select.cpp b/client/SDL/SDL3/dialogs/sdl_select.cpp index 9de01ae70..ac2490664 100644 --- a/client/SDL/SDL3/dialogs/sdl_select.cpp +++ b/client/SDL/SDL3/dialogs/sdl_select.cpp @@ -37,7 +37,7 @@ SdlSelectWidget::SdlSelectWidget(std::shared_ptr& renderer, const { _backgroundcolor = { 0x69, 0x66, 0x63, 0xff }; _fontcolor = { 0xd1, 0xcf, 0xcd, 0xff }; - update_text(label); + (void)update_text(label); } SdlSelectWidget::~SdlSelectWidget() = default; diff --git a/client/SDL/SDL3/dialogs/sdl_select_list.cpp b/client/SDL/SDL3/dialogs/sdl_select_list.cpp index a5a91b741..a4cebfe15 100644 --- a/client/SDL/SDL3/dialogs/sdl_select_list.cpp +++ b/client/SDL/SDL3/dialogs/sdl_select_list.cpp @@ -23,10 +23,10 @@ SdlSelectList::SdlSelectList(const std::string& title, const std::vector buttonids = { INPUT_BUTTON_ACCEPT, INPUT_BUTTON_CANCEL }; const std::vector buttonlabels = { "accept", "cancel" }; - _buttons.populate(_renderer, buttonlabels, buttonids, widget_width, - static_cast(total_height), static_cast(widget_width / 2), - static_cast(widget_height)); - _buttons.set_highlight(0); + (void)_buttons.populate( + _renderer, buttonlabels, buttonids, widget_width, static_cast(total_height), + static_cast(widget_width / 2), static_cast(widget_height)); + (void)_buttons.set_highlight(0); } } @@ -111,7 +111,8 @@ int SdlSelectList::run() throw; } - _buttons.set_mouseover(event.button.x, event.button.y); + if (!_buttons.set_mouseover(event.button.x, event.button.y)) + throw; } break; case SDL_EVENT_MOUSE_BUTTON_DOWN: @@ -147,7 +148,8 @@ int SdlSelectList::run() throw; } - update(); + if (!update()) + throw; } } catch (...) @@ -186,7 +188,7 @@ void SdlSelectList::reset_mouseover() { for (auto& cur : _list) { - cur.mouseover(false); + (void)cur.mouseover(false); } } @@ -194,6 +196,6 @@ void SdlSelectList::reset_highlight() { for (auto& cur : _list) { - cur.highlight(false); + (void)cur.highlight(false); } } diff --git a/client/SDL/SDL3/dialogs/sdl_select_list.hpp b/client/SDL/SDL3/dialogs/sdl_select_list.hpp index d611fd029..53d406ff8 100644 --- a/client/SDL/SDL3/dialogs/sdl_select_list.hpp +++ b/client/SDL/SDL3/dialogs/sdl_select_list.hpp @@ -21,10 +21,10 @@ class SdlSelectList : public SdlWidgetList SdlSelectList& operator=(const SdlSelectList& other) = delete; SdlSelectList& operator=(SdlSelectList&& other) = delete; - int run(); + [[nodiscard]] int run(); protected: - bool updateInternal() override; + [[nodiscard]] bool updateInternal() override; private: enum diff --git a/client/SDL/SDL3/dialogs/sdl_selectable_widget.hpp b/client/SDL/SDL3/dialogs/sdl_selectable_widget.hpp index 53e6ed8a8..06e2c8e63 100644 --- a/client/SDL/SDL3/dialogs/sdl_selectable_widget.hpp +++ b/client/SDL/SDL3/dialogs/sdl_selectable_widget.hpp @@ -36,11 +36,11 @@ class SdlSelectableWidget : public SdlWidget SdlSelectableWidget& operator=(const SdlSelectableWidget& other) = delete; SdlSelectableWidget& operator=(SdlSelectableWidget&& other) = delete; - bool highlight(bool enable); - bool mouseover(bool enable); + [[nodiscard]] bool highlight(bool enable); + [[nodiscard]] bool mouseover(bool enable); protected: - bool updateInternal() override; + [[nodiscard]] bool updateInternal() override; SDL_Color _highlightcolor = { 0xcd, 0xca, 0x35, 0x60 }; SDL_Color _mouseovercolor = { 0x66, 0xff, 0x66, 0x60 }; diff --git a/client/SDL/SDL3/dialogs/sdl_widget.cpp b/client/SDL/SDL3/dialogs/sdl_widget.cpp index 494427868..50630d4d5 100644 --- a/client/SDL/SDL3/dialogs/sdl_widget.cpp +++ b/client/SDL/SDL3/dialogs/sdl_widget.cpp @@ -51,12 +51,12 @@ SdlWidget::SdlWidget(std::shared_ptr& renderer, const SDL_FRect& r auto ops = SDL3ResourceManager::get(SDLResourceManager::typeFonts(), "OpenSans-VariableFont_wdth,wght.ttf"); if (!ops) - widget_log_error(false, "SDLResourceManager::get"); + (void)widget_log_error(false, "SDLResourceManager::get"); else { _font = std::shared_ptr(TTF_OpenFontIO(ops, true, 64), TTF_CloseFont); if (!_font) - widget_log_error(false, "TTF_OpenFontRW"); + (void)widget_log_error(false, "TTF_OpenFontRW"); } } @@ -72,7 +72,7 @@ SdlWidget::SdlWidget(std::shared_ptr& renderer, const SDL_FRect& r _image = std::shared_ptr(IMG_LoadTexture_IO(renderer.get(), ops, 1), SDL_DestroyTexture); if (!_image) - widget_log_error(false, "IMG_LoadTexture_IO"); + (void)widget_log_error(false, "IMG_LoadTexture_IO"); } } #endif @@ -95,7 +95,7 @@ std::shared_ptr SdlWidget::render_text(const std::string& text, SDL TTF_RenderText_Blended(_font.get(), text.c_str(), 0, fgcolor), SDL_DestroySurface); if (!surface) { - widget_log_error(false, "TTF_RenderText_Blended"); + (void)widget_log_error(false, "TTF_RenderText_Blended"); return nullptr; } @@ -103,13 +103,13 @@ std::shared_ptr SdlWidget::render_text(const std::string& text, SDL SDL_CreateTextureFromSurface(_renderer.get(), surface.get()), SDL_DestroyTexture); if (!texture) { - widget_log_error(false, "SDL_CreateTextureFromSurface"); + (void)widget_log_error(false, "SDL_CreateTextureFromSurface"); return nullptr; } if (!_engine) { - widget_log_error(false, "TTF_CreateRendererTextEngine"); + (void)widget_log_error(false, "TTF_CreateRendererTextEngine"); return nullptr; } @@ -118,14 +118,14 @@ std::shared_ptr SdlWidget::render_text(const std::string& text, SDL if (!txt) { - widget_log_error(false, "TTF_CreateText"); + (void)widget_log_error(false, "TTF_CreateText"); return nullptr; } int w = 0; int h = 0; if (!TTF_GetTextSize(txt.get(), &w, &h)) { - widget_log_error(false, "TTF_GetTextSize"); + (void)widget_log_error(false, "TTF_GetTextSize"); return nullptr; } @@ -170,7 +170,7 @@ std::shared_ptr SdlWidget::render_text_wrapped(const std::string& t SDL_DestroySurface); if (!surface) { - widget_log_error(false, "TTF_RenderText_Blended"); + (void)widget_log_error(false, "TTF_RenderText_Blended"); return nullptr; } @@ -181,7 +181,7 @@ std::shared_ptr SdlWidget::render_text_wrapped(const std::string& t SDL_CreateTextureFromSurface(_renderer.get(), surface.get()), SDL_DestroyTexture); if (!texture) { - widget_log_error(false, "SDL_CreateTextureFromSurface"); + (void)widget_log_error(false, "SDL_CreateTextureFromSurface"); return nullptr; } @@ -313,7 +313,10 @@ bool SdlWidget::update_text(const std::string& text) auto w = SDL_GetNumberProperty(propId, SDL_PROP_TEXTURE_WIDTH_NUMBER, -1); auto h = SDL_GetNumberProperty(propId, SDL_PROP_TEXTURE_HEIGHT_NUMBER, -1); if (w < 0 || h < 0) - widget_log_error(false, "SDL_GetTextureProperties"); + { + if (!widget_log_error(false, "SDL_GetTextureProperties")) + return false; + } src.w = static_cast(w); src.h = static_cast(h); } diff --git a/client/SDL/SDL3/dialogs/sdl_widget.hpp b/client/SDL/SDL3/dialogs/sdl_widget.hpp index 38305d44f..7f3f44759 100644 --- a/client/SDL/SDL3/dialogs/sdl_widget.hpp +++ b/client/SDL/SDL3/dialogs/sdl_widget.hpp @@ -59,19 +59,19 @@ class SdlWidget SdlWidget& operator=(const SdlWidget& other) = delete; SdlWidget& operator=(SdlWidget&& other) = delete; - bool fill(SDL_Color color) const; - bool fill(const std::vector& colors) const; - bool update_text(const std::string& text); + [[nodiscard]] bool fill(SDL_Color color) const; + [[nodiscard]] bool fill(const std::vector& colors) const; + [[nodiscard]] bool update_text(const std::string& text); [[nodiscard]] bool wrap() const; - bool set_wrap(bool wrap = true, size_t width = 0); + [[nodiscard]] bool set_wrap(bool wrap = true, size_t width = 0); [[nodiscard]] const SDL_FRect& rect() const; - bool update(); + [[nodiscard]] bool update(); #define widget_log_error(res, what) SdlWidget::error_ex(res, what, __FILE__, __LINE__, __func__) - static bool error_ex(bool success, const char* what, const char* file, size_t line, - const char* fkt); + [[nodiscard]] static bool error_ex(bool success, const char* what, const char* file, + size_t line, const char* fkt); protected: std::shared_ptr _renderer; @@ -83,11 +83,13 @@ class SdlWidget virtual bool updateInternal(); private: - bool draw_rect(const SDL_FRect& rect, SDL_Color color) const; - std::shared_ptr render_text(const std::string& text, SDL_Color fgcolor, - SDL_FRect& src, SDL_FRect& dst) const; - std::shared_ptr render_text_wrapped(const std::string& text, SDL_Color fgcolor, - SDL_FRect& src, SDL_FRect& dst) const; + [[nodiscard]] bool draw_rect(const SDL_FRect& rect, SDL_Color color) const; + [[nodiscard]] std::shared_ptr + render_text(const std::string& text, SDL_Color fgcolor, SDL_FRect& src, SDL_FRect& dst) const; + [[nodiscard]] std::shared_ptr render_text_wrapped(const std::string& text, + SDL_Color fgcolor, + SDL_FRect& src, + SDL_FRect& dst) const; std::shared_ptr _font = nullptr; std::shared_ptr _image = nullptr; diff --git a/client/SDL/SDL3/dialogs/sdl_widget_list.cpp b/client/SDL/SDL3/dialogs/sdl_widget_list.cpp index 15fd15fd2..ff2a8ce65 100644 --- a/client/SDL/SDL3/dialogs/sdl_widget_list.cpp +++ b/client/SDL/SDL3/dialogs/sdl_widget_list.cpp @@ -14,7 +14,7 @@ bool SdlWidgetList::reset(const std::string& title, size_t width, size_t height) _renderer = std::shared_ptr(renderer, SDL_DestroyRenderer); _window = std::shared_ptr(window, SDL_DestroyWindow); if (!rc) - widget_log_error(rc, "SDL_CreateWindowAndRenderer"); + (void)widget_log_error(rc, "SDL_CreateWindowAndRenderer"); return rc; } @@ -47,8 +47,10 @@ bool SdlWidgetList::update() if (!visible()) return true; - clearWindow(); - updateInternal(); + if (!clearWindow()) + return false; + if (!updateInternal()) + return false; if (!_buttons.update()) return false; auto rc = SDL_RenderPresent(_renderer.get()); diff --git a/client/SDL/SDL3/dialogs/sdl_widget_list.hpp b/client/SDL/SDL3/dialogs/sdl_widget_list.hpp index 768f331c7..ab3a582f6 100644 --- a/client/SDL/SDL3/dialogs/sdl_widget_list.hpp +++ b/client/SDL/SDL3/dialogs/sdl_widget_list.hpp @@ -18,14 +18,14 @@ class SdlWidgetList SdlWidgetList& operator=(SdlWidgetList&& other) = delete; virtual ~SdlWidgetList(); - virtual bool reset(const std::string& title, size_t width, size_t height); + [[nodiscard]] virtual bool reset(const std::string& title, size_t width, size_t height); [[nodiscard]] virtual bool visible() const; protected: - bool update(); - virtual bool clearWindow(); - virtual bool updateInternal() = 0; + [[nodiscard]] bool update(); + [[nodiscard]] virtual bool clearWindow(); + [[nodiscard]] virtual bool updateInternal() = 0; std::shared_ptr _window; std::shared_ptr _renderer; diff --git a/client/SDL/SDL3/sdl_clip.cpp b/client/SDL/SDL3/sdl_clip.cpp index d7eb1aab5..b3768ccc5 100644 --- a/client/SDL/SDL3/sdl_clip.cpp +++ b/client/SDL/SDL3/sdl_clip.cpp @@ -37,7 +37,7 @@ // NOLINTNEXTLINE(bugprone-suspicious-missing-comma) const char mime_text_utf8[] = mime_text_plain ";charset=utf-8"; -static const std::vector& s_mime_text() +[[nodiscard]] static const std::vector& s_mime_text() { static std::vector values; if (values.empty()) @@ -58,7 +58,7 @@ static const char s_mime_html[] = "text/html"; #define BMP_MIME_LIST "image/bmp", "image/x-bmp", "image/x-MS-bmp", "image/x-win-bitmap" -static const std::vector& s_mime_bitmap() +[[nodiscard]] static const std::vector& s_mime_bitmap() { static std::vector values; if (values.empty()) @@ -68,7 +68,7 @@ static const std::vector& s_mime_bitmap() return values; } -static const std::vector& s_mime_image() +[[nodiscard]] static const std::vector& s_mime_image() { static std::vector values; if (values.empty()) @@ -144,7 +144,7 @@ sdlClip::~sdlClip() { cliprdr_file_context_free(_file); ClipboardDestroy(_system); - (void)CloseHandle(_event); + std::ignore = CloseHandle(_event); } bool sdlClip::init(CliprdrClientContext* clip) @@ -876,7 +876,7 @@ const void* sdlClip::ClipDataCb(void* userdata, const char* mime_type, size_t* s clip->_request_queue.pop(); if (clip->_request_queue.empty()) - (void)ResetEvent(clip->_event); + std::ignore = ResetEvent(clip->_event); if (request.success()) { diff --git a/client/SDL/SDL3/sdl_disp.hpp b/client/SDL/SDL3/sdl_disp.hpp index b62b1b8e9..b48f10e79 100644 --- a/client/SDL/SDL3/sdl_disp.hpp +++ b/client/SDL/SDL3/sdl_disp.hpp @@ -57,8 +57,8 @@ class sdlDispContext [[nodiscard]] bool addTimer(); - bool updateMonitor(SDL_WindowID id); - bool updateMonitors(SDL_EventType type, SDL_DisplayID displayID); + [[nodiscard]] bool updateMonitor(SDL_WindowID id); + [[nodiscard]] bool updateMonitors(SDL_EventType type, SDL_DisplayID displayID); [[nodiscard]] static UINT DisplayControlCaps(DispClientContext* disp, UINT32 maxNumMonitors, UINT32 maxMonitorAreaFactorA, diff --git a/client/SDL/SDL3/sdl_freerdp.cpp b/client/SDL/SDL3/sdl_freerdp.cpp index 281fce4c9..8b6e015ef 100644 --- a/client/SDL/SDL3/sdl_freerdp.cpp +++ b/client/SDL/SDL3/sdl_freerdp.cpp @@ -207,7 +207,8 @@ static int sdl_run(SdlContext* sdl) SDLConnectionDialogHider hider(sdl); auto title = static_cast(windowEvent.user.data1); auto msg = static_cast(windowEvent.user.data2); - sdl_cert_dialog_show(title, msg); + if (!sdl_cert_dialog_show(title, msg)) + return -1; } break; case SDL_EVENT_USER_SHOW_DIALOG: @@ -215,7 +216,8 @@ static int sdl_run(SdlContext* sdl) SDLConnectionDialogHider hider(sdl); auto title = static_cast(windowEvent.user.data1); auto msg = static_cast(windowEvent.user.data2); - sdl_message_dialog_show(title, msg, windowEvent.user.code); + if (!sdl_message_dialog_show(title, msg, windowEvent.user.code)) + return -1; } break; case SDL_EVENT_USER_SCARD_DIALOG: @@ -223,14 +225,16 @@ static int sdl_run(SdlContext* sdl) SDLConnectionDialogHider hider(sdl); auto title = static_cast(windowEvent.user.data1); auto msg = static_cast(windowEvent.user.data2); - sdl_scard_dialog_show(title, windowEvent.user.code, msg); + if (!sdl_scard_dialog_show(title, windowEvent.user.code, msg)) + return -1; } break; case SDL_EVENT_USER_AUTH_DIALOG: { SDLConnectionDialogHider hider(sdl); - sdl_auth_dialog_show( - reinterpret_cast(windowEvent.padding)); + if (!sdl_auth_dialog_show( + reinterpret_cast(windowEvent.padding))) + return -1; } break; case SDL_EVENT_USER_UPDATE: diff --git a/client/SDL/SDL3/sdl_kbd.cpp b/client/SDL/SDL3/sdl_kbd.cpp index c5c7bdfba..a0c171d1b 100644 --- a/client/SDL/SDL3/sdl_kbd.cpp +++ b/client/SDL/SDL3/sdl_kbd.cpp @@ -283,7 +283,7 @@ static const scancode_entry_t map[] = { ENTRY(SDL_SCANCODE_MEDIA_FAST_FORWARD, RDP_SCANCODE_UNKNOWN) }; -static UINT32 sdl_get_kbd_flags() +[[nodiscard]] static UINT32 sdl_get_kbd_flags() { UINT32 flags = 0; @@ -374,7 +374,7 @@ BOOL sdlInput::keyboard_set_ime_status(rdpContext* context, UINT16 imeId, UINT32 return TRUE; } -static const std::map& getSdlMap() +[[nodiscard]] static const std::map& getSdlMap() { static std::map s_map = { { "KMOD_LSHIFT", SDL_KMOD_LSHIFT }, { "KMOD_RSHIFT", SDL_KMOD_RSHIFT }, @@ -399,7 +399,7 @@ static const std::map& getSdlMap() return s_map; } -static std::string modbyvalue(uint32_t val) +[[nodiscard]] static std::string modbyvalue(uint32_t val) { for (const auto& v : getSdlMap()) { @@ -411,7 +411,7 @@ static std::string modbyvalue(uint32_t val) return "KMOD_UNKNONW"; } -static std::string masktostr(uint32_t mask) +[[nodiscard]] static std::string masktostr(uint32_t mask) { if (mask == 0) return ""; @@ -470,7 +470,7 @@ uint32_t sdlInput::prefToMask() return mod; } -static const char* sdl_scancode_name(Uint32 scancode) +[[nodiscard]] static const char* sdl_scancode_name(Uint32 scancode) { for (const auto& cur : map) { @@ -481,7 +481,7 @@ static const char* sdl_scancode_name(Uint32 scancode) return "SDL_SCANCODE_UNKNOWN"; } -static Uint32 sdl_scancode_val(const char* scancodeName) +[[nodiscard]] static Uint32 sdl_scancode_val(const char* scancodeName) { for (const auto& cur : map) { @@ -493,7 +493,7 @@ static Uint32 sdl_scancode_val(const char* scancodeName) } #if defined(WITH_DEBUG_SDL_KBD_EVENTS) -static const char* sdl_rdp_scancode_name(UINT32 scancode) +[[nodiscard]] static const char* sdl_rdp_scancode_name(UINT32 scancode) { for (const auto& cur : map) { @@ -504,7 +504,7 @@ static const char* sdl_rdp_scancode_name(UINT32 scancode) return "RDP_SCANCODE_UNKNOWN"; } -static UINT32 sdl_rdp_scancode_val(const char* scancodeName) +[[nodiscard]] static UINT32 sdl_rdp_scancode_val(const char* scancodeName) { for (const auto& cur : map) { diff --git a/client/SDL/SDL3/sdl_monitor.cpp b/client/SDL/SDL3/sdl_monitor.cpp index 2f8840692..9b8b78031 100644 --- a/client/SDL/SDL3/sdl_monitor.cpp +++ b/client/SDL/SDL3/sdl_monitor.cpp @@ -81,7 +81,8 @@ int sdl_list_monitors([[maybe_unused]] SdlContext* sdl) return 0; } -static BOOL sdl_apply_mon_max_size(SdlContext* sdl, UINT32* pMaxWidth, UINT32* pMaxHeight) +[[nodiscard]] static BOOL sdl_apply_mon_max_size(SdlContext* sdl, UINT32* pMaxWidth, + UINT32* pMaxHeight) { int32_t left = 0; int32_t right = 0; @@ -113,7 +114,7 @@ static BOOL sdl_apply_mon_max_size(SdlContext* sdl, UINT32* pMaxWidth, UINT32* p return TRUE; } -static BOOL sdl_apply_max_size(SdlContext* sdl, UINT32* pMaxWidth, UINT32* pMaxHeight) +[[nodiscard]] static BOOL sdl_apply_max_size(SdlContext* sdl, UINT32* pMaxWidth, UINT32* pMaxHeight) { WINPR_ASSERT(sdl); WINPR_ASSERT(pMaxWidth); @@ -170,14 +171,15 @@ static BOOL sdl_apply_max_size(SdlContext* sdl, UINT32* pMaxWidth, UINT32* pMaxH return TRUE; } -static Uint32 scale(Uint32 val, float scale) +[[nodiscard]] static Uint32 scale(Uint32 val, float scale) { const auto dval = static_cast(val); const auto sval = dval / scale; return static_cast(sval); } -static BOOL sdl_apply_monitor_properties(rdpMonitor& monitor, SDL_DisplayID id, bool isPrimary) +[[nodiscard]] static BOOL sdl_apply_monitor_properties(rdpMonitor& monitor, SDL_DisplayID id, + bool isPrimary) { float dpi = SDL_GetDisplayContentScale(id); @@ -248,7 +250,7 @@ static BOOL sdl_apply_monitor_properties(rdpMonitor& monitor, SDL_DisplayID id, return TRUE; } -static BOOL sdl_apply_display_properties(SdlContext* sdl) +[[nodiscard]] static BOOL sdl_apply_display_properties(SdlContext* sdl) { WINPR_ASSERT(sdl); @@ -285,7 +287,8 @@ static BOOL sdl_apply_display_properties(SdlContext* sdl) monitors.size()); } -static BOOL sdl_detect_single_window(SdlContext* sdl, UINT32* pMaxWidth, UINT32* pMaxHeight) +[[nodiscard]] static BOOL sdl_detect_single_window(SdlContext* sdl, UINT32* pMaxWidth, + UINT32* pMaxHeight) { WINPR_ASSERT(sdl); WINPR_ASSERT(pMaxWidth); diff --git a/client/SDL/SDL3/sdl_pointer.cpp b/client/SDL/SDL3/sdl_pointer.cpp index 3fdd73d61..c8793bd13 100644 --- a/client/SDL/SDL3/sdl_pointer.cpp +++ b/client/SDL/SDL3/sdl_pointer.cpp @@ -37,7 +37,7 @@ typedef struct void* data; } sdlPointer; -static BOOL sdl_Pointer_New(rdpContext* context, rdpPointer* pointer) +[[nodiscard]] static BOOL sdl_Pointer_New(rdpContext* context, rdpPointer* pointer) { auto ptr = reinterpret_cast(pointer); @@ -90,14 +90,14 @@ static void sdl_Pointer_Free(rdpContext* context, rdpPointer* pointer) } } -static BOOL sdl_Pointer_SetDefault(rdpContext* context) +[[nodiscard]] static BOOL sdl_Pointer_SetDefault(rdpContext* context) { WINPR_UNUSED(context); return sdl_push_user_event(SDL_EVENT_USER_POINTER_DEFAULT); } -static BOOL sdl_Pointer_Set(rdpContext* context, rdpPointer* pointer) +[[nodiscard]] static BOOL sdl_Pointer_Set(rdpContext* context, rdpPointer* pointer) { WINPR_UNUSED(context); return sdl_push_user_event(SDL_EVENT_USER_POINTER_SET, pointer); @@ -178,14 +178,14 @@ BOOL sdl_Pointer_Set_Process(SdlContext* sdl) return TRUE; } -static BOOL sdl_Pointer_SetNull(rdpContext* context) +[[nodiscard]] static BOOL sdl_Pointer_SetNull(rdpContext* context) { WINPR_UNUSED(context); return sdl_push_user_event(SDL_EVENT_USER_POINTER_NULL); } -static BOOL sdl_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y) +[[nodiscard]] static BOOL sdl_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y) { WINPR_UNUSED(context); WINPR_ASSERT(context); diff --git a/client/SDL/SDL3/sdl_utils.hpp b/client/SDL/SDL3/sdl_utils.hpp index bd13dd6e2..be00920f6 100644 --- a/client/SDL/SDL3/sdl_utils.hpp +++ b/client/SDL/SDL3/sdl_utils.hpp @@ -96,7 +96,7 @@ namespace sdl::utils SCALE_MODE_WAYLAND }; - HighDpiScaleMode platformScaleMode(); + [[nodiscard]] HighDpiScaleMode platformScaleMode(); [[nodiscard]] std::string windowTitle(const rdpSettings* settings); diff --git a/client/SDL/common/aad/sdl_webview.hpp b/client/SDL/common/aad/sdl_webview.hpp index 8ece62d25..80a7e8221 100644 --- a/client/SDL/common/aad/sdl_webview.hpp +++ b/client/SDL/common/aad/sdl_webview.hpp @@ -26,8 +26,8 @@ extern "C" { #endif - BOOL sdl_webview_get_access_token(freerdp* instance, AccessTokenType tokenType, char** token, - size_t count, ...); + [[nodiscard]] BOOL sdl_webview_get_access_token(freerdp* instance, AccessTokenType tokenType, + char** token, size_t count, ...); #ifdef __cplusplus } diff --git a/client/SDL/common/aad/webview_impl.hpp b/client/SDL/common/aad/webview_impl.hpp index 25bca3c0a..9e48de21c 100644 --- a/client/SDL/common/aad/webview_impl.hpp +++ b/client/SDL/common/aad/webview_impl.hpp @@ -21,4 +21,5 @@ #include -bool webview_impl_run(const std::string& title, const std::string& url, std::string& code); +[[nodiscard]] bool webview_impl_run(const std::string& title, const std::string& url, + std::string& code); diff --git a/client/SDL/common/res/sdl_resource_manager.hpp b/client/SDL/common/res/sdl_resource_manager.hpp index 54cca16bf..a85b68bbc 100644 --- a/client/SDL/common/res/sdl_resource_manager.hpp +++ b/client/SDL/common/res/sdl_resource_manager.hpp @@ -33,20 +33,21 @@ class SDLResourceManager SDLResourceManager operator=(const SDLResourceManager& other) = delete; SDLResourceManager& operator=(SDLResourceManager&& other) = delete; - static std::string typeFonts(); - static std::string typeImages(); + [[nodiscard]] static std::string typeFonts(); + [[nodiscard]] static std::string typeImages(); protected: static void insert(const std::string& type, const std::string& id, const std::vector& data); - static const std::vector* data(const std::string& type, const std::string& id); - static std::string filename(const std::string& type, const std::string& id); + [[nodiscard]] static const std::vector* data(const std::string& type, + const std::string& id); + [[nodiscard]] static std::string filename(const std::string& type, const std::string& id); - static bool useCompiledResources(); + [[nodiscard]] static bool useCompiledResources(); private: - static std::map>& resources(); + [[nodiscard]] static std::map>& resources(); #if defined(SDL_USE_COMPILED_RESOURCES) static void init(); // implemented in generated file #endif diff --git a/client/SDL/common/sdl_prefs.hpp b/client/SDL/common/sdl_prefs.hpp index 63ea0bdd6..aba0b4294 100644 --- a/client/SDL/common/sdl_prefs.hpp +++ b/client/SDL/common/sdl_prefs.hpp @@ -27,7 +27,7 @@ class SdlPref { public: - static std::shared_ptr + [[nodiscard]] static std::shared_ptr instance(const std::string& name = SdlPref::get_default_file(false)); [[nodiscard]] std::string get_pref_file(bool systemConfigOnly = false) const; @@ -63,6 +63,7 @@ class SdlPref [[nodiscard]] bool is_user_config_enabled() const; - static std::string get_default_file(bool systemConfigOnly); - static std::string item_to_str(WINPR_JSON* item, const std::string& fallback = ""); + [[nodiscard]] static std::string get_default_file(bool systemConfigOnly); + [[nodiscard]] static std::string item_to_str(WINPR_JSON* item, + const std::string& fallback = ""); };