Commit e0bf1024 authored by Huang Ying's avatar Huang Ying Committed by Linus Torvalds

kfifo: add parenthesis for macro parameter reference

Some macro parameter references inside typeof() operator are not enclosed
with parenthesis.  It should be safer to add them.
Signed-off-by: default avatarHuang Ying <ying.huang@intel.com>
Acked-by: default avatarStefani Seibold <stefani@seibold.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f3c65b28
...@@ -214,7 +214,7 @@ __kfifo_must_check_helper(unsigned int val) ...@@ -214,7 +214,7 @@ __kfifo_must_check_helper(unsigned int val)
*/ */
#define kfifo_reset(fifo) \ #define kfifo_reset(fifo) \
(void)({ \ (void)({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
__tmp->kfifo.in = __tmp->kfifo.out = 0; \ __tmp->kfifo.in = __tmp->kfifo.out = 0; \
}) })
...@@ -228,7 +228,7 @@ __kfifo_must_check_helper(unsigned int val) ...@@ -228,7 +228,7 @@ __kfifo_must_check_helper(unsigned int val)
*/ */
#define kfifo_reset_out(fifo) \ #define kfifo_reset_out(fifo) \
(void)({ \ (void)({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
__tmp->kfifo.out = __tmp->kfifo.in; \ __tmp->kfifo.out = __tmp->kfifo.in; \
}) })
...@@ -238,7 +238,7 @@ __kfifo_must_check_helper(unsigned int val) ...@@ -238,7 +238,7 @@ __kfifo_must_check_helper(unsigned int val)
*/ */
#define kfifo_len(fifo) \ #define kfifo_len(fifo) \
({ \ ({ \
typeof(fifo + 1) __tmpl = (fifo); \ typeof((fifo) + 1) __tmpl = (fifo); \
__tmpl->kfifo.in - __tmpl->kfifo.out; \ __tmpl->kfifo.in - __tmpl->kfifo.out; \
}) })
...@@ -248,7 +248,7 @@ __kfifo_must_check_helper(unsigned int val) ...@@ -248,7 +248,7 @@ __kfifo_must_check_helper(unsigned int val)
*/ */
#define kfifo_is_empty(fifo) \ #define kfifo_is_empty(fifo) \
({ \ ({ \
typeof(fifo + 1) __tmpq = (fifo); \ typeof((fifo) + 1) __tmpq = (fifo); \
__tmpq->kfifo.in == __tmpq->kfifo.out; \ __tmpq->kfifo.in == __tmpq->kfifo.out; \
}) })
...@@ -258,7 +258,7 @@ __kfifo_must_check_helper(unsigned int val) ...@@ -258,7 +258,7 @@ __kfifo_must_check_helper(unsigned int val)
*/ */
#define kfifo_is_full(fifo) \ #define kfifo_is_full(fifo) \
({ \ ({ \
typeof(fifo + 1) __tmpq = (fifo); \ typeof((fifo) + 1) __tmpq = (fifo); \
kfifo_len(__tmpq) > __tmpq->kfifo.mask; \ kfifo_len(__tmpq) > __tmpq->kfifo.mask; \
}) })
...@@ -269,7 +269,7 @@ __kfifo_must_check_helper(unsigned int val) ...@@ -269,7 +269,7 @@ __kfifo_must_check_helper(unsigned int val)
#define kfifo_avail(fifo) \ #define kfifo_avail(fifo) \
__kfifo_must_check_helper( \ __kfifo_must_check_helper( \
({ \ ({ \
typeof(fifo + 1) __tmpq = (fifo); \ typeof((fifo) + 1) __tmpq = (fifo); \
const size_t __recsize = sizeof(*__tmpq->rectype); \ const size_t __recsize = sizeof(*__tmpq->rectype); \
unsigned int __avail = kfifo_size(__tmpq) - kfifo_len(__tmpq); \ unsigned int __avail = kfifo_size(__tmpq) - kfifo_len(__tmpq); \
(__recsize) ? ((__avail <= __recsize) ? 0 : \ (__recsize) ? ((__avail <= __recsize) ? 0 : \
...@@ -284,7 +284,7 @@ __kfifo_must_check_helper( \ ...@@ -284,7 +284,7 @@ __kfifo_must_check_helper( \
*/ */
#define kfifo_skip(fifo) \ #define kfifo_skip(fifo) \
(void)({ \ (void)({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
const size_t __recsize = sizeof(*__tmp->rectype); \ const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \ struct __kfifo *__kfifo = &__tmp->kfifo; \
if (__recsize) \ if (__recsize) \
...@@ -302,7 +302,7 @@ __kfifo_must_check_helper( \ ...@@ -302,7 +302,7 @@ __kfifo_must_check_helper( \
#define kfifo_peek_len(fifo) \ #define kfifo_peek_len(fifo) \
__kfifo_must_check_helper( \ __kfifo_must_check_helper( \
({ \ ({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
const size_t __recsize = sizeof(*__tmp->rectype); \ const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \ struct __kfifo *__kfifo = &__tmp->kfifo; \
(!__recsize) ? kfifo_len(__tmp) * sizeof(*__tmp->type) : \ (!__recsize) ? kfifo_len(__tmp) * sizeof(*__tmp->type) : \
...@@ -325,7 +325,7 @@ __kfifo_must_check_helper( \ ...@@ -325,7 +325,7 @@ __kfifo_must_check_helper( \
#define kfifo_alloc(fifo, size, gfp_mask) \ #define kfifo_alloc(fifo, size, gfp_mask) \
__kfifo_must_check_helper( \ __kfifo_must_check_helper( \
({ \ ({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
struct __kfifo *__kfifo = &__tmp->kfifo; \ struct __kfifo *__kfifo = &__tmp->kfifo; \
__is_kfifo_ptr(__tmp) ? \ __is_kfifo_ptr(__tmp) ? \
__kfifo_alloc(__kfifo, size, sizeof(*__tmp->type), gfp_mask) : \ __kfifo_alloc(__kfifo, size, sizeof(*__tmp->type), gfp_mask) : \
...@@ -339,7 +339,7 @@ __kfifo_must_check_helper( \ ...@@ -339,7 +339,7 @@ __kfifo_must_check_helper( \
*/ */
#define kfifo_free(fifo) \ #define kfifo_free(fifo) \
({ \ ({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
struct __kfifo *__kfifo = &__tmp->kfifo; \ struct __kfifo *__kfifo = &__tmp->kfifo; \
if (__is_kfifo_ptr(__tmp)) \ if (__is_kfifo_ptr(__tmp)) \
__kfifo_free(__kfifo); \ __kfifo_free(__kfifo); \
...@@ -358,7 +358,7 @@ __kfifo_must_check_helper( \ ...@@ -358,7 +358,7 @@ __kfifo_must_check_helper( \
*/ */
#define kfifo_init(fifo, buffer, size) \ #define kfifo_init(fifo, buffer, size) \
({ \ ({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
struct __kfifo *__kfifo = &__tmp->kfifo; \ struct __kfifo *__kfifo = &__tmp->kfifo; \
__is_kfifo_ptr(__tmp) ? \ __is_kfifo_ptr(__tmp) ? \
__kfifo_init(__kfifo, buffer, size, sizeof(*__tmp->type)) : \ __kfifo_init(__kfifo, buffer, size, sizeof(*__tmp->type)) : \
...@@ -379,8 +379,8 @@ __kfifo_must_check_helper( \ ...@@ -379,8 +379,8 @@ __kfifo_must_check_helper( \
*/ */
#define kfifo_put(fifo, val) \ #define kfifo_put(fifo, val) \
({ \ ({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
typeof(val + 1) __val = (val); \ typeof((val) + 1) __val = (val); \
unsigned int __ret; \ unsigned int __ret; \
const size_t __recsize = sizeof(*__tmp->rectype); \ const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \ struct __kfifo *__kfifo = &__tmp->kfifo; \
...@@ -421,8 +421,8 @@ __kfifo_must_check_helper( \ ...@@ -421,8 +421,8 @@ __kfifo_must_check_helper( \
#define kfifo_get(fifo, val) \ #define kfifo_get(fifo, val) \
__kfifo_must_check_helper( \ __kfifo_must_check_helper( \
({ \ ({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
typeof(val + 1) __val = (val); \ typeof((val) + 1) __val = (val); \
unsigned int __ret; \ unsigned int __ret; \
const size_t __recsize = sizeof(*__tmp->rectype); \ const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \ struct __kfifo *__kfifo = &__tmp->kfifo; \
...@@ -462,8 +462,8 @@ __kfifo_must_check_helper( \ ...@@ -462,8 +462,8 @@ __kfifo_must_check_helper( \
#define kfifo_peek(fifo, val) \ #define kfifo_peek(fifo, val) \
__kfifo_must_check_helper( \ __kfifo_must_check_helper( \
({ \ ({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
typeof(val + 1) __val = (val); \ typeof((val) + 1) __val = (val); \
unsigned int __ret; \ unsigned int __ret; \
const size_t __recsize = sizeof(*__tmp->rectype); \ const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \ struct __kfifo *__kfifo = &__tmp->kfifo; \
...@@ -501,8 +501,8 @@ __kfifo_must_check_helper( \ ...@@ -501,8 +501,8 @@ __kfifo_must_check_helper( \
*/ */
#define kfifo_in(fifo, buf, n) \ #define kfifo_in(fifo, buf, n) \
({ \ ({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
typeof(buf + 1) __buf = (buf); \ typeof((buf) + 1) __buf = (buf); \
unsigned long __n = (n); \ unsigned long __n = (n); \
const size_t __recsize = sizeof(*__tmp->rectype); \ const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \ struct __kfifo *__kfifo = &__tmp->kfifo; \
...@@ -554,8 +554,8 @@ __kfifo_must_check_helper( \ ...@@ -554,8 +554,8 @@ __kfifo_must_check_helper( \
#define kfifo_out(fifo, buf, n) \ #define kfifo_out(fifo, buf, n) \
__kfifo_must_check_helper( \ __kfifo_must_check_helper( \
({ \ ({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
typeof(buf + 1) __buf = (buf); \ typeof((buf) + 1) __buf = (buf); \
unsigned long __n = (n); \ unsigned long __n = (n); \
const size_t __recsize = sizeof(*__tmp->rectype); \ const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \ struct __kfifo *__kfifo = &__tmp->kfifo; \
...@@ -611,7 +611,7 @@ __kfifo_must_check_helper( \ ...@@ -611,7 +611,7 @@ __kfifo_must_check_helper( \
#define kfifo_from_user(fifo, from, len, copied) \ #define kfifo_from_user(fifo, from, len, copied) \
__kfifo_must_check_helper( \ __kfifo_must_check_helper( \
({ \ ({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
const void __user *__from = (from); \ const void __user *__from = (from); \
unsigned int __len = (len); \ unsigned int __len = (len); \
unsigned int *__copied = (copied); \ unsigned int *__copied = (copied); \
...@@ -639,7 +639,7 @@ __kfifo_must_check_helper( \ ...@@ -639,7 +639,7 @@ __kfifo_must_check_helper( \
#define kfifo_to_user(fifo, to, len, copied) \ #define kfifo_to_user(fifo, to, len, copied) \
__kfifo_must_check_helper( \ __kfifo_must_check_helper( \
({ \ ({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
void __user *__to = (to); \ void __user *__to = (to); \
unsigned int __len = (len); \ unsigned int __len = (len); \
unsigned int *__copied = (copied); \ unsigned int *__copied = (copied); \
...@@ -666,7 +666,7 @@ __kfifo_must_check_helper( \ ...@@ -666,7 +666,7 @@ __kfifo_must_check_helper( \
*/ */
#define kfifo_dma_in_prepare(fifo, sgl, nents, len) \ #define kfifo_dma_in_prepare(fifo, sgl, nents, len) \
({ \ ({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
struct scatterlist *__sgl = (sgl); \ struct scatterlist *__sgl = (sgl); \
int __nents = (nents); \ int __nents = (nents); \
unsigned int __len = (len); \ unsigned int __len = (len); \
...@@ -690,7 +690,7 @@ __kfifo_must_check_helper( \ ...@@ -690,7 +690,7 @@ __kfifo_must_check_helper( \
*/ */
#define kfifo_dma_in_finish(fifo, len) \ #define kfifo_dma_in_finish(fifo, len) \
(void)({ \ (void)({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
unsigned int __len = (len); \ unsigned int __len = (len); \
const size_t __recsize = sizeof(*__tmp->rectype); \ const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \ struct __kfifo *__kfifo = &__tmp->kfifo; \
...@@ -717,7 +717,7 @@ __kfifo_must_check_helper( \ ...@@ -717,7 +717,7 @@ __kfifo_must_check_helper( \
*/ */
#define kfifo_dma_out_prepare(fifo, sgl, nents, len) \ #define kfifo_dma_out_prepare(fifo, sgl, nents, len) \
({ \ ({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
struct scatterlist *__sgl = (sgl); \ struct scatterlist *__sgl = (sgl); \
int __nents = (nents); \ int __nents = (nents); \
unsigned int __len = (len); \ unsigned int __len = (len); \
...@@ -741,7 +741,7 @@ __kfifo_must_check_helper( \ ...@@ -741,7 +741,7 @@ __kfifo_must_check_helper( \
*/ */
#define kfifo_dma_out_finish(fifo, len) \ #define kfifo_dma_out_finish(fifo, len) \
(void)({ \ (void)({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
unsigned int __len = (len); \ unsigned int __len = (len); \
const size_t __recsize = sizeof(*__tmp->rectype); \ const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \ struct __kfifo *__kfifo = &__tmp->kfifo; \
...@@ -766,8 +766,8 @@ __kfifo_must_check_helper( \ ...@@ -766,8 +766,8 @@ __kfifo_must_check_helper( \
#define kfifo_out_peek(fifo, buf, n) \ #define kfifo_out_peek(fifo, buf, n) \
__kfifo_must_check_helper( \ __kfifo_must_check_helper( \
({ \ ({ \
typeof(fifo + 1) __tmp = (fifo); \ typeof((fifo) + 1) __tmp = (fifo); \
typeof(buf + 1) __buf = (buf); \ typeof((buf) + 1) __buf = (buf); \
unsigned long __n = (n); \ unsigned long __n = (n); \
const size_t __recsize = sizeof(*__tmp->rectype); \ const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \ struct __kfifo *__kfifo = &__tmp->kfifo; \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment