archlinuxfr / package-query

Query alpm database and AUR
69 stars 17 forks source link

Fix clang static analyzer warning #137

Closed larchunix closed 6 years ago

larchunix commented 6 years ago

A possible use of NULL pointer has been identified by clang static analyzer:

../src/util.c:809:8: warning: Null pointer passed as an argument to a 'nonnull' parameter
                        if (strcmp (ver, lver) != 0) {
                            ^~~~~~~~~~~~~~~~~~
1 warning generated.

Add a NULL pointer check to fix the warning.

f2404 commented 6 years ago

Merged, thanks!

larchunix commented 6 years ago

On second thought, maybe a better fix was to add the check later like this:

if (lver) {
    if (info && strcmp (info, "local") != 0) {
        ....
        if (ver && strcmp (ver, lver) != 0) {
            printf ( ... )
        }
    }
}
f2404 commented 6 years ago

Yeah, that would probably be better.

larchunix commented 6 years ago

@f2404 would you mind pushing a fix or do you prefer a new PR ?

f2404 commented 6 years ago

I can fix it myself. Thanks again!