Bug #5538
closedCompiler Warning on Fedora 36 / gcc 12.2.1
Description
On my Fedora 36 system with gcc 12.2.1 compiling the latest git master :
CC main.o
CC alert-debuglog.o
CC alert-fastlog.o
CC alert-syslog.o
CC app-layer.o
CC app-layer-detect-proto.o
In file included from suricata-common.h:501,
from app-layer-detect-proto.c:25:
util-debug.h: In function ‘AppLayerProtoDetectGetProto’:
util-debug.h:330:31: warning: ‘alproto_masks’ may be used uninitialized [-Wmaybe-uninitialized]
330 | #define SCLogDebug(...) SCLog(SC_LOG_DEBUG, FILE, FUNCTION, LINE, VA_ARGS)
| ^~~
app-layer-detect-proto.c:520:15: note: ‘alproto_masks’ was declared here
520 | uint32_t *alproto_masks;
| ^~~~~~~~~~~
CC app-layer-dnp3.o
CC app-layer-dnp3-objects.o
CC app-layer-enip.o
Otherwise compiles without warnings/errors
$ suricata -V
This is Suricata version 7.0.0-dev (fe9150632 2022-09-08)
Updated by Victor Julien about 2 years ago
- Status changed from New to Assigned
- Assignee changed from OISF Dev to Philippe Antoine
- Priority changed from Low to Normal
- Target version changed from TBD to 7.0.0-beta1
I did https://github.com/OISF/suricata/commit/b9ad1d12606f81fccdd8ccab816221a75fac710a, but would like @Philippe Antoine to review.
Updated by Philippe Antoine about 2 years ago
I have seen it with a recent clang as well.
The real fix would be to have a better logic in AppLayerProtoDetectGetProto
not using goto
I said fix because the real bug is in the static analyzer which gets messed up by these gotos
I will take a deeper look
Updated by Philippe Antoine about 2 years ago
- Status changed from Assigned to Closed
I took a deeper look :
- The commit already in master fixed the warning
- I did not see how the previous code could lead to use of uninitialized value
- The code is terribly messy and I understand that a static analyzer can produce a "false positive" on this (or you can say a true positive if it puts a red flag on ugly code)
So closing as is