From dcdde8122dc7ce6da420cfcb870a6e0497109a33 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Tue, 27 Jan 2026 13:08:10 +0100 Subject: [PATCH] [client,sdl] adjust nodiscard use for dialogs --- client/SDL/SDL3/dialogs/sdl_button.cpp | 4 ++-- client/SDL/SDL3/dialogs/sdl_buttons.hpp | 6 +++--- .../SDL3/dialogs/sdl_connection_dialog.cpp | 10 +++++----- .../dialogs/sdl_connection_dialog_wrapper.cpp | 14 ++++++------- .../SDL3/dialogs/sdl_input_widget_pair.cpp | 4 ++-- .../SDL3/dialogs/sdl_input_widget_pair.hpp | 4 ++-- .../dialogs/sdl_input_widget_pair_list.cpp | 4 ++-- client/SDL/SDL3/dialogs/sdl_select.cpp | 2 +- client/SDL/SDL3/dialogs/sdl_select_list.cpp | 8 ++++---- .../SDL3/dialogs/sdl_selectable_widget.hpp | 4 ++-- client/SDL/SDL3/dialogs/sdl_widget.cpp | 20 +++++++++---------- client/SDL/SDL3/dialogs/sdl_widget.hpp | 4 ++-- client/SDL/SDL3/dialogs/sdl_widget_list.cpp | 2 +- .../SDL3/dialogs/test/TestSDLDialogInput.cpp | 11 ++-------- .../dialogs/test/TestSDLDialogSelectList.cpp | 11 ++-------- client/SDL/SDL3/sdl_touch.cpp | 10 ++++++---- 16 files changed, 53 insertions(+), 65 deletions(-) diff --git a/client/SDL/SDL3/dialogs/sdl_button.cpp b/client/SDL/SDL3/dialogs/sdl_button.cpp index ef625e1cd..da33c9452 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 }; - (void)update_text(label); - (void)update(); + std::ignore = update_text(label); + std::ignore = update(); } SdlButton::SdlButton(SdlButton&& other) noexcept = default; diff --git a/client/SDL/SDL3/dialogs/sdl_buttons.hpp b/client/SDL/SDL3/dialogs/sdl_buttons.hpp index 733380894..3d43c5492 100644 --- a/client/SDL/SDL3/dialogs/sdl_buttons.hpp +++ b/client/SDL/SDL3/dialogs/sdl_buttons.hpp @@ -25,9 +25,9 @@ class SdlButtonList [[nodiscard]] std::shared_ptr get_selected(const SDL_MouseButtonEvent& button); [[nodiscard]] std::shared_ptr get_selected(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); + bool set_highlight_next(bool reset = false); + bool set_highlight(size_t index); + 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 3286b24aa..ffc2edd91 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) { - (void)hide(); + std::ignore = hide(); } SDLConnectionDialog::~SDLConnectionDialog() @@ -207,7 +207,7 @@ bool SDLConnectionDialog::handle(const SDL_Event& event) if (event.type == SDL_EVENT_KEY_UP) { freerdp_abort_event(_context); - (void)sdl_push_quit(); + std::ignore = sdl_push_quit(); } break; case SDLK_TAB: @@ -246,7 +246,7 @@ bool SDLConnectionDialog::handle(const SDL_Event& event) if (event.type == SDL_EVENT_MOUSE_BUTTON_UP) { freerdp_abort_event(_context); - (void)sdl_push_quit(); + std::ignore = sdl_push_quit(); } } @@ -282,7 +282,7 @@ bool SDLConnectionDialog::handle(const SDL_Event& event) if (windowID == ev.windowID) { freerdp_abort_event(_context); - (void)sdl_push_quit(); + std::ignore = sdl_push_quit(); } break; default: @@ -473,7 +473,7 @@ Uint32 SDLConnectionDialog::timeout(void* pvthis, [[maybe_unused]] SDL_TimerID t [[maybe_unused]] Uint32 intervalMS) { auto self = static_cast(pvthis); - (void)self->hide(); + std::ignore = self->hide(); self->_running = false; return 0; } diff --git a/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.cpp b/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.cpp index 45e775c6a..b632833a6 100644 --- a/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.cpp +++ b/client/SDL/SDL3/dialogs/sdl_connection_dialog_wrapper.cpp @@ -88,7 +88,7 @@ static std::string format(WINPR_FORMAT_ARG const char* fmt, va_list ap) va_list ap2; va_copy(ap2, ap); - (void)vsnprintf(msg.data(), msg.size(), fmt, ap2); + std::ignore = vsnprintf(msg.data(), msg.size(), fmt, ap2); va_end(ap2); return msg; } @@ -166,7 +166,7 @@ void SdlConnectionDialogWrapper::handleShow() if (arg.hasTitle() && _connection_dialog) { - (void)_connection_dialog->setTitle(arg.title().c_str()); + std::ignore = _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) - (void)_connection_dialog->showInfo(arg.message().c_str()); + std::ignore = _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) - (void)_connection_dialog->showWarn(arg.message().c_str()); + std::ignore = _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) - (void)_connection_dialog->showError(arg.message().c_str()); + std::ignore = _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()) - (void)_connection_dialog->show(); + std::ignore = _connection_dialog->show(); else - (void)_connection_dialog->hide(); + std::ignore = _connection_dialog->hide(); } } } diff --git a/client/SDL/SDL3/dialogs/sdl_input_widget_pair.cpp b/client/SDL/SDL3/dialogs/sdl_input_widget_pair.cpp index 319f6eb88..887564ba6 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) }) { - (void)_label.update_text(label); - (void)update_input_text(initial); + std::ignore = _label.update_text(label); + std::ignore = 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 ebbcec0f5..2fedeb853 100644 --- a/client/SDL/SDL3/dialogs/sdl_input_widget_pair.hpp +++ b/client/SDL/SDL3/dialogs/sdl_input_widget_pair.hpp @@ -45,8 +45,8 @@ class SdlInputWidgetPair SdlInputWidgetPair& operator=(const SdlInputWidgetPair& other) = delete; SdlInputWidgetPair& operator=(SdlInputWidgetPair&& other) = delete; - [[nodiscard]] bool set_mouseover(bool mouseOver); - [[nodiscard]] bool set_highlight(bool highlight); + bool set_mouseover(bool mouseOver); + bool set_highlight(bool highlight); [[nodiscard]] bool set_str(const std::string& text); [[nodiscard]] bool remove_str(size_t count); 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 2bfb9c1c0..e07ea9657 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); } - (void)_buttons.populate( + std::ignore = _buttons.populate( _renderer, buttonlabels, buttonids, total_width, static_cast(input_height), static_cast(widget_width), static_cast(widget_heigth)); - (void)_buttons.set_highlight(0); + _buttons.set_highlight(0); m_currentActiveTextInput = selected; } } diff --git a/client/SDL/SDL3/dialogs/sdl_select.cpp b/client/SDL/SDL3/dialogs/sdl_select.cpp index ac2490664..c295a8555 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 }; - (void)update_text(label); + std::ignore = 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 751ae2d99..f52a10dcc 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" }; - (void)_buttons.populate( + std::ignore = _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); + _buttons.set_highlight(0); } } @@ -187,7 +187,7 @@ void SdlSelectList::reset_mouseover() { for (auto& cur : _list) { - (void)cur.mouseover(false); + cur.mouseover(false); } } @@ -195,6 +195,6 @@ void SdlSelectList::reset_highlight() { for (auto& cur : _list) { - (void)cur.highlight(false); + cur.highlight(false); } } diff --git a/client/SDL/SDL3/dialogs/sdl_selectable_widget.hpp b/client/SDL/SDL3/dialogs/sdl_selectable_widget.hpp index 06e2c8e63..f9706b4c9 100644 --- a/client/SDL/SDL3/dialogs/sdl_selectable_widget.hpp +++ b/client/SDL/SDL3/dialogs/sdl_selectable_widget.hpp @@ -36,8 +36,8 @@ class SdlSelectableWidget : public SdlWidget SdlSelectableWidget& operator=(const SdlSelectableWidget& other) = delete; SdlSelectableWidget& operator=(SdlSelectableWidget&& other) = delete; - [[nodiscard]] bool highlight(bool enable); - [[nodiscard]] bool mouseover(bool enable); + bool highlight(bool enable); + bool mouseover(bool enable); protected: [[nodiscard]] bool updateInternal() override; diff --git a/client/SDL/SDL3/dialogs/sdl_widget.cpp b/client/SDL/SDL3/dialogs/sdl_widget.cpp index d0cbaefc8..843f7a0f5 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) - (void)widget_log_error(false, "SDLResourceManager::get"); + widget_log_error(false, "SDLResourceManager::get"); else { _font = std::shared_ptr(TTF_OpenFontIO(ops, true, 64), TTF_CloseFont); if (!_font) - (void)widget_log_error(false, "TTF_OpenFontRW"); + 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, true), SDL_DestroyTexture); if (!_image) - (void)widget_log_error(false, "IMG_LoadTexture_IO"); + 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) { - (void)widget_log_error(false, "TTF_RenderText_Blended"); + 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) { - (void)widget_log_error(false, "SDL_CreateTextureFromSurface"); + widget_log_error(false, "SDL_CreateTextureFromSurface"); return nullptr; } if (!_engine) { - (void)widget_log_error(false, "TTF_CreateRendererTextEngine"); + 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) { - (void)widget_log_error(false, "TTF_CreateText"); + widget_log_error(false, "TTF_CreateText"); return nullptr; } int w = 0; int h = 0; if (!TTF_GetTextSize(txt.get(), &w, &h)) { - (void)widget_log_error(false, "TTF_GetTextSize"); + 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) { - (void)widget_log_error(false, "TTF_RenderText_Blended"); + 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) { - (void)widget_log_error(false, "SDL_CreateTextureFromSurface"); + widget_log_error(false, "SDL_CreateTextureFromSurface"); return nullptr; } diff --git a/client/SDL/SDL3/dialogs/sdl_widget.hpp b/client/SDL/SDL3/dialogs/sdl_widget.hpp index 7f3f44759..1e13326bb 100644 --- a/client/SDL/SDL3/dialogs/sdl_widget.hpp +++ b/client/SDL/SDL3/dialogs/sdl_widget.hpp @@ -70,8 +70,8 @@ class SdlWidget [[nodiscard]] bool update(); #define widget_log_error(res, what) SdlWidget::error_ex(res, what, __FILE__, __LINE__, __func__) - [[nodiscard]] static bool error_ex(bool success, const char* what, const char* file, - size_t line, const char* fkt); + static bool error_ex(bool success, const char* what, const char* file, size_t line, + const char* fkt); protected: std::shared_ptr _renderer; diff --git a/client/SDL/SDL3/dialogs/sdl_widget_list.cpp b/client/SDL/SDL3/dialogs/sdl_widget_list.cpp index ff2a8ce65..e7be4b602 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) - (void)widget_log_error(rc, "SDL_CreateWindowAndRenderer"); + widget_log_error(rc, "SDL_CreateWindowAndRenderer"); return rc; } diff --git a/client/SDL/SDL3/dialogs/test/TestSDLDialogInput.cpp b/client/SDL/SDL3/dialogs/test/TestSDLDialogInput.cpp index 98e01864c..28ad4a159 100644 --- a/client/SDL/SDL3/dialogs/test/TestSDLDialogInput.cpp +++ b/client/SDL/SDL3/dialogs/test/TestSDLDialogInput.cpp @@ -53,14 +53,7 @@ static int runTest(fkt_t fkt) return rc; } -int main(int argc, char* argv[]) +int main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) { - int rc = 0; - - (void)argc; - (void)argv; - - rc = runTest(auth_dialogs); - - return rc; + return runTest(auth_dialogs); } diff --git a/client/SDL/SDL3/dialogs/test/TestSDLDialogSelectList.cpp b/client/SDL/SDL3/dialogs/test/TestSDLDialogSelectList.cpp index 5f20611c1..206c2da2d 100644 --- a/client/SDL/SDL3/dialogs/test/TestSDLDialogSelectList.cpp +++ b/client/SDL/SDL3/dialogs/test/TestSDLDialogSelectList.cpp @@ -41,14 +41,7 @@ static int runTest(fkt_t fkt) return rc; } -int main(int argc, char* argv[]) +int main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) { - int rc = 0; - - (void)argc; - (void)argv; - - rc = runTest(select_dialogs); - - return rc; + return runTest(select_dialogs); } diff --git a/client/SDL/SDL3/sdl_touch.cpp b/client/SDL/SDL3/sdl_touch.cpp index 34fcaf388..28164269c 100644 --- a/client/SDL/SDL3/sdl_touch.cpp +++ b/client/SDL/SDL3/sdl_touch.cpp @@ -30,7 +30,7 @@ #include -static bool send_mouse_wheel(SdlContext* sdl, UINT16 flags, INT32 avalue) +[[nodiscard]] static bool send_mouse_wheel(SdlContext* sdl, UINT16 flags, INT32 avalue) { WINPR_ASSERT(sdl); if (avalue < 0) @@ -54,7 +54,7 @@ static bool send_mouse_wheel(SdlContext* sdl, UINT16 flags, INT32 avalue) return TRUE; } -static UINT32 sdl_scale_pressure(const float pressure) +[[nodiscard]] static UINT32 sdl_scale_pressure(const float pressure) { const float val = pressure * 0x400; /* [MS-RDPEI] 2.2.3.3.1.1 RDPINPUT_TOUCH_CONTACT */ if (val < 0.0f) @@ -130,13 +130,15 @@ bool SdlTouch::handleEvent(SdlContext* sdl, const SDL_MouseWheelEvent& ev) if (y != 0) { flags |= PTR_FLAGS_WHEEL; - send_mouse_wheel(sdl, flags, y); + if (!send_mouse_wheel(sdl, flags, y)) + return false; } if (x != 0) { flags |= PTR_FLAGS_HWHEEL; - send_mouse_wheel(sdl, flags, x); + if (!send_mouse_wheel(sdl, flags, x)) + return false; } return TRUE; }