Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1727626
| From | zijun_hu <zijun_hu@zoho.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/1] workqueue: use type int instead of bool to index array |
| Date | 2017-09-06 18:10 +0200 |
| Message-ID | <umL3P-49l-7@gated-at.bofh.it> (permalink) |
| References | <umzFn-433-3@gated-at.bofh.it> <umJEJ-32z-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/1] workqueue: use type int instead of bool to index array zijun_hu <zijun_hu@zoho.com> - 2017-09-06 06:00 +0200
Re: [PATCH 1/1] workqueue: use type int instead of bool to index array Tejun Heo <tj@kernel.org> - 2017-09-06 16:40 +0200
Re: [PATCH 1/1] workqueue: use type int instead of bool to index array zijun_hu <zijun_hu@zoho.com> - 2017-09-06 18:10 +0200
Re: [PATCH 1/1] workqueue: use type int instead of bool to index array Tejun Heo <tj@kernel.org> - 2017-09-06 18:50 +0200
Re: [PATCH 1/1] workqueue: use type int instead of bool to index array zijun_hu <zijun_hu@zoho.com> - 2017-09-06 19:10 +0200
Re: [PATCH 1/1] workqueue: use type int instead of bool to index array Tejun Heo <tj@kernel.org> - 2017-09-06 19:30 +0200
csiph-web