kfifo: fix sparse complaints
authorStefani Seibold <[email protected]>
Tue, 22 Mar 2016 21:27:42 +0000 (14:27 -0700)
committerLinus Torvalds <[email protected]>
Tue, 22 Mar 2016 22:36:02 +0000 (15:36 -0700)
This patch fix complaints by the sparse tool when using kfifo_put() with
non scalar types like structures (i.e.
drivers/iio/industrialio-event.c).

Casting a pointer to the value and read this pointer instead of directly
casting the value will fix this.

The generated code is equal.

Signed-off-by: Stefani Seibold <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/kfifo.h

index 473b43678ad12ef360801ffd9e32594285efd41a..41eb6fdf87a84d05ae43bfd769943a89abb47d98 100644 (file)
@@ -401,7 +401,7 @@ __kfifo_int_must_check_helper( \
                        ((typeof(__tmp->type))__kfifo->data) : \
                        (__tmp->buf) \
                        )[__kfifo->in & __tmp->kfifo.mask] = \
-                               (typeof(*__tmp->type))__val; \
+                               *(typeof(__tmp->type))&__val; \
                        smp_wmb(); \
                        __kfifo->in++; \
                } \