-
Notifications
You must be signed in to change notification settings - Fork 790
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
enable misra-c2012-2.3 & misra-c2012-2.4 #1801
Conversation
board/can_definitions.h
Outdated
@@ -15,7 +15,8 @@ const uint8_t PANDA_BUS_CNT = 4U; | |||
#define CANPACKET_DATA_SIZE_MAX 8U | |||
#endif | |||
|
|||
typedef struct { | |||
// cppcheck-suppress [misra-c2012-2.3, misra-c2012-2.4] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, why do we have to do this here but not for health.h?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it was a bit tricky to understand for me in the beginning too.
if you try to run my code, cppcheck is flagging misra-c2012 2.3 at the board/pedal/main.c
file only not the other two test of board/main.c
. I'm not entirely sure of the implementation of cppcheck, but I read through the code base and see that they would read through all of the include header files. For instance to check for misra_2.3 it would look through all of the typedef struct
definition of the main file as well as the included files. In the board/pedal/main.c
, if you follow the trail then it would include some header files that include the can_definitions.h
file, while the pedal/main.c file doesn't use any header file that has health.h
file in it.
I also did one experiment and put #include health.h
in the board/pedal/main.c
file and get this.
/home/openpilot/panda/board/health.h:35:1: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-2.3]
typedef struct __attribute__((packed)) {
^
/home/openpilot/panda/board/health.h:4:41: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-2.4]
struct __attribute__((packed)) health_t {
So I think it is a false positive of cppcheck.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not necessary, I just reverted it. please be more careful with changes like this in the future
For #1794, I included both the 2.3 and 2.4 since they are the same fix.
board/can_definitions.h
.USB_OTG_HostPortTypeDef
type because they are commented out inboard/drivers/usb.h
and not used everywhere else