From 7d13cbd8b826a9b6127055dc52242921a421a4f6 Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Fri, 5 Jan 2024 02:02:36 +0100 Subject: [PATCH] Fix pedantic warnings (#2441) * Fix macro pedantic warning * Fixed pedantic warnings --- CMakeLists.txt | 1 + Drv/Ip/SocketReadTask.cpp | 2 +- Drv/Ip/SocketReadTask.hpp | 2 +- .../LinuxGpioDriverComponentImpl.cpp | 4 +-- Drv/LinuxI2cDriver/LinuxI2cDriver.cpp | 36 +++++++++---------- .../LinuxSpiDriverComponentImpl.cpp | 4 +-- Drv/LinuxUartDriver/LinuxUartDriver.cpp | 4 +-- Fw/Comp/ActiveComponentBase.cpp | 4 +-- Fw/Logger/Logger.cpp | 3 +- Fw/Types/BasicTypes.hpp | 2 +- Os/Linux/File.cpp | 4 +-- Os/Linux/SystemResources.cpp | 2 +- Os/ValidatedFile.hpp | 2 +- Ref/CMakeLists.txt | 1 + Svc/BufferLogger/BufferLogger.cpp | 2 +- Svc/CmdSequencer/Sequence.cpp | 2 +- Svc/ComLogger/ComLogger.cpp | 2 +- Svc/ComLogger/ComLogger.hpp | 2 +- Svc/ComSplitter/ComSplitter.cpp | 2 +- Svc/ComSplitter/ComSplitter.hpp | 2 +- Svc/FramingProtocol/DeframingProtocol.cpp | 2 +- Svc/FramingProtocol/DeframingProtocol.hpp | 2 +- Svc/FramingProtocol/FprimeProtocol.cpp | 2 +- Svc/FramingProtocol/FramingProtocol.cpp | 2 +- Svc/UdpReceiver/UdpReceiverComponentImpl.cpp | 4 +-- Svc/UdpSender/UdpSenderComponentImpl.cpp | 4 +-- Utils/Types/Queue.cpp | 2 +- config/FpConfig.hpp | 2 +- 28 files changed, 51 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad0fa20d5f..f85651021a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ add_compile_options( -Wall -Wextra -Werror +# -pedantic $<$:-Wold-style-cast> -Wno-unused-parameter ) diff --git a/Drv/Ip/SocketReadTask.cpp b/Drv/Ip/SocketReadTask.cpp index a595b8cd90..73cef229ca 100644 --- a/Drv/Ip/SocketReadTask.cpp +++ b/Drv/Ip/SocketReadTask.cpp @@ -111,4 +111,4 @@ void SocketReadTask::readTask(void* pointer) { (status == SOCK_SUCCESS || status == SOCK_INTERRUPTED_TRY_AGAIN || self->m_reconnect)); self->getSocketHandler().shutdown(); // Shutdown the port entirely } -}; // namespace Drv +} // namespace Drv diff --git a/Drv/Ip/SocketReadTask.hpp b/Drv/Ip/SocketReadTask.hpp index e6e92720d3..19bbe4233f 100644 --- a/Drv/Ip/SocketReadTask.hpp +++ b/Drv/Ip/SocketReadTask.hpp @@ -173,5 +173,5 @@ class SocketReadTask { bool m_stop; //!< Stops the task when set to true }; -}; +} #endif // DRV_SOCKETREADTASK_HPP diff --git a/Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.cpp b/Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.cpp index 11d122f57f..aa644de3a1 100644 --- a/Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.cpp +++ b/Drv/LinuxGpioDriver/LinuxGpioDriverComponentImpl.cpp @@ -27,8 +27,8 @@ #include #include -//#define DEBUG_PRINT(x,...) printf(x,##__VA_ARGS__); fflush(stdout) -#define DEBUG_PRINT(x,...) +//#define DEBUG_PRINT(...) printf(##__VA_ARGS__); fflush(stdout) +#define DEBUG_PRINT(...) namespace Drv { diff --git a/Drv/LinuxI2cDriver/LinuxI2cDriver.cpp b/Drv/LinuxI2cDriver/LinuxI2cDriver.cpp index 9afb610d75..8d2dcba430 100644 --- a/Drv/LinuxI2cDriver/LinuxI2cDriver.cpp +++ b/Drv/LinuxI2cDriver/LinuxI2cDriver.cpp @@ -174,25 +174,23 @@ namespace Drv { Fw::Logger::logMsg("I2c addr: 0x%02X\n",addr); #endif - struct i2c_msg rdwr_msgs[2] = { - { // Start address - .addr = static_cast(addr), - .flags = 0, // write - .len = static_cast(writeBuffer.getSize()), - .buf = writeBuffer.getData() - }, - { // Read buffer - .addr = static_cast(addr), - .flags = I2C_M_RD, // read - .len = static_cast(readBuffer.getSize()), - .buf = readBuffer.getData() - } - }; - - struct i2c_rdwr_ioctl_data rdwr_data = { - .msgs = rdwr_msgs, - .nmsgs = 2 - }; + struct i2c_msg rdwr_msgs[2]; + + // Start address + rdwr_msgs[0].addr = static_cast(addr); + rdwr_msgs[0].flags = 0; // write + rdwr_msgs[0].len = static_cast(writeBuffer.getSize()); + rdwr_msgs[0].buf = writeBuffer.getData(); + + // Read buffer + rdwr_msgs[1].addr = static_cast(addr); + rdwr_msgs[1].flags = I2C_M_RD; // read + rdwr_msgs[1].len = static_cast(readBuffer.getSize()); + rdwr_msgs[1].buf = readBuffer.getData(); + + struct i2c_rdwr_ioctl_data rdwr_data; + rdwr_data.msgs = rdwr_msgs; + rdwr_data.nmsgs = 2; //Use ioctl to perform the combined write/read transaction NATIVE_INT_TYPE stat = ioctl(this->m_fd, I2C_RDWR, &rdwr_data); diff --git a/Drv/LinuxSpiDriver/LinuxSpiDriverComponentImpl.cpp b/Drv/LinuxSpiDriver/LinuxSpiDriverComponentImpl.cpp index c07fc0e465..78afd2c624 100644 --- a/Drv/LinuxSpiDriver/LinuxSpiDriverComponentImpl.cpp +++ b/Drv/LinuxSpiDriver/LinuxSpiDriverComponentImpl.cpp @@ -24,8 +24,8 @@ #include #include -//#define DEBUG_PRINT(x,...) printf(x,##__VA_ARGS__); fflush(stdout) -#define DEBUG_PRINT(x,...) +//#define DEBUG_PRINT(...) printf(##__VA_ARGS__); fflush(stdout) +#define DEBUG_PRINT(...) namespace Drv { diff --git a/Drv/LinuxUartDriver/LinuxUartDriver.cpp b/Drv/LinuxUartDriver/LinuxUartDriver.cpp index b099e7c15c..8eb3f7290b 100644 --- a/Drv/LinuxUartDriver/LinuxUartDriver.cpp +++ b/Drv/LinuxUartDriver/LinuxUartDriver.cpp @@ -22,8 +22,8 @@ //#include //#include -//#define DEBUG_PRINT(x,...) printf(x,##__VA_ARGS__); fflush(stdout) -#define DEBUG_PRINT(x, ...) +//#define DEBUG_PRINT(...) printf(##__VA_ARGS__); fflush(stdout) +#define DEBUG_PRINT(...) namespace Drv { diff --git a/Fw/Comp/ActiveComponentBase.cpp b/Fw/Comp/ActiveComponentBase.cpp index 409fd3b69e..abd7631aec 100644 --- a/Fw/Comp/ActiveComponentBase.cpp +++ b/Fw/Comp/ActiveComponentBase.cpp @@ -4,8 +4,8 @@ #include #include -//#define DEBUG_PRINT(x,...) printf(x,##__VA_ARGS__); fflush(stdout) -#define DEBUG_PRINT(x,...) +//#define DEBUG_PRINT(...) printf(##__VA_ARGS__); fflush(stdout) +#define DEBUG_PRINT(...) namespace Fw { diff --git a/Fw/Logger/Logger.cpp b/Fw/Logger/Logger.cpp index 27bd11ae45..07d08becad 100644 --- a/Fw/Logger/Logger.cpp +++ b/Fw/Logger/Logger.cpp @@ -31,5 +31,4 @@ namespace Fw { Logger::~Logger() { } -}; -//End namespace Fw +} //End namespace Fw diff --git a/Fw/Types/BasicTypes.hpp b/Fw/Types/BasicTypes.hpp index ec5f578ee9..e23651f8f0 100644 --- a/Fw/Types/BasicTypes.hpp +++ b/Fw/Types/BasicTypes.hpp @@ -12,7 +12,7 @@ // Use C linkage for the basic items extern "C" { #include "BasicTypes.h" -}; +} #ifndef FW_BASIC_TYPES_HPP #define FW_BASIC_TYPES_HPP diff --git a/Os/Linux/File.cpp b/Os/Linux/File.cpp index 8f63964957..21bb33e298 100644 --- a/Os/Linux/File.cpp +++ b/Os/Linux/File.cpp @@ -21,8 +21,8 @@ extern "C" { #include #include -//#define DEBUG_PRINT(x,...) printf(x,##__VA_ARGS__); fflush(stdout) -#define DEBUG_PRINT(x,...) +//#define DEBUG_PRINT(...) printf(##__VA_ARGS__); fflush(stdout) +#define DEBUG_PRINT(...) namespace Os { diff --git a/Os/Linux/SystemResources.cpp b/Os/Linux/SystemResources.cpp index 90df778fcd..f0d9efd746 100644 --- a/Os/Linux/SystemResources.cpp +++ b/Os/Linux/SystemResources.cpp @@ -68,7 +68,7 @@ namespace Os { SystemResources::SystemResourcesStatus parseCpuData(char proc_stat_line[LINE_SIZE], U32 cpu_data[4]) { - if (sscanf(proc_stat_line, "%*s %d %d %d %d", &cpu_data[0], &cpu_data[1], &cpu_data[2], &cpu_data[3]) != + if (sscanf(proc_stat_line, "%*s %u %u %u %u", &cpu_data[0], &cpu_data[1], &cpu_data[2], &cpu_data[3]) != 4) { return SystemResources::SYSTEM_RESOURCES_ERROR; } diff --git a/Os/ValidatedFile.hpp b/Os/ValidatedFile.hpp index 69d19feed7..7d309873fd 100644 --- a/Os/ValidatedFile.hpp +++ b/Os/ValidatedFile.hpp @@ -65,6 +65,6 @@ namespace Os { Utils::HashBuffer hashBuffer; }; -}; +} #endif diff --git a/Ref/CMakeLists.txt b/Ref/CMakeLists.txt index b5bfb0d671..d898889c86 100644 --- a/Ref/CMakeLists.txt +++ b/Ref/CMakeLists.txt @@ -56,6 +56,7 @@ register_fprime_deployment() target_compile_options("${PROJECT_NAME}" PUBLIC -Wall) target_compile_options("${PROJECT_NAME}" PUBLIC -Wextra) target_compile_options("${PROJECT_NAME}" PUBLIC -Werror) +target_compile_options("${PROJECT_NAME}" PUBLIC -pedantic) #target_compile_options("${PROJECT_NAME}" PUBLIC -Wshadow) target_compile_options("${PROJECT_NAME}" PUBLIC -Wconversion) target_compile_options("${PROJECT_NAME}" PUBLIC -Wsign-conversion) diff --git a/Svc/BufferLogger/BufferLogger.cpp b/Svc/BufferLogger/BufferLogger.cpp index ac75bb622d..6f0df8ac11 100644 --- a/Svc/BufferLogger/BufferLogger.cpp +++ b/Svc/BufferLogger/BufferLogger.cpp @@ -157,4 +157,4 @@ namespace Svc { } } -}; +} diff --git a/Svc/CmdSequencer/Sequence.cpp b/Svc/CmdSequencer/Sequence.cpp index 1ab4151731..5a0ec53d48 100644 --- a/Svc/CmdSequencer/Sequence.cpp +++ b/Svc/CmdSequencer/Sequence.cpp @@ -20,7 +20,7 @@ namespace Svc { m_allocatorId(0) { - }; + } CmdSequencerComponentImpl::Sequence :: ~Sequence() diff --git a/Svc/ComLogger/ComLogger.cpp b/Svc/ComLogger/ComLogger.cpp index a82d283937..ab50c2a72d 100644 --- a/Svc/ComLogger/ComLogger.cpp +++ b/Svc/ComLogger/ComLogger.cpp @@ -290,4 +290,4 @@ namespace Svc { this->log_WARNING_LO_FileValidationError(logStringArg1, logStringArg2, validateStatus); } } -}; +} diff --git a/Svc/ComLogger/ComLogger.hpp b/Svc/ComLogger/ComLogger.hpp index 1a8cbf53dc..a2cba3ce52 100644 --- a/Svc/ComLogger/ComLogger.hpp +++ b/Svc/ComLogger/ComLogger.hpp @@ -152,6 +152,6 @@ namespace Svc { void writeHashFile( ); }; -}; +} #endif diff --git a/Svc/ComSplitter/ComSplitter.cpp b/Svc/ComSplitter/ComSplitter.cpp index 963eb71504..92f170e2d6 100644 --- a/Svc/ComSplitter/ComSplitter.cpp +++ b/Svc/ComSplitter/ComSplitter.cpp @@ -57,4 +57,4 @@ namespace Svc { } } -}; +} diff --git a/Svc/ComSplitter/ComSplitter.hpp b/Svc/ComSplitter/ComSplitter.hpp index 6c2b4b9b3b..4a51d181d2 100644 --- a/Svc/ComSplitter/ComSplitter.hpp +++ b/Svc/ComSplitter/ComSplitter.hpp @@ -48,6 +48,6 @@ namespace Svc { }; -}; +} #endif diff --git a/Svc/FramingProtocol/DeframingProtocol.cpp b/Svc/FramingProtocol/DeframingProtocol.cpp index 7c605e702b..a31106c404 100644 --- a/Svc/FramingProtocol/DeframingProtocol.cpp +++ b/Svc/FramingProtocol/DeframingProtocol.cpp @@ -22,4 +22,4 @@ void DeframingProtocol::setup(DeframingProtocolInterface& interface) { FW_ASSERT(m_interface == nullptr); m_interface = &interface; } -}; +} diff --git a/Svc/FramingProtocol/DeframingProtocol.hpp b/Svc/FramingProtocol/DeframingProtocol.hpp index b36111f489..6bb4e10781 100644 --- a/Svc/FramingProtocol/DeframingProtocol.hpp +++ b/Svc/FramingProtocol/DeframingProtocol.hpp @@ -62,5 +62,5 @@ class DeframingProtocol { PROTECTED: DeframingProtocolInterface* m_interface; }; -}; +} #endif // SVC_DEFRAMING_PROTOCOL_HPP diff --git a/Svc/FramingProtocol/FprimeProtocol.cpp b/Svc/FramingProtocol/FprimeProtocol.cpp index f7d162a910..6639e7d933 100644 --- a/Svc/FramingProtocol/FprimeProtocol.cpp +++ b/Svc/FramingProtocol/FprimeProtocol.cpp @@ -131,4 +131,4 @@ DeframingProtocol::DeframingStatus FprimeDeframing::deframe(Types::CircularBuffe m_interface->route(buffer); return DeframingProtocol::DEFRAMING_STATUS_SUCCESS; } -}; +} diff --git a/Svc/FramingProtocol/FramingProtocol.cpp b/Svc/FramingProtocol/FramingProtocol.cpp index 65541b173c..e94750b90d 100644 --- a/Svc/FramingProtocol/FramingProtocol.cpp +++ b/Svc/FramingProtocol/FramingProtocol.cpp @@ -22,4 +22,4 @@ void FramingProtocol::setup(FramingProtocolInterface& interface) { FW_ASSERT(m_interface == nullptr); m_interface = &interface; } -}; +} diff --git a/Svc/UdpReceiver/UdpReceiverComponentImpl.cpp b/Svc/UdpReceiver/UdpReceiverComponentImpl.cpp index 8c9885b3de..3a38ffbec9 100644 --- a/Svc/UdpReceiver/UdpReceiverComponentImpl.cpp +++ b/Svc/UdpReceiver/UdpReceiverComponentImpl.cpp @@ -22,8 +22,8 @@ #include #include -//#define DEBUG_PRINT(x,...) printf(x,##__VA_ARGS__) -#define DEBUG_PRINT(x,...) +//#define DEBUG_PRINT(...) printf(##__VA_ARGS__) +#define DEBUG_PRINT(...) namespace Svc { diff --git a/Svc/UdpSender/UdpSenderComponentImpl.cpp b/Svc/UdpSender/UdpSenderComponentImpl.cpp index 9daa282562..43b2fc1ef6 100644 --- a/Svc/UdpSender/UdpSenderComponentImpl.cpp +++ b/Svc/UdpSender/UdpSenderComponentImpl.cpp @@ -19,8 +19,8 @@ #include #include -//#define DEBUG_PRINT(x,...) printf(x,##__VA_ARGS__) -#define DEBUG_PRINT(x,...) +//#define DEBUG_PRINT(...) printf(##__VA_ARGS__) +#define DEBUG_PRINT(...) namespace Svc { diff --git a/Utils/Types/Queue.cpp b/Utils/Types/Queue.cpp index ef41ee90bb..9e5e25346f 100644 --- a/Utils/Types/Queue.cpp +++ b/Utils/Types/Queue.cpp @@ -53,4 +53,4 @@ NATIVE_UINT_TYPE Queue::getQueueSize() const { } -}; // namespace Types \ No newline at end of file +} // namespace Types \ No newline at end of file diff --git a/config/FpConfig.hpp b/config/FpConfig.hpp index cc4b89d27c..a51cc000dd 100644 --- a/config/FpConfig.hpp +++ b/config/FpConfig.hpp @@ -11,4 +11,4 @@ #include extern "C" { #include -}; +}