Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1315978 > unrolled thread

[PATCH] include/linux/list_bl.h: Use bool instead of int for boolean functions

Started bychengang@emindsoft.com.cn
First post2016-01-24 22:10 +0100
Last post2016-01-28 16:30 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] include/linux/list_bl.h: Use bool instead of int for boolean functions chengang@emindsoft.com.cn - 2016-01-24 22:10 +0100
    Re: [PATCH] include/linux/list_bl.h: Use bool instead of int for  boolean functions Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-01-28 08:30 +0100
      Re: [PATCH] include/linux/list_bl.h: Use bool instead of int for  boolean functions Chen Gang <chengang@emindsoft.com.cn> - 2016-01-28 16:30 +0100

#1315978 — [PATCH] include/linux/list_bl.h: Use bool instead of int for boolean functions

Fromchengang@emindsoft.com.cn
Date2016-01-24 22:10 +0100
Subject[PATCH] include/linux/list_bl.h: Use bool instead of int for boolean functions
Message-ID<qUA53-263-11@gated-at.bofh.it>
From: Chen Gang <chengang@emindsoft.com.cn>

hlist_bl_unhashed() and hlist_bl_empty() are all boolean functions, so
return bool instead of int.

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 include/linux/list_bl.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/list_bl.h b/include/linux/list_bl.h
index ee7229a..cb48330 100644
--- a/include/linux/list_bl.h
+++ b/include/linux/list_bl.h
@@ -48,7 +48,7 @@ static inline void INIT_HLIST_BL_NODE(struct hlist_bl_node *h)
 
 #define hlist_bl_entry(ptr, type, member) container_of(ptr,type,member)
 
-static inline int hlist_bl_unhashed(const struct hlist_bl_node *h)
+static inline bool  hlist_bl_unhashed(const struct hlist_bl_node *h)
 {
 	return !h->pprev;
 }
@@ -68,7 +68,7 @@ static inline void hlist_bl_set_first(struct hlist_bl_head *h,
 	h->first = (struct hlist_bl_node *)((unsigned long)n | LIST_BL_LOCKMASK);
 }
 
-static inline int hlist_bl_empty(const struct hlist_bl_head *h)
+static inline bool hlist_bl_empty(const struct hlist_bl_head *h)
 {
 	return !((unsigned long)READ_ONCE(h->first) & ~LIST_BL_LOCKMASK);
 }
-- 
1.9.3

[toc] | [next] | [standalone]


#1320370 — Re: [PATCH] include/linux/list_bl.h: Use bool instead of int for boolean functions

FromHeiko Carstens <heiko.carstens@de.ibm.com>
Date2016-01-28 08:30 +0100
SubjectRe: [PATCH] include/linux/list_bl.h: Use bool instead of int for boolean functions
Message-ID<qVPbI-8rA-17@gated-at.bofh.it>
In reply to#1315978
On Mon, Jan 25, 2016 at 04:58:18AM +0800, chengang@emindsoft.com.cn wrote:
> From: Chen Gang <chengang@emindsoft.com.cn>
> 
> hlist_bl_unhashed() and hlist_bl_empty() are all boolean functions, so
> return bool instead of int.
> 
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
>  include/linux/list_bl.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/list_bl.h b/include/linux/list_bl.h
> index ee7229a..cb48330 100644
> --- a/include/linux/list_bl.h
> +++ b/include/linux/list_bl.h
> @@ -48,7 +48,7 @@ static inline void INIT_HLIST_BL_NODE(struct hlist_bl_node *h)
>  
>  #define hlist_bl_entry(ptr, type, member) container_of(ptr,type,member)
>  
> -static inline int hlist_bl_unhashed(const struct hlist_bl_node *h)
> +static inline bool  hlist_bl_unhashed(const struct hlist_bl_node *h)
>  {
>  	return !h->pprev;
>  }
> @@ -68,7 +68,7 @@ static inline void hlist_bl_set_first(struct hlist_bl_head *h,
>  	h->first = (struct hlist_bl_node *)((unsigned long)n | LIST_BL_LOCKMASK);
>  }
>  
> -static inline int hlist_bl_empty(const struct hlist_bl_head *h)
> +static inline bool hlist_bl_empty(const struct hlist_bl_head *h)
>  {
>  	return !((unsigned long)READ_ONCE(h->first) & ~LIST_BL_LOCKMASK);

Sorry for my ignorance, but what's the point of doing conversions like
this? It has zero impact on code generation.

[toc] | [prev] | [next] | [standalone]


#1320786 — Re: [PATCH] include/linux/list_bl.h: Use bool instead of int for boolean functions

FromChen Gang <chengang@emindsoft.com.cn>
Date2016-01-28 16:30 +0100
SubjectRe: [PATCH] include/linux/list_bl.h: Use bool instead of int for boolean functions
Message-ID<qVWGe-5of-15@gated-at.bofh.it>
In reply to#1320370
On 1/28/16 15:22, Heiko Carstens wrote:
> On Mon, Jan 25, 2016 at 04:58:18AM +0800, chengang@emindsoft.com.cn wrote:
>> From: Chen Gang <chengang@emindsoft.com.cn>
>>
>> hlist_bl_unhashed() and hlist_bl_empty() are all boolean functions, so
>> return bool instead of int.
>>
>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>> ---
>>  include/linux/list_bl.h | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/linux/list_bl.h b/include/linux/list_bl.h
>> index ee7229a..cb48330 100644
>> --- a/include/linux/list_bl.h
>> +++ b/include/linux/list_bl.h
>> @@ -48,7 +48,7 @@ static inline void INIT_HLIST_BL_NODE(struct hlist_bl_node *h)
>>  
>>  #define hlist_bl_entry(ptr, type, member) container_of(ptr,type,member)
>>  
>> -static inline int hlist_bl_unhashed(const struct hlist_bl_node *h)
>> +static inline bool  hlist_bl_unhashed(const struct hlist_bl_node *h)
>>  {
>>  	return !h->pprev;
>>  }
>> @@ -68,7 +68,7 @@ static inline void hlist_bl_set_first(struct hlist_bl_head *h,
>>  	h->first = (struct hlist_bl_node *)((unsigned long)n | LIST_BL_LOCKMASK);
>>  }
>>  
>> -static inline int hlist_bl_empty(const struct hlist_bl_head *h)
>> +static inline bool hlist_bl_empty(const struct hlist_bl_head *h)
>>  {
>>  	return !((unsigned long)READ_ONCE(h->first) & ~LIST_BL_LOCKMASK);
> 
> Sorry for my ignorance, but what's the point of doing conversions like
> this? It has zero impact on code generation.
> 

For me, in our case, the 2 functions really generate boolean value, and
they are really used as boolean functions, so returning boolean value
will let the code a little simpler and a little clearer.


Thanks.
-- 
Chen Gang (陈刚)

Open, share, and attitude like air, water, and life which God blessed

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web