commaai / panda

code powering the comma.ai panda
MIT License
1.52k stars 763 forks source link

MISRA safety_toyota.h #1876

Open AlexandreSato opened 6 months ago

AlexandreSato commented 6 months ago

0 -> false

adeebshihadeh commented 6 months ago

I don't really want to merge this without cppcheck enforcing this. @0x41head do you think there's a way to make cppcheck check this somehow? I'd put up a new bounty for adding upstream support for that. Maybe we can directly check the token string?

0x41head commented 6 months ago

Can I get some context ? What is this commit for ? Why is this commit a problem since false in stdbool is just #define false 0

adeebshihadeh commented 6 months ago

We want bool tx = 0/1 to fail and bool tx = false/true to pass for readability, even if 0/1 are the underlying values.

0x41head commented 6 months ago

I am not sure if we can push this upstream. But we can definitely make our own addon for this check. Should be easy as all addons work on a dump file generated by cppchecker, which is just an XML.

adeebshihadeh commented 6 months ago

I'd prefer to upstream it, but that may be an option if the addon is small (<20 lines?)

0x41head commented 6 months ago

addon would be pretty small. Probably something like the findcasts addon

adeebshihadeh commented 6 months ago

That would be totally fine, but let's try to upstream it first.

adeebshihadeh commented 6 months ago

Cool, let's do a $150 bounty for getting all of these fixed and checked with cppcheck, ideally inside cppcheck, but ok as an addon if they reject it