Fix various compiler warnings
MODIFY
.github/workflows/linux-release.yml
.github/workflows/linux-release.yml
@@ -18,7 +18,7 @@ jobs:
sudo apt-get upgrade -y
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y -q --force-yes \
automake cmake git wget libfuse2 desktop-file-utils tree \
- build-essential libgl1-mesa-dev libxkbcommon-x11-0 libpulse-dev
+ build-essential libgl1-mesa-dev libxkbcommon-x11-0 libpulse-dev \
libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 \
libxcb-xinerama0 libxcb-composite0 libxcb-cursor0 libxcb-damage0 \
libxcb-dpms0 libxcb-dri2-0 libxcb-dri3-0 libxcb-ewmh2 libxcb-glx0 \

MODIFY
CMakeLists.txt
CMakeLists.txt
@@ -51,7 +51,7 @@ qt5_add_resources(FONTS_SRC ${CMAKE_SOURCE_DIR}/resources/fonts/fonts.qrc)
######################################################################
# Header-only libraries used in the project must be included from top CMakeLists.txt file
-include_directories(${RIPES_LIB} PUBLIC external/VSRTL/external/cereal/include)
+include_directories(${RIPES_LIB} SYSTEM PUBLIC external/VSRTL/external/cereal/include)
include_directories(${RIPES_LIB} PUBLIC external/VSRTL/external)
include_directories(SYSTEM external/ELFIO)
include_directories(SYSTEM external/Signals)

