Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755214AbdIFQFL (ORCPT ); Wed, 6 Sep 2017 12:05:11 -0400 Received: from sender-pp-091.zoho.com ([135.84.80.236]:25072 "EHLO sender-pp-091.zoho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755195AbdIFQFJ (ORCPT ); Wed, 6 Sep 2017 12:05:09 -0400 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=subject:to:references:cc:from:message-id:date:user-agent:mime-version:in-reply-to:content-type; b=HOAe74K/Tm2llJ0auoGwrV4KHOC72hBat/X5whV1CQmaIhKqiQp80I2JdQxqFKDNpDok/hYdYeP2 9EkAo7eRlBP16qLFbN5H6sUSEiOy/Z95K1jjVHdpunp/RSsuZRae Subject: Re: [PATCH 1/1] workqueue: use type int instead of bool to index array To: Tejun Heo References: <59AF6CB6.4090609@zoho.com> <20170906143320.GK1774378@devbig577.frc2.facebook.com> Cc: zijun_hu@htc.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , jiangshanlai@gmail.com From: zijun_hu Message-ID: Date: Thu, 7 Sep 2017 00:04:59 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170906143320.GK1774378@devbig577.frc2.facebook.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-ZohoMailClient: External Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1245 Lines: 35 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 >> >> 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 >