small fixes; add compile checks

main
Clyne 1 year ago
parent f3c28dd2f1
commit d7cd899653
Signed by: clyne
GPG Key ID: 3267C8EBF3F9AFC7

@ -162,10 +162,10 @@ INCDIR = $(CONFDIR) $(ALLINC) $(TESTINC) \
source source/periph source source/periph
# Define C warning options here. # 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. # 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 # Project, target, sources and paths
@ -217,6 +217,17 @@ include $(RULESPATH)/rules.mk
# Custom rules # 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 # Custom rules
############################################################################## ##############################################################################

@ -223,7 +223,7 @@ void sampleRate(unsigned char *cmd)
{ {
if (EM.assert(USBSerial::read(&cmd[1], 1) == 1, Error::BadParamSize)) { if (EM.assert(USBSerial::read(&cmd[1], 1) == 1, Error::BadParamSize)) {
if (cmd[1] == 0xFF) { if (cmd[1] == 0xFF) {
unsigned char r = SClock::getRate(); auto r = static_cast<unsigned char>(SClock::getRate());
USBSerial::write(&r, 1); USBSerial::write(&r, 1);
} else { } else {
auto r = static_cast<SClock::Rate>(cmd[1]); auto r = static_cast<SClock::Rate>(cmd[1]);

@ -156,6 +156,7 @@ void ConversionManager::threadRunner(void *)
samples = entry(samples, size); samples = entry(samples, size);
asm("mov sp, %0" :: "r" (sp)); asm("mov sp, %0" :: "r" (sp));
volatile auto testRead = *samples; volatile auto testRead = *samples;
(void)testRead;
} else { } else {
// Start execution timer: // Start execution timer:
asm("mov %0, sp; eor r0, r0; svc 2" : "=r" (sp)); asm("mov %0, sp; eor r0, r0; svc 2" : "=r" (sp));
@ -163,6 +164,7 @@ void ConversionManager::threadRunner(void *)
// Stop execution timer: // Stop execution timer:
asm("mov r0, #1; svc 2; mov sp, %0" :: "r" (sp)); asm("mov r0, #1; svc 2; mov sp, %0" :: "r" (sp));
volatile auto testRead = *samples; volatile auto testRead = *samples;
(void)testRead;
} }
} }

@ -264,7 +264,6 @@ static const USBEndpointConfig ep2config = {
* Handles the USB driver global events. * Handles the USB driver global events.
*/ */
static void usb_event(USBDriver *usbp, usbevent_t event) { static void usb_event(USBDriver *usbp, usbevent_t event) {
extern SerialUSBDriver SDU1;
switch (event) { switch (event) {
case USB_EVENT_ADDRESS: case USB_EVENT_ADDRESS:

@ -19,12 +19,12 @@ void SampleBuffer::clear() {
} }
__attribute__((section(".convcode"))) __attribute__((section(".convcode")))
void SampleBuffer::modify(Sample *data, unsigned int srcsize) { void SampleBuffer::modify(Sample *data, unsigned int srcsize) {
auto size = srcsize < m_size ? srcsize : m_size; auto dsize = srcsize < m_size ? srcsize : m_size;
size = (size + 15) & (~15); dsize = (dsize + 15) & (~15);
m_modified = m_buffer; m_modified = m_buffer;
const int *src = reinterpret_cast<const int *>(data); const int *src = reinterpret_cast<const int *>(data);
const int * const srcend = src + (size / 2); const int * const srcend = src + (dsize / 2);
int *dst = reinterpret_cast<int *>(m_buffer); int *dst = reinterpret_cast<int *>(m_buffer);
do { do {
int a = src[0]; int a = src[0];
@ -49,12 +49,12 @@ void SampleBuffer::modify(Sample *data, unsigned int srcsize) {
} }
__attribute__((section(".convcode"))) __attribute__((section(".convcode")))
void SampleBuffer::midmodify(Sample *data, unsigned int srcsize) { void SampleBuffer::midmodify(Sample *data, unsigned int srcsize) {
auto size = srcsize < m_size / 2 ? srcsize : m_size / 2; auto dsize = srcsize < m_size / 2 ? srcsize : m_size / 2;
size = (size + 15) & (~15); dsize = (dsize + 15) & (~15);
m_modified = middata(); m_modified = middata();
const int *src = reinterpret_cast<const int *>(data); const int *src = reinterpret_cast<const int *>(data);
const int * const srcend = src + (size / 2); const int * const srcend = src + (dsize / 2);
int *dst = reinterpret_cast<int *>(middata()); int *dst = reinterpret_cast<int *>(middata());
do { do {
int a = src[0]; int a = src[0];

@ -29,7 +29,7 @@ class SampleBuffer
{ {
public: public:
// Manage the sample data memory at 'buffer'. // Manage the sample data memory at 'buffer'.
SampleBuffer(Sample *buffer); explicit SampleBuffer(Sample *buffer);
/** /**
* Fill the current buffer with midpoint (2048/0V) values. * Fill the current buffer with midpoint (2048/0V) values.

Loading…
Cancel
Save