[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-bugs] #29805 [Core Tor/Tor]: 41 coverity defects on prob_distr.c



#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 riastradh):

 You correctly ascertained that the goal of this apparently sketchy
 business is to check that in `container_of(P, T, F)`, the type `T` has a
 field `F` of the same type as `*P`.  I don't think there's any undefined
 behaviour here.

 The type check is already factored into a separate macro, precisely
 because of this issue with Coverity.  In NetBSD we have the following
 `#ifdef __COVERITY__` to suppress this noise:
 https://nxr.netbsd.org/xref/src/sys/lib/libkern/libkern.h#339

 {{{
 #ifdef __COVERITY___
 #define validate_container_of(P, T, F) 0
 #else
 #define validate_container_of(P, T, F) ...as before...
 #endif
 }}}

 We considered various other workarounds but, e.g., discarding the result
 with a comma led to non-Coverity compiler warnings, so we settled on an
 #ifdef.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/29805#comment:3>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs