From f57e036c006ab7c94b71e65939e9bfc15119a9b2 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Wed, 8 Jul 2026 14:29:18 -0400 Subject: [PATCH] More fixing of warnings after noticing clang was skipping some tests. --- examples/temp_sensor/src/TemperatureFilter.c | 2 +- examples/temp_sensor/src/TimerInterruptConfigurator.c | 9 +++++++++ examples/temp_sensor/src/UsartModel.c | 2 +- examples/temp_sensor/src/UsartPutChar.c | 2 +- examples/temp_sensor/test/TestUsartConductor.c | 10 ++++++---- examples/temp_sensor/test/TestUsartHardware.c | 3 ++- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/examples/temp_sensor/src/TemperatureFilter.c b/examples/temp_sensor/src/TemperatureFilter.c index 5aeb3ff..68532d1 100644 --- a/examples/temp_sensor/src/TemperatureFilter.c +++ b/examples/temp_sensor/src/TemperatureFilter.c @@ -43,7 +43,7 @@ void TemperatureFilter_ProcessInput(float temperature) else { /* Otherwise apply our low-pass filter to smooth the values */ - temperatureInCelcius = (temperatureInCelcius * 0.75f) + (temperature * 0.25); + temperatureInCelcius = (temperatureInCelcius * 0.75f) + (temperature * 0.25f); } } } diff --git a/examples/temp_sensor/src/TimerInterruptConfigurator.c b/examples/temp_sensor/src/TimerInterruptConfigurator.c index 7c1a0d7..0d876b5 100644 --- a/examples/temp_sensor/src/TimerInterruptConfigurator.c +++ b/examples/temp_sensor/src/TimerInterruptConfigurator.c @@ -43,7 +43,16 @@ void Timer_EnableInterrupt(void) static inline void SetInterruptHandler(void) { + /* Assigning a function pointer to a void* interrupt vector register is + * intentional embedded hardware code; suppress the pedantic warning. */ +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" +#endif AT91C_BASE_AIC->AIC_SVR[AT91C_ID_TC0] = Timer_InterruptHandler; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif } static inline void ConfigureInterruptSourceModeRegister(void) diff --git a/examples/temp_sensor/src/UsartModel.c b/examples/temp_sensor/src/UsartModel.c index 1e3115e..5fda16a 100644 --- a/examples/temp_sensor/src/UsartModel.c +++ b/examples/temp_sensor/src/UsartModel.c @@ -14,7 +14,7 @@ #include char formattedTemperature[32]; -char* wakeup = "It's Awesome Time!\n"; +char wakeup[] = "It's Awesome Time!\n"; uint8 UsartModel_GetBaudRateRegisterSetting(void) { diff --git a/examples/temp_sensor/src/UsartPutChar.c b/examples/temp_sensor/src/UsartPutChar.c index aec25cf..d853200 100644 --- a/examples/temp_sensor/src/UsartPutChar.c +++ b/examples/temp_sensor/src/UsartPutChar.c @@ -18,6 +18,6 @@ void Usart_PutChar(char data) #ifdef SIMULATE printf("%c", data); #else - AT91C_BASE_US0->US_THR = data; + AT91C_BASE_US0->US_THR = (uint8)data; #endif } diff --git a/examples/temp_sensor/test/TestUsartConductor.c b/examples/temp_sensor/test/TestUsartConductor.c index b82db81..ee17018 100644 --- a/examples/temp_sensor/test/TestUsartConductor.c +++ b/examples/temp_sensor/test/TestUsartConductor.c @@ -22,9 +22,10 @@ void tearDown(void) void testShouldInitializeHardwareWhenInitCalled(void) { + char wakeup[] = "Hey there!"; UsartModel_GetBaudRateRegisterSetting_ExpectAndReturn(4); - UsartModel_GetWakeupMessage_ExpectAndReturn("Hey there!"); - UsartHardware_TransmitString_Expect("Hey there!"); + UsartModel_GetWakeupMessage_ExpectAndReturn(wakeup); + UsartHardware_TransmitString_Expect(wakeup); UsartHardware_Init_Expect(4); UsartConductor_Init(); @@ -39,9 +40,10 @@ void testRunShouldNotDoAnythingIfSchedulerSaysItIsNotTimeYet(void) void testRunShouldGetCurrentTemperatureAndTransmitIfSchedulerSaysItIsTime(void) { + char temperature[] = "hey there"; TaskScheduler_DoUsart_ExpectAndReturn(TRUE); - UsartModel_GetFormattedTemperature_ExpectAndReturn("hey there"); - UsartHardware_TransmitString_Expect("hey there"); + UsartModel_GetFormattedTemperature_ExpectAndReturn(temperature); + UsartHardware_TransmitString_Expect(temperature); UsartConductor_Run(); } diff --git a/examples/temp_sensor/test/TestUsartHardware.c b/examples/temp_sensor/test/TestUsartHardware.c index 6d762e1..8816819 100644 --- a/examples/temp_sensor/test/TestUsartHardware.c +++ b/examples/temp_sensor/test/TestUsartHardware.c @@ -40,5 +40,6 @@ void testTransmitStringShouldSendDesiredStringOutUsingUsart(void) Usart_PutChar_Expect('l'); Usart_PutChar_Expect('o'); - UsartHardware_TransmitString("hello"); + char msg[] = "hello"; + UsartHardware_TransmitString(msg); }