* Re: [PATCH 1/1] workqueue: use type int instead of bool to index array [not found] ` <20170906143320.GK1774378@devbig577.frc2.facebook.com> @ 2017-09-06 16:04 ` zijun_hu 2017-09-06 16:40 ` Tejun Heo 0 siblings, 1 reply; 4+ messages in thread From: zijun_hu @ 2017-09-06 16:04 UTC (permalink / raw) To: Tejun Heo; +Cc: zijun_hu, linux-mm, linux-kernel, Andrew Morton, jiangshanlai On 2017/9/6 22:33, Tejun Heo wrote: > Hello, > > On Wed, Sep 06, 2017 at 11:34:14AM +0800, zijun_hu wrote: >> From: zijun_hu <zijun_hu@htc.com> >> >> type bool is used to index three arrays in alloc_and_link_pwqs() >> it doesn't look like conventional. >> >> it is fixed by using type int to index the relevant arrays. > > bool is a uint type which can be either 0 or 1. I don't see what the > benefit of this patch is.q > bool is NOT a uint type now, it is a new type introduced by gcc, it is rather different with "typedef int bool" historically see following code segments for more info about type bool bool v = 0x10; printf("v = %d\n", v); the output is v = 1. it maybe cause a invalid array index if bool is represented as uint bool highpri = wq->flags & WQ_HIGHPRI; WQ_HIGHPRI = 1 << 4, @highpri maybe 16, but the number of array elements is 2. bool is a logic value, the valid value is true or false. indexing array by type bool is not a good program custom it is more extendable to use type int, type bool maybe is improper if the number of array elements is extended to more than 2 in future besides, the relevant array is indexed by type int in many other places of the same source file. this patch can keep consistency > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] workqueue: use type int instead of bool to index array 2017-09-06 16:04 ` [PATCH 1/1] workqueue: use type int instead of bool to index array zijun_hu @ 2017-09-06 16:40 ` Tejun Heo 2017-09-06 17:07 ` zijun_hu 0 siblings, 1 reply; 4+ messages in thread From: Tejun Heo @ 2017-09-06 16:40 UTC (permalink / raw) To: zijun_hu; +Cc: zijun_hu, linux-mm, linux-kernel, Andrew Morton, jiangshanlai On Thu, Sep 07, 2017 at 12:04:59AM +0800, zijun_hu wrote: > On 2017/9/6 22:33, Tejun Heo wrote: > > Hello, > > > > On Wed, Sep 06, 2017 at 11:34:14AM +0800, zijun_hu wrote: > >> From: zijun_hu <zijun_hu@htc.com> > >> > >> type bool is used to index three arrays in alloc_and_link_pwqs() > >> it doesn't look like conventional. > >> > >> it is fixed by using type int to index the relevant arrays. > > > > bool is a uint type which can be either 0 or 1. I don't see what the > > benefit of this patch is.q > > > bool is NOT a uint type now, it is a new type introduced by gcc, it is > rather different with "typedef int bool" historically http://www.open-std.org/jtc1/sc22/wg14/www/docs/n815.htm Because C has existed for so long without a Boolean type, however, the new standard must coexist with the old remedies. Therefore, the type name is taken from the reserved identifier space. To maintain orthogonal promotion rules, the Boolean type is defined as an unsigned integer type capable of representing the values 0 and 1. The more conventional names for the type and its values are then made available only with the inclusion of the <stdbool.h> header. In addition, the header defines a feature test macro to aid in integrating new code with old code that defines its own Boolean type. -- tejun -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] workqueue: use type int instead of bool to index array 2017-09-06 16:40 ` Tejun Heo @ 2017-09-06 17:07 ` zijun_hu 2017-09-06 17:22 ` Tejun Heo 0 siblings, 1 reply; 4+ messages in thread From: zijun_hu @ 2017-09-06 17:07 UTC (permalink / raw) To: Tejun Heo; +Cc: zijun_hu, linux-mm, linux-kernel, Andrew Morton, jiangshanlai On 2017/9/7 0:40, Tejun Heo wrote: > On Thu, Sep 07, 2017 at 12:04:59AM +0800, zijun_hu wrote: >> On 2017/9/6 22:33, Tejun Heo wrote: >>> Hello, >>> >>> On Wed, Sep 06, 2017 at 11:34:14AM +0800, zijun_hu wrote: >>>> From: zijun_hu <zijun_hu@htc.com> >>>> >>>> type bool is used to index three arrays in alloc_and_link_pwqs() >>>> it doesn't look like conventional. >>>> >>>> it is fixed by using type int to index the relevant arrays. >>> >>> bool is a uint type which can be either 0 or 1. I don't see what the >>> benefit of this patch is.q >>> >> bool is NOT a uint type now, it is a new type introduced by gcc, it is >> rather different with "typedef int bool" historically > > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n815.htm > > Because C has existed for so long without a Boolean type, however, the > new standard must coexist with the old remedies. Therefore, the type > name is taken from the reserved identifier space. To maintain > orthogonal promotion rules, the Boolean type is defined as an unsigned > integer type capable of representing the values 0 and 1. The more > conventional names for the type and its values are then made available > only with the inclusion of the <stdbool.h> header. In addition, the > header defines a feature test macro to aid in integrating new code > with old code that defines its own Boolean type. > in this case, i think type int is more suitable than bool in aspects of extendibility, program custom and consistency. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] workqueue: use type int instead of bool to index array 2017-09-06 17:07 ` zijun_hu @ 2017-09-06 17:22 ` Tejun Heo 0 siblings, 0 replies; 4+ messages in thread From: Tejun Heo @ 2017-09-06 17:22 UTC (permalink / raw) To: zijun_hu; +Cc: zijun_hu, linux-mm, linux-kernel, Andrew Morton, jiangshanlai On Thu, Sep 07, 2017 at 01:07:23AM +0800, zijun_hu wrote: > in this case, i think type int is more suitable than bool in aspects of > extendibility, program custom and consistency. Please stop. -- tejun -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-09-06 17:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <59AF6CB6.4090609@zoho.com>
[not found] ` <20170906143320.GK1774378@devbig577.frc2.facebook.com>
2017-09-06 16:04 ` [PATCH 1/1] workqueue: use type int instead of bool to index array zijun_hu
2017-09-06 16:40 ` Tejun Heo
2017-09-06 17:07 ` zijun_hu
2017-09-06 17:22 ` Tejun Heo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox