laurencelundblade / QCBOR

Comprehensive, powerful, commercial-quality CBOR encoder/ decoder that is still suited for small devices.
Other
186 stars 47 forks source link

Disable -Wmaybe-uninitialized because of false positives #179

Closed laurencelundblade closed 1 year ago

laurencelundblade commented 1 year ago

For some versions of gcc (but not all) -Wall enables -Wmaybe-uninitialized.

While there are no uninitialized variables in QCBOR, warnings are still produced with some versions of gcc and with some optimization options for gcc. This just disables the warning entirely for qcbor_decode.c and notes where the warnings were checked.

It is well understood that -Wmaybe-uninitialized produces false positives.

QCBOR has been through full and proper static analysis so we know it doesn't have uninitialized variables. The cases that -Wmaybe-uninitialized complained about in one case (I can't reproduce them) have been checked and noted.

Note that just slamming initialization on to the variables to prevent the warnings is actually a bit dangerous because you don't know what the proper initialization value should be. You actually have to read and understand the code to initialize correctly. That or confirm there is no uninitialized variables. Both have been done in this case.