scan-build errors found during 2019.07 testing #11852
Labels
Area: cpu
Area: CPU/MCU ports
Area: drivers
Area: Device drivers
Area: network
Area: Networking
Area: pkg
Area: External package ports
Area: sys
Area: System
Area: tests
Area: tests and testing framework
Area: tools
Area: Supplementary tools
Type: bug
The issue reports a bug / The PR fixes a bug (including spelling errors)
Description
I am running
scan-build
checking for the 2019.07 release RIOT-OS/Release-Specs#128I will try to list the issues I found here.
By running the
scan-build
command manually, you get the webpage that gives the path taken by the analyzer to show the error. Which is good to have context.The parsed result is available here: https://ci-ilab.imp.fu-berlin.de/job/RIOT%20scan-build-analyze/18/
How should issues be handled?
sys/cdefs.h
.-Wno-deprecated-declarations
when runningscan-build
? Or a way to have a supportedCFLAGS_APPEND
.value is never read
be disabled or correctly handled?List of found issues:
TODO
Reported files
RIOT/sys/net/application_layer/nanocoap/nanocoap.c
Line 307 in 14fe8f2
Error handling is done on
option_len
but as there was no length,it is used not initialized.
RIOT/cpu/sam0_common/include/periph_cpu_common.h
Line 395 in 14fe8f2
The default case returns
-1
for anuint8_t
which also causes invalid C code.Could be replaced by a compile time error.
RIOT/drivers/ata8520e/ata8520e.c
Line 203 in 14fe8f2
Could be
(void)
in an else statement.RIOT/drivers/bmp180/bmp180.c
Line 120 in 14fe8f2
As the function does not check the return value, _compute_b5 can use uninitialized value in case of error.
Also it currently acquires 2 times the
i2c
for_read_ut
.RIOT/drivers/nrf24l01p/nrf24l01p.c
Line 644 in 14fe8f2
Would need an enum I guess instead of hardwriten values and generic type.
RIOT/drivers/tmp006/tmp006.c
Line 248 in 14fe8f2
As the function does not check the return value of
tmp006_read
in case of error,it would result in using
drdy
not initialized.There is even some
drdy
error checking, but what if the function failed…RIOT/pkg/lwip/contrib/netdev/lwip_netdev.c
Line 203 in 14fe8f2
LL_COUNT(p, q, count);
may return a 0 value forcount
.It seems that indeed
conn
can be NULL before being de-referencedcore/include/rmutex.h
used byRIOT/sys/net/gnrc/netif/gnrc_netif.c
Line 23 in 14fe8f2
There is an
assert(netif != NULL)
but still assumes that&netif->mutex
can be NULL.The
rmutex
function could be decorated with a__nonnull
attribute completely.RIOT/sys/hashes/sha3.c
Line 427 in 14fe8f2
The value is never used. This looks indeed not used. Not sure if it was meant
or if it is an initialization that should be outside the loop.
RIOT/sys/hashes/sha256.c
Line 80 in 14fe8f2
The compiler has no idea that
src
is of the right length.A more precise type definition could help, would be good to find the correct way of declaring this for the compiler.
RIOT/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c
Line 232 in 14fe8f2
Initialized even if
DEBUG
is not set.sys/include/net/addr.h
throughRIOT/sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c
Line 23 in 14fe8f2
Looks like it assumes that
dst
can be NULL. An assert or__nonnull
attribute should help.RIOT/sys/net/application_layer/uhcp/uhcpc.c
Line 40 in 14fe8f2
Value is obviously ignored.
RIOT/sys/net/gnrc/network_layer/sixlowpan/iphc/gnrc_sixlowpan_iphc.c
Line 1007 in 14fe8f2
The function is so big that the reported analysis is on 300 lines.
RIOT/sys/net/gnrc/link_layer/gomach/gomach_internal.c
Line 786 in 14fe8f2
Minor one indeed set just after, could be removed.
The other one is a quite complex analysis, should have focused review.
101 steps
RIOT/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c
Line 232 in 14fe8f2
Value not used when debug disabled.
RIOT/sys/net/gnrc/network_layer/ipv6/nib/nib.c
Line 442 in 14fe8f2
Is it finding that the branches using the values are not reachable ?
RIOT/sys/net/gnrc/network_layer/sixlowpan/gnrc_sixlowpan.c
Line 74 in 14fe8f2
Long path of pointers that could be said
__nonnull
.RIOT/sys/net/gnrc/network_layer/sixlowpan/iphc/gnrc_sixlowpan_iphc.c
Line 1007 in 14fe8f2
It is after a long long analysis. 400 lines function.
RIOT/sys/net/gnrc/sock/ip/gnrc_sock_ip.c
Line 174 in 14fe8f2
This really looks like a case where it is NULL, if I can understand
the number of branches.
RIOT/sys/net/routing/nhdp/iib_table.c
Line 717 in 14fe8f2
Use after free, this seems bad
RIOT/sys/net/sock/sock_util.c
Line 154 in 14fe8f2
Initialization could be removed it is never used.
RIOT/sys/posix/sockets/posix_sockets.c
Line 186 in 14fe8f2
Not correctly handled having invalid socket type for 'getsockname'
RIOT/sys/riotboot/flashwrite.c
Line 79 in 14fe8f2
Unused value
https:/github.com/RIOT-OS/RIOT/blob/14fe8f29e7c4aa424fce6f90fb598796b24fe063/sys/vfs/vfs_stdio.c#L61
Mulle usess
vfs
by default ?fd
is used only inassert
but look like disabled…Maybe need a
(void)fd
everytime ?RIOT/tests/fault_handler/main.c
Line 43 in 14fe8f2
https:/github.com/RIOT-OS/RIOT/blob/14fe8f29e7c4aa424fce6f90fb598796b24fe063/tests/gnrc_netif/common.c#L78
Condition looks like it should be
&&
instead of||
.https:/github.com/RIOT-OS/RIOT/blob/14fe8f29e7c4aa424fce6f90fb598796b24fe063/tests/malloc/main.c#L59
It assumes
malloc
can return null which is not handled.RIOT/tests/nanocoap_cli/nanocli_server.c
Line 67 in 14fe8f2
Value is obviously unused.
Some other "unused value" in tests.
...
Versions
2019.07-RC1
The text was updated successfully, but these errors were encountered: