Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pedantic warnings #2441

Merged
merged 2 commits into from Jan 5, 2024
Merged

Conversation

JohanBertrand
Copy link
Contributor

Related Issue(s) N/A
Has Unit Tests (y/n) N/A
Documentation Included (y/n) N/A

Change Description

Fixes some of the pedantic warnings in the code base. To be merged/checked once #2436 is merged.
I activated the pedantic flag on the Ref project, I am not sure if it is something that was expected.
I kept it deactivated on the root CMakeLists.txt.

Still open to be pedantic-compliant is the declaration of 0 sized array, which I guess, would have to be fixed from the fpp side.

build-fprime-automatic-native/F-Prime/Svc/CmdSequencer/CmdSequencerComponentAc.cpp:41:60: error: ISO C++ forbids zero-size array ‘seqCancelInPortSize’ [-Werror=pedantic]
   41 |       BYTE seqCancelInPortSize[Svc::InputCmdSeqCancelPort::SERIALIZED_SIZE];
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~

There are also some warnings on the unit tests, but I guess it will need its own PR.


Main changes:

  • Changed %d to %u for printing unsigned integer
error: format ‘%d’ expects argument of type ‘int*’, but argument 4 has type ‘U32*’ {aka ‘unsigned int*’} [-Werror=format=]
  • Removed semicolon after closure of namespaces
error: extra ‘;’ [-Werror=pedantic]
  • Changed designated initializers to sequential initialisation
error: C++ designated initializers only available with ‘-std=c++2a’ or ‘-std=gnu++2a’ [-Werror=pedantic]
  • Changed variadic macro definition to have at least one argument
error: ISO C++11 requires at least one argument for the "..." in a variadic macro [-Werror]

@@ -53,4 +53,4 @@
}


}; // namespace Types
} // namespace Types

Check warning

Code scanning / CppCheck

Could not find a newline character at the end of the file. Warning

Could not find a newline character at the end of the file.
struct i2c_msg rdwr_msgs[2];

// Start address
rdwr_msgs[0].addr = static_cast<U16>(addr);

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter addr has not been checked.
//#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(...)

Check notice

Code scanning / CodeQL

Undisciplined macro Note

The macro DEBUG_PRINT(__VA_ARGS__...) is variadic, and hence not allowed.
//#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(...)

Check notice

Code scanning / CodeQL

Undisciplined macro Note

The macro DEBUG_PRINT(__VA_ARGS__...) is variadic, and hence not allowed.
//#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(...)

Check notice

Code scanning / CodeQL

Undisciplined macro Note

The macro DEBUG_PRINT(__VA_ARGS__...) is variadic, and hence not allowed.
//#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(...)

Check notice

Code scanning / CodeQL

Undisciplined macro Note

The macro DEBUG_PRINT(__VA_ARGS__...) is variadic, and hence not allowed.
//#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(...)

Check notice

Code scanning / CodeQL

Undisciplined macro Note

The macro DEBUG_PRINT(__VA_ARGS__...) is variadic, and hence not allowed.
@SMorettini
Copy link
Contributor

Still open to be pedantic-compliant is the declaration of 0 sized array, which I guess, would have to be fixed from the fpp side.

Should be solved by nasa/fpp#368

Copy link
Collaborator

@LeStarch LeStarch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the one question, otherwise looks good!

Drv/LinuxI2cDriver/LinuxI2cDriver.cpp Show resolved Hide resolved
@LeStarch LeStarch requested review from thomas-bc and removed request for timcanham January 4, 2024 19:02
@LeStarch LeStarch merged commit 7d13cbd into nasa:devel Jan 5, 2024
34 checks passed
@JohanBertrand JohanBertrand deleted the fix-pedantic-warnings branch April 29, 2024 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants