Feature #1997
openImprove error check at compilation time
0%
Description
I recently fixed a crash which was originated by a function expected to return a pointer and actually missing an explicit return in a specific code path instead of returning NULL.
IMHO this should enable compilation flags to at least have warning about this kind of error to avoid running into similar issues in the future (and we may actually find there are still similar issues nowadays).
It should at least print a warning message at compile time (-Wreturn-type ?), but I think the best would be to treat those cases as errors by default (-Werror), so that we keep the code clean and we then care about the issues printed by the compiler. Other kind of similar checks would be also welcome.
As far as I know, there's some part at least in osmo-iuh which is auto-generated and may print lots of warnings which we cannot fix. I guess in this case we can apply different CFLAGS to that specific set of files which is more relaxed to avoid lots of garbage warnings.
Updated by pespin about 7 years ago
It seems some related work was already done in openbsc. Worth having a look and applying something similar: http://cgit.osmocom.org/openbsc/commit/?id=34f012639ddf41470714ae74ae961d158670a4c7
Updated by pespin over 2 years ago
We did enable -Werror in most projects since a while ago. However, projects based on osmo-iuh cannot use -Werror due to compilation warnings showing up in the ASN1 generated files.
I wrote a sort of fix proposal here:
https://gerrit.osmocom.org/c/osmo-iuh/+/25886
Updated by pespin over 2 years ago
There seems to be some issues currently too due to the structs being named the same:
In file included from /include/asn1c/asn_SEQUENCE_OF.h:8, from /include/osmocom/rua/RUA_Connect.h:15, from /include/osmocom/rua/rua_common.h:13, from /include/osmocom/rua/rua_ies_defs.h:7, from /include/osmocom/hnodeb/rua.h:11, from /git/osmo-hnodeb/src/osmo-hnodeb/rua.c:1: /include/osmocom/ranap/RANAP_GA-Polygon.h:26:9: error: redefinition of ‘struct Member’ 26 | A_SEQUENCE_OF(struct Member { | ^~~~~~~~~~~~~ /include/osmocom/rua/RUA_CriticalityDiagnostics-IE-List.h:28:9: note: originally defined here 28 | A_SEQUENCE_OF(struct Member { | ^~~~~~~~~~~~~