* [PATCH] Replace the type check code with typecheck() in kfifo_in
@ 2012-10-24 3:41 Wei Yang
2012-10-24 5:43 ` Stefani Seibold
2012-10-24 7:33 ` richard -rw- weinberger
0 siblings, 2 replies; 3+ messages in thread
From: Wei Yang @ 2012-10-24 3:41 UTC (permalink / raw)
To: akpm, richard.weinberger, jkosina, stefani, linux-kernel; +Cc: Wei Yang
In kfifo_in marco, one piece of code which is arounded by if(0) will check the
type of __tmp->ptr_const and __buf. If they are different type, there will
output a warning during compiling. This piece of code is not self explaining
and a little bit hard to understand.
Based on Andrew Morton's suggestion, this patch replace this with typecheck()
which will be easy to understand.
In the same file, there are several places with the same code style. This
patch change them too.
Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: richard -rw- weinberger <richard.weinberger@gmail.com>
---
include/linux/kfifo.h | 22 +++++-----------------
1 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 10308c6..680c293 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -390,10 +390,7 @@ __kfifo_int_must_check_helper( \
unsigned int __ret; \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
- if (0) { \
- typeof(__tmp->ptr_const) __dummy __attribute__ ((unused)); \
- __dummy = (typeof(__val))NULL; \
- } \
+ typecheck(typeof(__tmp->ptr_const), __val); \
if (__recsize) \
__ret = __kfifo_in_r(__kfifo, __val, sizeof(*__val), \
__recsize); \
@@ -433,7 +430,7 @@ __kfifo_uint_must_check_helper( \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
if (0) \
- __val = (typeof(__tmp->ptr))0; \
+ __val = (typeof(__tmp->ptr))NULL; \
if (__recsize) \
__ret = __kfifo_out_r(__kfifo, __val, sizeof(*__val), \
__recsize); \
@@ -512,10 +509,7 @@ __kfifo_uint_must_check_helper( \
unsigned long __n = (n); \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
- if (0) { \
- typeof(__tmp->ptr_const) __dummy __attribute__ ((unused)); \
- __dummy = (typeof(__buf))NULL; \
- } \
+ typecheck(typeof(__tmp->ptr_const), __buf);\
(__recsize) ?\
__kfifo_in_r(__kfifo, __buf, __n, __recsize) : \
__kfifo_in(__kfifo, __buf, __n); \
@@ -565,10 +559,7 @@ __kfifo_uint_must_check_helper( \
unsigned long __n = (n); \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
- if (0) { \
- typeof(__tmp->ptr) __dummy = NULL; \
- __buf = __dummy; \
- } \
+ typecheck(typeof(__tmp->ptr), __buf); \
(__recsize) ?\
__kfifo_out_r(__kfifo, __buf, __n, __recsize) : \
__kfifo_out(__kfifo, __buf, __n); \
@@ -777,10 +768,7 @@ __kfifo_uint_must_check_helper( \
unsigned long __n = (n); \
const size_t __recsize = sizeof(*__tmp->rectype); \
struct __kfifo *__kfifo = &__tmp->kfifo; \
- if (0) { \
- typeof(__tmp->ptr) __dummy __attribute__ ((unused)) = NULL; \
- __buf = __dummy; \
- } \
+ typecheck(typeof(__tmp->ptr), __buf); \
(__recsize) ? \
__kfifo_out_peek_r(__kfifo, __buf, __n, __recsize) : \
__kfifo_out_peek(__kfifo, __buf, __n); \
--
1.7.5.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Replace the type check code with typecheck() in kfifo_in
2012-10-24 3:41 [PATCH] Replace the type check code with typecheck() in kfifo_in Wei Yang
@ 2012-10-24 5:43 ` Stefani Seibold
2012-10-24 7:33 ` richard -rw- weinberger
1 sibling, 0 replies; 3+ messages in thread
From: Stefani Seibold @ 2012-10-24 5:43 UTC (permalink / raw)
To: Wei Yang; +Cc: akpm, richard.weinberger, jkosina, linux-kernel
Am Mittwoch, den 24.10.2012, 11:41 +0800 schrieb Wei Yang:
> In kfifo_in marco, one piece of code which is arounded by if(0) will check the
> type of __tmp->ptr_const and __buf. If they are different type, there will
> output a warning during compiling. This piece of code is not self explaining
> and a little bit hard to understand.
>
> Based on Andrew Morton's suggestion, this patch replace this with typecheck()
> which will be easy to understand.
>
> In the same file, there are several places with the same code style. This
> patch change them too.
>
> Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
> Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
> Reviewed-by: richard -rw- weinberger <richard.weinberger@gmail.com>
> ---
> include/linux/kfifo.h | 22 +++++-----------------
> 1 files changed, 5 insertions(+), 17 deletions(-)
>
> diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
> index 10308c6..680c293 100644
> --- a/include/linux/kfifo.h
> +++ b/include/linux/kfifo.h
> @@ -390,10 +390,7 @@ __kfifo_int_must_check_helper( \
> unsigned int __ret; \
> const size_t __recsize = sizeof(*__tmp->rectype); \
> struct __kfifo *__kfifo = &__tmp->kfifo; \
> - if (0) { \
> - typeof(__tmp->ptr_const) __dummy __attribute__ ((unused)); \
> - __dummy = (typeof(__val))NULL; \
> - } \
> + typecheck(typeof(__tmp->ptr_const), __val); \
> if (__recsize) \
> __ret = __kfifo_in_r(__kfifo, __val, sizeof(*__val), \
> __recsize); \
> @@ -433,7 +430,7 @@ __kfifo_uint_must_check_helper( \
> const size_t __recsize = sizeof(*__tmp->rectype); \
> struct __kfifo *__kfifo = &__tmp->kfifo; \
> if (0) \
> - __val = (typeof(__tmp->ptr))0; \
> + __val = (typeof(__tmp->ptr))NULL; \
> if (__recsize) \
> __ret = __kfifo_out_r(__kfifo, __val, sizeof(*__val), \
> __recsize); \
> @@ -512,10 +509,7 @@ __kfifo_uint_must_check_helper( \
> unsigned long __n = (n); \
> const size_t __recsize = sizeof(*__tmp->rectype); \
> struct __kfifo *__kfifo = &__tmp->kfifo; \
> - if (0) { \
> - typeof(__tmp->ptr_const) __dummy __attribute__ ((unused)); \
> - __dummy = (typeof(__buf))NULL; \
> - } \
> + typecheck(typeof(__tmp->ptr_const), __buf);\
> (__recsize) ?\
> __kfifo_in_r(__kfifo, __buf, __n, __recsize) : \
> __kfifo_in(__kfifo, __buf, __n); \
> @@ -565,10 +559,7 @@ __kfifo_uint_must_check_helper( \
> unsigned long __n = (n); \
> const size_t __recsize = sizeof(*__tmp->rectype); \
> struct __kfifo *__kfifo = &__tmp->kfifo; \
> - if (0) { \
> - typeof(__tmp->ptr) __dummy = NULL; \
> - __buf = __dummy; \
> - } \
> + typecheck(typeof(__tmp->ptr), __buf); \
> (__recsize) ?\
> __kfifo_out_r(__kfifo, __buf, __n, __recsize) : \
> __kfifo_out(__kfifo, __buf, __n); \
> @@ -777,10 +768,7 @@ __kfifo_uint_must_check_helper( \
> unsigned long __n = (n); \
> const size_t __recsize = sizeof(*__tmp->rectype); \
> struct __kfifo *__kfifo = &__tmp->kfifo; \
> - if (0) { \
> - typeof(__tmp->ptr) __dummy __attribute__ ((unused)) = NULL; \
> - __buf = __dummy; \
> - } \
> + typecheck(typeof(__tmp->ptr), __buf); \
> (__recsize) ? \
> __kfifo_out_peek_r(__kfifo, __buf, __n, __recsize) : \
> __kfifo_out_peek(__kfifo, __buf, __n); \
Acked-by: Stefani Seibold <stefani@seibold.net>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Replace the type check code with typecheck() in kfifo_in
2012-10-24 3:41 [PATCH] Replace the type check code with typecheck() in kfifo_in Wei Yang
2012-10-24 5:43 ` Stefani Seibold
@ 2012-10-24 7:33 ` richard -rw- weinberger
1 sibling, 0 replies; 3+ messages in thread
From: richard -rw- weinberger @ 2012-10-24 7:33 UTC (permalink / raw)
To: Wei Yang; +Cc: akpm, jkosina, stefani, linux-kernel
On Wed, Oct 24, 2012 at 5:41 AM, Wei Yang <weiyang@linux.vnet.ibm.com> wrote:
> Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
> Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
> Reviewed-by: richard -rw- weinberger <richard.weinberger@gmail.com>
I did *not* review this patch, nor did Andrew.
--
Thanks,
//richard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-10-24 7:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-24 3:41 [PATCH] Replace the type check code with typecheck() in kfifo_in Wei Yang
2012-10-24 5:43 ` Stefani Seibold
2012-10-24 7:33 ` richard -rw- weinberger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).