From a660861008adf479525c7283ab3fb86c6af7251f Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Tue, 17 Nov 2020 18:37:10 -0330 Subject: [PATCH] Fixed minor clang warnings, and implemented clang-tidy suggestions. --- src/debugger/gui/RomListWidget.cxx | 6 +++--- src/debugger/gui/ToggleWidget.cxx | 8 +------- src/debugger/gui/ToggleWidget.hxx | 16 ++++++++-------- src/gui/ToolTip.cxx | 7 +++++-- src/gui/ToolTip.hxx | 4 ++-- 5 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 72f3a0b03..504f7443d 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -465,14 +465,14 @@ string RomListWidget::getToolTip(Common::Point pos) const const string bytes = myDisasm->list[idx.y].bytes; - if(bytes.length() < idx.x + 1) + if(bytes.length() < size_t(idx.x + 1)) return EmptyString; Int32 val; if(bytes.length() == 8 && bytes[2] != ' ') { // Binary value - val = stol(bytes, 0, 2); + val = static_cast(stol(bytes, 0, 2)); } else { @@ -484,7 +484,7 @@ string RomListWidget::getToolTip(Common::Point pos) const // Get one hex byte const string valStr = bytes.substr((idx.x / 3) * 3, 2); - val = stol(valStr, 0, 16); + val = static_cast(stol(valStr, 0, 16)); } ostringstream buf; diff --git a/src/debugger/gui/ToggleWidget.cxx b/src/debugger/gui/ToggleWidget.cxx index e20544783..2a4187c6d 100644 --- a/src/debugger/gui/ToggleWidget.cxx +++ b/src/debugger/gui/ToggleWidget.cxx @@ -28,13 +28,7 @@ ToggleWidget::ToggleWidget(GuiObject* boss, const GUI::Font& font, CommandSender(boss), _rows(rows), _cols(cols), - _currentRow(0), - _currentCol(0), - _rowHeight(0), - _colWidth(0), - _selectedItem(0), - _shiftBits(shiftBits), - _editable(true) + _shiftBits(shiftBits) { _flags = Widget::FLAG_ENABLED | Widget::FLAG_CLEARBG | Widget::FLAG_RETAIN_FOCUS | Widget::FLAG_WANTS_RAWDATA; diff --git a/src/debugger/gui/ToggleWidget.hxx b/src/debugger/gui/ToggleWidget.hxx index 5f4ec13a7..3f74237b0 100644 --- a/src/debugger/gui/ToggleWidget.hxx +++ b/src/debugger/gui/ToggleWidget.hxx @@ -53,14 +53,14 @@ class ToggleWidget : public Widget, public CommandSender bool hasToolTip() const override { return true; } protected: - int _rows; - int _cols; - int _currentRow; - int _currentCol; - int _rowHeight; // explicitly set in child classes - int _colWidth; // explicitly set in child classes - int _selectedItem; - bool _editable; + int _rows{0}; + int _cols{0}; + int _currentRow{0}; + int _currentCol{0}; + int _rowHeight{0}; // explicitly set in child classes + int _colWidth{0}; // explicitly set in child classes + int _selectedItem{0}; + bool _editable{true}; bool _swapBits{false}; int _shiftBits{0}; // shift bits for tooltip display diff --git a/src/gui/ToolTip.cxx b/src/gui/ToolTip.cxx index 85f5bedf4..77b5d5e20 100644 --- a/src/gui/ToolTip.cxx +++ b/src/gui/ToolTip.cxx @@ -62,7 +62,7 @@ void ToolTip::setFont(const GUI::Font& font) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void ToolTip::update(const Widget* widget, Common::Point pos) +void ToolTip::update(const Widget* widget, const Common::Point& pos) { if(myTipWidget != widget) { @@ -70,7 +70,10 @@ void ToolTip::update(const Widget* widget, Common::Point pos) release(); } if(myTipShown && myTipWidget->changedToolTip(myPos, pos)) - myPos = pos, show(); + { + myPos = pos; + show(); + } else myPos = pos; } diff --git a/src/gui/ToolTip.hxx b/src/gui/ToolTip.hxx index 879200c06..17ff2e7ec 100644 --- a/src/gui/ToolTip.hxx +++ b/src/gui/ToolTip.hxx @@ -59,9 +59,9 @@ class ToolTip void release(); /** - Update focussed widget and current mouse position. + Update focused widget and current mouse position. */ - void update(const Widget* widget, Common::Point pos); + void update(const Widget* widget, const Common::Point& pos); /* Render the tooltip