[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] RFC xen: suppress Coverity warnings about atomic_read and atomic_set.
Coverity generates false positives when read_atomic() and write_atomic() are called with pointers to objects smaller than 64 bits (because it can't see that the 64-bit access in the switych statement is dead code). I don't want to automatically suppress all ofthose, because read_atomic() and write_atomic() could still be called with mis-cast pointers, but for atomic_t accessors it's pretty clealry always safe. RFC because I'm not sure what people think about scattering coverity annotations in the code. Signed-off-by: Tim Deegan <tim@xxxxxxx> --- xen/include/asm-x86/atomic.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xen/include/asm-x86/atomic.h b/xen/include/asm-x86/atomic.h index e476ab5..cfa3f66 100644 --- a/xen/include/asm-x86/atomic.h +++ b/xen/include/asm-x86/atomic.h @@ -70,7 +70,11 @@ typedef struct { int counter; } atomic_t; * Atomically reads the value of @v. */ #define _atomic_read(v) ((v).counter) -#define atomic_read(v) read_atomic(&((v)->counter)) +static inline int atomic_read(atomic_t *v) +{ + /* coverity[incompatible_cast : FALSE] */ + return read_atomic(&v->counter); +} /** * atomic_set - set atomic variable @@ -80,7 +84,11 @@ typedef struct { int counter; } atomic_t; * Atomically sets the value of @v to @i. */ #define _atomic_set(v,i) (((v).counter) = (i)) -#define atomic_set(v,i) write_atomic(&((v)->counter), (i)) +static inline void atomic_set(atomic_t *v, int i) +{ + /* coverity[incompatible_cast : FALSE] */ + write_atomic(&v->counter, i); +} /** * atomic_add - add integer to atomic variable -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |