]> sigrok.org Git - libsigrok.git/commit
uni-t-ut181a: silence compiler warning, use of uninitialized variable
authorGerhard Sittig <redacted>
Wed, 22 Dec 2021 13:12:31 +0000 (14:12 +0100)
committerGerhard Sittig <redacted>
Wed, 22 Dec 2021 19:06:02 +0000 (20:06 +0100)
commitdeb7615262ac4f9cc0750a08351afa7cbf9c34d5
treed79a86422d2bbc83dc808709e72aadd2a7ffcbaa
parent672a5e8ffbbba0ec0f8996a4e90fec04afaadd8f
uni-t-ut181a: silence compiler warning, use of uninitialized variable

The ut181a driver's acquisition start routine may face a previously
unknown data source value, which is potentially unhandled when the
source code becomes inconsistent during maintenance. Add a default
case to handle the condition, which silences a compiler warning.

    src/hardware/uni-t-ut181a/api.c:505:13: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
            } else if (devc->data_source >= DATA_SOURCE_REC_FIRST) {
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/hardware/uni-t-ut181a/api.c:536:6: note: uninitialized use occurs here
            if (ret < 0)
                ^~~
    src/hardware/uni-t-ut181a/api.c:505:9: note: remove the 'if' if its condition is always true
            } else if (devc->data_source >= DATA_SOURCE_REC_FIRST) {
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/hardware/uni-t-ut181a/api.c:467:9: note: initialize the variable 'ret' to silence this warning
            int ret;
                   ^
                    = 0
src/hardware/uni-t-ut181a/api.c