MODIFY
src/io/ioledmatrix.cpp
src/io/ioledmatrix.cpp
@@ -43,7 +43,7 @@ uint32_t IOLedMatrix::ioRead(uint32_t offset, unsigned size) {
return (m_ledRegs.at(offset / 4) >> (offset % 4)) & generateBitmask(size * 8);
}
-void IOLedMatrix::ioWrite(uint32_t offset, uint32_t value, unsigned size) {
+void IOLedMatrix::ioWrite(uint32_t offset, uint32_t value, unsigned) {
offset >>= 2; // word addressable
if (offset >= m_ledRegs.size()) {
Q_ASSERT(false);
@@ -91,7 +91,7 @@ QSize IOLedMatrix::minimumSizeHint() const {
return QSize(pixelWidth, pixelHeight);
}
-void IOLedMatrix::paintEvent(QPaintEvent* event) {
+void IOLedMatrix::paintEvent(QPaintEvent*) {
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);

MODIFY
src/io/iomanager.cpp
src/io/iomanager.cpp
@@ -60,7 +60,7 @@ void IOManager::assignBaseAddresses() {
refreshMemoryMap();
}
-void IOManager::peripheralSizeChanged(IOBase* peripheral) {
+void IOManager::peripheralSizeChanged(IOBase*) {
assignBaseAddresses();
refreshMemoryMap();
}

MODIFY
src/io/ioswitches.cpp
src/io/ioswitches.cpp
@@ -81,7 +81,6 @@ void ToggleButton::paintEvent(QPaintEvent*) {
p.setPen(Qt::NoPen);
bool check = isChecked();
qreal trackOpacity = mOpacity;
- qreal textOpacity = 1.0;
qreal thumbOpacity = 1.0;
QBrush trackBrush;
QBrush thumbBrush;
@@ -137,8 +136,6 @@ void ToggleButton::enterEvent(QEvent* event) {
*/
IOSwitches::IOSwitches(QWidget* parent) : IOBase(IOType::SWITCHES, parent) {
- constexpr unsigned defaultWidth = 25;
-
// Parameters
m_parameters[SWITCHES] = IOParam(SWITCHES, "# Switches", 8, true, 1, 32);
@@ -158,7 +155,7 @@ QString IOSwitches::description() const {
void IOSwitches::updateSwitches() {
const unsigned nSwitches = m_parameters.at(SWITCHES).value.toInt();
- for (int i = 0; i < nSwitches; i++) {
+ for (unsigned i = 0; i < nSwitches; i++) {
if (m_switches.count(i) == 0) {
auto* sw = new ToggleButton(10, 8, true, this);
auto* label = new QLabel(QString::number(i), this);
@@ -169,14 +166,14 @@ void IOSwitches::updateSwitches() {
}
// Remove extra switches if # of switches was reduced
- std::vector<int> idxToDelete;
+ std::vector<unsigned> idxToDelete;
for (const auto& it : m_switches) {
if (it.first >= nSwitches) {
idxToDelete.push_back(it.first);
}
}
- for (int idx : idxToDelete) {
+ for (unsigned idx : idxToDelete) {
auto it = m_switches.find(idx);
Q_ASSERT(it != m_switches.end());
it->second.first->deleteLater();

MODIFY
src/io/ioswitches.h
src/io/ioswitches.h
@@ -82,7 +82,7 @@ private:
void updateSwitches();
uint32_t regRead(uint32_t offset) const;
- std::map<int, std::pair<QLabel*, ToggleButton*>> m_switches;
+ std::map<unsigned, std::pair<QLabel*, ToggleButton*>> m_switches;
QGridLayout* m_switchLayout;
std::vector<RegDesc> m_regDescs;
};

MODIFY
src/io/registermapmodel.cpp
src/io/registermapmodel.cpp
@@ -86,6 +86,8 @@ QVariant RegisterMapModel::data(const QModelIndex& index, int role) const {
return "W";
case RegDesc::RW::RW:
return "R/W";
+ default:
+ Q_UNREACHABLE();
}
}
case Qt::TextAlignmentRole:

MODIFY
src/ioperipheraltab.cpp
src/ioperipheraltab.cpp
namespace Ripes {
IOPeripheralTab::IOPeripheralTab(QWidget* parent, IOBase* peripheral)
- : QWidget(parent), m_peripheral(peripheral), m_ui(new Ui::IOPeripheralTab) {
+ : QWidget(parent), m_ui(new Ui::IOPeripheralTab), m_peripheral(peripheral) {
m_ui->setupUi(this);
m_ui->description->setText(m_peripheral->description());

MODIFY
src/ioperipheraltab.h
src/ioperipheraltab.h
@@ -18,8 +18,7 @@ public:
private:
void updateExportsInfo();
- Ui::IOPeripheralTab* m_ui;
-
+ Ui::IOPeripheralTab* m_ui = nullptr;
IOBase* m_peripheral = nullptr;
};

MODIFY
src/iotab.cpp
src/iotab.cpp
#include "ioperipheraltab.h"
-#include "VSRTL/external/cereal/include/cereal/archives/json.hpp"
-#include "VSRTL/external/cereal/include/cereal/types/map.hpp"
-#include "VSRTL/external/cereal/include/cereal/types/vector.hpp"
+#include "cereal/archives/json.hpp"
+#include "cereal/types/map.hpp"
+#include "cereal/types/vector.hpp"
namespace Ripes {
@@ -140,7 +140,7 @@ void IOTab::loadPeripheralState() {
archive(cereal::make_nvp("periphIDs", ids));
for (const auto& id : ids) {
if (id.typeId < NPERIPHERALS) {
- auto* periph = createPeripheral(static_cast<IOType>(id.typeId), id.uniqueId);
+ createPeripheral(static_cast<IOType>(id.typeId), id.uniqueId);
}
}
@@ -148,7 +148,7 @@ void IOTab::loadPeripheralState() {
IOBase* periphPtr = dynamic_cast<IOBase*>(periph.first);
archive(cereal::make_nvp(periphPtr->serializedUniqueID(), *periphPtr));
}
- } catch (cereal::Exception e) {
+ } catch (const cereal::Exception& e) {
/// @todo: build an error report
}
} catch (...) {
@@ -176,7 +176,7 @@ void IOTab::storePeripheralState() {
IOBase* periphPtr = dynamic_cast<IOBase*>(periph.first);
archive(cereal::make_nvp(periphPtr->serializedUniqueID(), *periphPtr));
}
- } catch (cereal::Exception e) {
+ } catch (const cereal::Exception& e) {
/// @todo: build an error report
}
}

MODIFY
src/utilities/hexspinbox.h
src/utilities/hexspinbox.h
@@ -20,7 +20,7 @@ protected:
int v = sanitize(text).toUInt(nullptr, 16);
return v;
}
- QValidator::State validate(QString& input, int&) const {
+ QValidator::State validate(QString& input, int&) const override {
bool okay;
sanitize(input).toUInt(&okay, 16);
if (!okay)

Fix various compiler warnings