diff --git a/firmware/Makefile b/firmware/Makefile index 0db249b..542bcea 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -162,10 +162,10 @@ INCDIR = $(CONFDIR) $(ALLINC) $(TESTINC) \ source source/periph # Define C warning options here. -CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes -pedantic +CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes -pedantic -Werror # Define C++ warning options here. -CPPWARN = -Wall -Wextra -Wundef -pedantic -Wno-volatile +CPPWARN = -Wall -Wextra -Wundef -pedantic -Wno-volatile -Werror -Wconversion # # Project, target, sources and paths @@ -217,6 +217,17 @@ include $(RULESPATH)/rules.mk # Custom rules # +check: + cppcheck --std=c++17 --enable=warning,style,performance,portability --force $(shell find source/ -name "*.cpp" -or -name "*.hpp" -or -name "*.c" -or -name "*.h" -type f) + +tidy: + clang-tidy \ + -warnings-as-errors=* \ + --extra-arg=-I --extra-arg=/usr/lib/gcc/arm-none-eabi/13/include/g++-v13 \ + --extra-arg=-I --extra-arg=/usr/lib/gcc/arm-none-eabi/13/include/g++-v13/arm-none-eabi \ + $(CPPSRC) + # # Custom rules ############################################################################## + diff --git a/firmware/source/communication.cpp b/firmware/source/communication.cpp index e85828b..8a9f86e 100644 --- a/firmware/source/communication.cpp +++ b/firmware/source/communication.cpp @@ -223,7 +223,7 @@ void sampleRate(unsigned char *cmd) { if (EM.assert(USBSerial::read(&cmd[1], 1) == 1, Error::BadParamSize)) { if (cmd[1] == 0xFF) { - unsigned char r = SClock::getRate(); + auto r = static_cast(SClock::getRate()); USBSerial::write(&r, 1); } else { auto r = static_cast(cmd[1]); diff --git a/firmware/source/conversion.cpp b/firmware/source/conversion.cpp index 56a689e..8b6a927 100644 --- a/firmware/source/conversion.cpp +++ b/firmware/source/conversion.cpp @@ -156,6 +156,7 @@ void ConversionManager::threadRunner(void *) samples = entry(samples, size); asm("mov sp, %0" :: "r" (sp)); volatile auto testRead = *samples; + (void)testRead; } else { // Start execution timer: asm("mov %0, sp; eor r0, r0; svc 2" : "=r" (sp)); @@ -163,6 +164,7 @@ void ConversionManager::threadRunner(void *) // Stop execution timer: asm("mov r0, #1; svc 2; mov sp, %0" :: "r" (sp)); volatile auto testRead = *samples; + (void)testRead; } } diff --git a/firmware/source/periph/usbcfg.c b/firmware/source/periph/usbcfg.c index b726e23..537cca7 100644 --- a/firmware/source/periph/usbcfg.c +++ b/firmware/source/periph/usbcfg.c @@ -264,7 +264,6 @@ static const USBEndpointConfig ep2config = { * Handles the USB driver global events. */ static void usb_event(USBDriver *usbp, usbevent_t event) { - extern SerialUSBDriver SDU1; switch (event) { case USB_EVENT_ADDRESS: diff --git a/firmware/source/samplebuffer.cpp b/firmware/source/samplebuffer.cpp index 74c6778..f04173a 100644 --- a/firmware/source/samplebuffer.cpp +++ b/firmware/source/samplebuffer.cpp @@ -19,12 +19,12 @@ void SampleBuffer::clear() { } __attribute__((section(".convcode"))) void SampleBuffer::modify(Sample *data, unsigned int srcsize) { - auto size = srcsize < m_size ? srcsize : m_size; - size = (size + 15) & (~15); + auto dsize = srcsize < m_size ? srcsize : m_size; + dsize = (dsize + 15) & (~15); m_modified = m_buffer; const int *src = reinterpret_cast(data); - const int * const srcend = src + (size / 2); + const int * const srcend = src + (dsize / 2); int *dst = reinterpret_cast(m_buffer); do { int a = src[0]; @@ -49,12 +49,12 @@ void SampleBuffer::modify(Sample *data, unsigned int srcsize) { } __attribute__((section(".convcode"))) void SampleBuffer::midmodify(Sample *data, unsigned int srcsize) { - auto size = srcsize < m_size / 2 ? srcsize : m_size / 2; - size = (size + 15) & (~15); + auto dsize = srcsize < m_size / 2 ? srcsize : m_size / 2; + dsize = (dsize + 15) & (~15); m_modified = middata(); const int *src = reinterpret_cast(data); - const int * const srcend = src + (size / 2); + const int * const srcend = src + (dsize / 2); int *dst = reinterpret_cast(middata()); do { int a = src[0]; diff --git a/firmware/source/samplebuffer.hpp b/firmware/source/samplebuffer.hpp index 8328770..9b837bc 100644 --- a/firmware/source/samplebuffer.hpp +++ b/firmware/source/samplebuffer.hpp @@ -29,7 +29,7 @@ class SampleBuffer { public: // Manage the sample data memory at 'buffer'. - SampleBuffer(Sample *buffer); + explicit SampleBuffer(Sample *buffer); /** * Fill the current buffer with midpoint (2048/0V) values.