Skip to content

Fix some issues discovered by static analysis

Jan Tojnar requested to merge wip/jtojnar/clang-analysis into master

Running ninja -C _build/ scan-build, I now get:

  • This appears to be a false positive (_fr_process_start clears out the exec_data->error field so the branch containing the if can only be entered when waitpid that assigns status is run):

    ../../../src/fr-process.c:851:7: warning: The left operand of '&' is a garbage value [core.UndefinedBinaryOperatorResult]
                    if (WIFEXITED (status)) {
                        ^          ~~~~~~
    /nix/store/p5vg4rdba95snvxd7p0km695jnm8vvwh-glibc-2.35-163-dev/include/stdlib.h:47:28: note: expanded from macro 'WIFEXITED'
    # define WIFEXITED(status)      __WIFEXITED (status)
                                    ^            ~~~~~~
    /nix/store/p5vg4rdba95snvxd7p0km695jnm8vvwh-glibc-2.35-163-dev/include/bits/waitstatus.h:37:30: note: expanded from macro '__WIFEXITED'
    #define __WIFEXITED(status)     (__WTERMSIG(status) == 0)
                                     ^          ~~~~~~
    /nix/store/p5vg4rdba95snvxd7p0km695jnm8vvwh-glibc-2.35-163-dev/include/bits/waitstatus.h:31:38: note: expanded from macro '__WTERMSIG'
    #define __WTERMSIG(status)      ((status) & 0x7f)
                                      ~~~~~~  ^
  • Need to investigate

    ../../../src/glib-utils.c:663:26: warning: The left operand of '!=' is a garbage value [core.UndefinedBinaryOperatorResult]
            for (i = 0; patterns[i] != NULL; i++) {
                        ~~~~~~~~~~~ ^
  • This is correct, we need to handle the errors as in the example:

    ../../../src/fr-archive-libarchive.c:1604:2: warning: Value stored to 'rb' is never read [deadcode.DeadStores]
            rb = archive_write_header (b, w_entry);
            ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../../src/fr-archive-libarchive.c:1696:4: warning: Value stored to 'rb' is never read [deadcode.DeadStores]
                            rb = archive_write_finish_entry (b);
                            ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Edited by Jan Tojnar

Merge request reports