[tor-bugs] #29805 [Core Tor/Tor]: 41 coverity defects on prob_distr.c
Tor Bug Tracker & Wiki
blackhole at torproject.org
Tue Mar 19 20:57:00 UTC 2019
#29805: 41 coverity defects on prob_distr.c
---------------------------------+------------------------------------
Reporter: asn | Owner: (none)
Type: defect | Status: new
Priority: Medium | Milestone: Tor: 0.4.1.x-final
Component: Core Tor/Tor | Version:
Severity: Normal | Resolution:
Keywords: prob-distr coverity | Actual Points:
Parent ID: | Points:
Reviewer: | Sponsor:
---------------------------------+------------------------------------
Comment (by catalyst):
Summarizing some analysis that asn and I did on IRC, plus some more
comments from me:
For the `DIST_BASE_TYPED` cases (not quoted here?), Coverity is apparently
complaining about the multiplication of an integer by the result of a
`sizeof` operator, which I think is possibly a helpful warning where the
integer is nonzero.
This appears to be a type-checking hack that functions by making a
compile-time assertion. The type checking works by subtracting `&(OBJ)`
and the same pointer cast to `const TYPE *`, which is a C constraint
violation if the types aren't the same. At a minimum, I think we should
move the type-checking hack to a helper macro, and document everything
better in comments.
Maybe directly adding the result of the pointer subtraction (which should
always be zero) will be enough to quiet Coverity. Discarding the
subtraction result by using a comma operator probably also works (if the
macro isn't used in a static initializer).
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/29805#comment:2>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
More information about the tor-bugs
mailing list