]> sigrok.org Git - libsigrok.git/commit
motech-lps-30x: fix several compiler warnings
authorGerhard Sittig <redacted>
Fri, 9 Feb 2018 18:17:13 +0000 (19:17 +0100)
committerUwe Hermann <redacted>
Fri, 9 Feb 2018 20:37:39 +0000 (21:37 +0100)
commite4924d752b3a2e08d0ab90b0eb872c569c4c68c9
tree197f88c14a096ee706756c3e61e32747f19faf20
parentfe535a89c9b8dfceeb7706c71af5aad7f6dcda26
motech-lps-30x: fix several compiler warnings

Check pointers' validity before dereferencing them. Explicitly assign a
default value to variables, before conversion routines conditionally
assign the "real" value (and don't in case of conversion errors). This
avoids processing "garbage" data.

Strictly speaking I cannot see how the conversion routine returns OK and
has _not_ assigned a result. But the explicit assignment won't harm
either, and matches the fallback when the conversion fails (detectibly).
Which means that runtime behaviour won't change.

This was reported by clang's scan-build.
src/hardware/motech-lps-30x/api.c
src/hardware/motech-lps-30x/protocol.c