]> granicus.if.org Git - transmission/commit
fix: Coverity warnings (#842)
authorCharles Kerr <ckerr@github.com>
Mon, 18 Feb 2019 22:38:24 +0000 (22:38 +0000)
committerGitHub <noreply@github.com>
Mon, 18 Feb 2019 22:38:24 +0000 (22:38 +0000)
commit309d97c57849407b3bdc275364c4ae29200f81bb
tree12d70dde52c05d0138c9b4f37da30e9fc9379550
parent3ba0b9df150ff92a3afeb626e19d1e2cdc0690ca
fix: Coverity warnings (#842)

* Silence coverity CHECKED_RETURN on added.f load

The existing code behaved alright since added.f is optional.
However, by testing for success we can both silence the warning
and prevent a useless initialization of NULL/0 to added_f and
added_f_length.

* Silence coverity CHECKED_RETURN on added6.f load

ipv6 variant of previous commit.

* Silence coverity CHECKED_RETURN writing benc strs

saveStringFunc() gets the target string by calling tr_variantGetStr().
It previously didn't check to see if this function succeeded because
saveStringFunc() isn't reached without the type already being known.
However, checking the return value costs nothing and makes Coverity happy.

* Silence coverity CHECKED_RETURN on ut metadata

Like earlier few Coverity commits in this PR, we're handling optional
values by declaring stack locals set to the default (e.g. -1) and then
trying to read the variant.

Unlike the earlier commits, there is a two-part step to thise read:
checking for the metadata, then checking for the individual fields.
The earlier fixes' aproach -- e.g. initializing to -1 only if the reads
failed -- would involve new nested conditionals. I find the new complexity
to outweigh the benefit of removing the dead store, so in this case I'm
casting the return value to `(void)` to tell Coverity to shush.

* Silence coverity CHECKED_RETURN on scrape

Check the return value of tr_variantGetInt() when showing
seeder and leecher counts in transmission-show.

* Silence CHECKED_RETURN on rpc recently-active

When building a list of removed torrent IDs from variants, confirm that
we can read the IDs from the variants before adding them to the list.
I don't _think_ this would have failed before, but Coverity's right that
it's reasonable to add a safeguard here.

* fix: better fix to serializing benc strings

The approach in 33e2ece7e5bc261566ae9e8db57be0b3247508d1 was
a little problematic: GetString() shouldn't fail here; but if
it somehow did, we still want to encode a zero-length benc string here.

* chore: make uncrustify happy
libtransmission/peer-msgs.c
libtransmission/rpcimpl.c
libtransmission/variant-benc.c
utils/show.c