From 3396ec942997c5f7e303a1a2adad8e6c3698053b Mon Sep 17 00:00:00 2001 From: Lennart Date: Mon, 17 Jul 2017 18:55:45 +0200 Subject: [PATCH 1/4] fixed some warnings when compiling with -Wconversion and -Wsign-conversion --- src/MIDI.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/MIDI.hpp b/src/MIDI.hpp index 9951261..3ee7c8f 100644 --- a/src/MIDI.hpp +++ b/src/MIDI.hpp @@ -375,7 +375,7 @@ template void MidiInterface::sendTimeCodeQuarterFrame(DataByte inTypeNibble, DataByte inValuesNibble) { - const byte data = (((inTypeNibble & 0x07) << 4) | (inValuesNibble & 0x0f)); + const byte data = byte((((inTypeNibble & 0x07) << 4) | (inValuesNibble & 0x0f))); sendTimeCodeQuarterFrame(data); } @@ -620,7 +620,7 @@ template StatusByte MidiInterface::getStatus(MidiType inType, Channel inChannel) const { - return ((byte)inType | ((inChannel - 1) & 0x0f)); + return StatusByte(((byte)inType | ((inChannel - 1) & 0x0f))); } // ----------------------------------------------------------------------------- @@ -856,7 +856,7 @@ bool MidiInterface::parse() // Get length mMessage.data1 = mPendingMessageIndex & 0xff; // LSB - mMessage.data2 = mPendingMessageIndex >> 8; // MSB + mMessage.data2 = byte(mPendingMessageIndex >> 8); // MSB mMessage.channel = 0; mMessage.valid = true; @@ -1116,7 +1116,7 @@ MidiType MidiInterface::getTypeFromStatusByte(byte inStatu template inline Channel MidiInterface::getChannelFromStatusByte(byte inStatus) { - return (inStatus & 0x0f) + 1; + return Channel((inStatus & 0x0f) + 1); } template @@ -1221,7 +1221,7 @@ void MidiInterface::launchCallback() // Occasional messages case TimeCodeQuarterFrame: if (mTimeCodeQuarterFrameCallback != 0) mTimeCodeQuarterFrameCallback(mMessage.data1); break; - case SongPosition: if (mSongPositionCallback != 0) mSongPositionCallback((mMessage.data1 & 0x7f) | ((mMessage.data2 & 0x7f) << 7)); break; + case SongPosition: if (mSongPositionCallback != 0) mSongPositionCallback(unsigned((mMessage.data1 & 0x7f) | ((mMessage.data2 & 0x7f) << 7))); break; case SongSelect: if (mSongSelectCallback != 0) mSongSelectCallback(mMessage.data1); break; case TuneRequest: if (mTuneRequestCallback != 0) mTuneRequestCallback(); break; From c5833214a162d9ef24694dd81ffcbbdbfefcac61 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Sat, 10 Mar 2018 17:44:16 +0100 Subject: [PATCH 2/4] feat: Increase warning level for sources Don't do it globally as externals may have warnings we can't do much about. --- builder/CMakeLists.txt | 17 ++++++++++++++++- src/CMakeLists.txt | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/builder/CMakeLists.txt b/builder/CMakeLists.txt index 036c701..5f367f2 100644 --- a/builder/CMakeLists.txt +++ b/builder/CMakeLists.txt @@ -8,7 +8,18 @@ macro(setup_builder) include_directories(${ROOT_SOURCE_DIR}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -W -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wno-deprecated -Woverloaded-virtual") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ + -Wall \ + -W \ + -Wshadow \ + -Wunused-variable \ + -Wunused-parameter \ + -Wunused-function \ + -Wunused \ + -Wno-system-headers \ + -Wno-deprecated \ + -Woverloaded-virtual \ + ") if (BUILDER_ENABLE_PROFILING) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} --coverage") @@ -16,3 +27,7 @@ macro(setup_builder) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") endmacro() + +macro(increase_warning_level) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wconversion -Wsign-conversion") +endmacro() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ef00cf1..66f3355 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,5 @@ +increase_warning_level() + project(midi) add_library(midi STATIC From 33bd77dd13f24d8f7923c3601446a71df0d846c4 Mon Sep 17 00:00:00 2001 From: Francois Best Date: Sat, 10 Mar 2018 17:59:17 +0100 Subject: [PATCH 3/4] fix: Fix more sign / implicit type conversion warnings --- src/MIDI.cpp | 2 +- src/MIDI.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MIDI.cpp b/src/MIDI.cpp index 7761821..e14a98f 100644 --- a/src/MIDI.cpp +++ b/src/MIDI.cpp @@ -95,7 +95,7 @@ unsigned decodeSysEx(const byte* inSysEx, byte* outData, unsigned inLength) else { const byte body = inSysEx[i]; - const byte msb = ((msbStorage >> byteIndex--) & 1) << 7; + const byte msb = byte(((msbStorage >> byteIndex--) & 1) << 7); outData[count++] = msb | body; } } diff --git a/src/MIDI.hpp b/src/MIDI.hpp index 3ee7c8f..fa34533 100644 --- a/src/MIDI.hpp +++ b/src/MIDI.hpp @@ -292,7 +292,7 @@ template void MidiInterface::sendPitchBend(int inPitchValue, Channel inChannel) { - const unsigned bend = inPitchValue - MIDI_PITCHBEND_MIN; + const unsigned bend = unsigned(inPitchValue - int(MIDI_PITCHBEND_MIN)); send(PitchBend, (bend & 0x7f), (bend >> 7) & 0x7f, inChannel); } From 1cd638361efedbfc83b10c7f698a796e8e9ebaca Mon Sep 17 00:00:00 2001 From: Francois Best Date: Sat, 10 Mar 2018 18:43:15 +0100 Subject: [PATCH 4/4] chore: Update VSCode C++ helper file --- .vscode/c_cpp_properties.json | 54 ++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 7c19b39..1ed9b10 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -6,26 +6,48 @@ "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/include", "/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" ], - "browse" : { - "limitSymbolsToIncludedHeaders" : true, - "databaseFilename" : "" - } + "browse": { + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "", + "path": [ + "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/include", + "/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino" + ] + }, + "intelliSenseMode": "clang-x64", + "macFrameworkPath": [ + "/System/Library/Frameworks", + "/Library/Frameworks" + ] }, { "name": "Linux", - "includePath": ["/usr/include"], - "browse" : { - "limitSymbolsToIncludedHeaders" : true, - "databaseFilename" : "" - } + "includePath": [ + "/usr/include" + ], + "browse": { + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "", + "path": [ + "/usr/include" + ] + }, + "intelliSenseMode": "clang-x64" }, { "name": "Win32", - "includePath": ["c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include"], - "browse" : { - "limitSymbolsToIncludedHeaders" : true, - "databaseFilename" : "" - } + "includePath": [ + "c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include" + ], + "browse": { + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "", + "path": [ + "c:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include" + ] + }, + "intelliSenseMode": "msvc-x64" } - ] -} + ], + "version": 3 +} \ No newline at end of file