Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: Enable warning -Woverloaded-virtual #3046

Merged
merged 5 commits into from
Aug 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/mixxx.cpp
src/mixxxapplication.cpp
src/musicbrainz/chromaprinter.cpp
src/musicbrainz/crc.c
src/musicbrainz/crc.cpp
src/musicbrainz/gzip.cpp
src/musicbrainz/musicbrainz.cpp
src/musicbrainz/musicbrainzxml.cpp
Expand Down Expand Up @@ -947,7 +947,7 @@ if(MSVC)
target_compile_options(mixxx-lib PUBLIC /W3)
endif()
else()
target_compile_options(mixxx-lib PUBLIC -Wall -Wextra)
target_compile_options(mixxx-lib PUBLIC -Wall -Wextra -Woverloaded-virtual)
if(WARNINGS_PEDANTIC)
target_compile_options(mixxx-lib PUBLIC -pedantic)
endif()
Expand Down
3 changes: 2 additions & 1 deletion build/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ def sources(self, build):

"src/musicbrainz/tagfetcher.cpp",
"src/musicbrainz/gzip.cpp",
"src/musicbrainz/crc.c",
"src/musicbrainz/crc.cpp",
"src/musicbrainz/chromaprinter.cpp",
"src/musicbrainz/musicbrainz.cpp",
"src/musicbrainz/musicbrainzxml.cpp",
Expand Down Expand Up @@ -1460,6 +1460,7 @@ def configure(self, build, conf):
build.env.Append(CCFLAGS='-pipe')
build.env.Append(CCFLAGS='-Wall')
build.env.Append(CCFLAGS='-Wextra')
build.env.Append(CCFLAGS='-Woverloaded-virtual')

if build.compiler_is_gcc and build.gcc_major_version >= 9:
# Avoid many warnings from GCC 9 about implicitly defined copy assignment
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/bulk/bulkcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ void BulkController::send(QList<int> data, unsigned int length) {
foreach (int datum, data) {
temp.append(datum);
}
send(temp);
sendBytes(temp);
}

void BulkController::send(QByteArray data) {
void BulkController::sendBytes(const QByteArray& data) {
int ret;
int transferred;

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/bulk/bulkcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class BulkController : public Controller {
private:
// For devices which only support a single report, reportID must be set to
// 0x0.
void send(QByteArray data) override;
void sendBytes(const QByteArray& data) override;

// Returns a pointer to the currently loaded controller preset. For internal
// use only.
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void Controller::send(QList<int> data, unsigned int length) {
for (unsigned int i = 0; i < length; ++i) {
msg[i] = data.at(i);
}
send(msg);
sendBytes(msg);
}

void Controller::triggerActivity()
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Controller : public QObject, ConstControllerPresetVisitor {

// This must be reimplemented by sub-classes desiring to send raw bytes to a
// controller.
virtual void send(QByteArray data) = 0;
virtual void sendBytes(const QByteArray& data) = 0;

// To be called in sub-class' open() functions after opening the device but
// before starting any input polling/processing.
Expand Down
10 changes: 5 additions & 5 deletions src/controllers/hid/hidcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,20 +264,20 @@ bool HidController::isPolling() const {
return isOpen();
}

void HidController::send(QList<int> data, unsigned int length, unsigned int reportID) {
void HidController::sendReport(QList<int> data, unsigned int length, unsigned int reportID) {
Q_UNUSED(length);
QByteArray temp;
foreach (int datum, data) {
temp.append(datum);
}
send(temp, reportID);
sendBytesReport(temp, reportID);
}

void HidController::send(QByteArray data) {
send(data, 0);
void HidController::sendBytes(const QByteArray& data) {
sendBytesReport(data, 0);
}

void HidController::send(QByteArray data, unsigned int reportID) {
void HidController::sendBytesReport(QByteArray data, unsigned int reportID) {
// Append the Report ID to the beginning of data[] per the API..
data.prepend(reportID);

Expand Down
11 changes: 5 additions & 6 deletions src/controllers/hid/hidcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class HidController final : public Controller {
static QString safeDecodeWideString(const wchar_t* pStr, size_t max_length);

protected:
using Controller::send;
void send(QList<int> data, unsigned int length, unsigned int reportID = 0);
void sendReport(QList<int> data, unsigned int length, unsigned int reportID);

private slots:
int open() override;
Expand All @@ -64,8 +63,8 @@ class HidController final : public Controller {
private:
// For devices which only support a single report, reportID must be set to
// 0x0.
void send(QByteArray data) override;
void virtual send(QByteArray data, unsigned int reportID);
void sendBytes(const QByteArray& data) override;
void sendBytesReport(QByteArray data, unsigned int reportID);

// Returns a pointer to the currently loaded controller preset. For internal
// use only.
Expand Down Expand Up @@ -106,11 +105,11 @@ class HidControllerJSProxy : public ControllerJSProxy {
}

Q_INVOKABLE void send(QList<int> data, unsigned int length = 0) override {
send(data, length, 0);
m_pHidController->send(data, length);
}

Q_INVOKABLE void send(QList<int> data, unsigned int length, unsigned int reportID) {
m_pHidController->send(data, length, reportID);
m_pHidController->sendReport(data, length, reportID);
}

private:
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/midi/hss1394controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void Hss1394Controller::sendShortMsg(unsigned char status, unsigned char byte1,
//}
}

void Hss1394Controller::send(QByteArray data) {
void Hss1394Controller::sendBytes(const QByteArray& data) {
int bytesSent = m_pChannel->SendChannelBytes(
(unsigned char*)data.constData(), data.size());

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/midi/hss1394controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Hss1394Controller : public MidiController {
private:
// The sysex data must already contain the start byte 0xf0 and the end byte
// 0xf7.
void send(QByteArray data) override;
void sendBytes(const QByteArray& data) override;

hss1394::TNodeInfo m_deviceInfo;
int m_iDeviceIndex;
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/midi/portmidicontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void PortMidiController::sendShortMsg(unsigned char status, unsigned char byte1,
}
}

void PortMidiController::send(QByteArray data) {
void PortMidiController::sendBytes(const QByteArray& data) {
// PortMidi does not receive a length argument for the buffer we provide to
// Pm_WriteSysEx. Instead, it scans for a MIDI_EOX byte to know when the
// message is over. If one is not provided, it will overflow the buffer and
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/midi/portmidicontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class PortMidiController : public MidiController {
private:
// The sysex data must already contain the start byte 0xf0 and the end byte
// 0xf7.
void send(QByteArray data) override;
void sendBytes(const QByteArray& data) override;

bool isPolling() const override {
return true;
Expand Down
130 changes: 0 additions & 130 deletions src/musicbrainz/crc.c

This file was deleted.

Loading