Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2738157imu; Sun, 13 Jan 2019 08:54:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN6sXAwK76/h57hlB2yOMnlKyfAdvMBbNh+VY6Mug7/VjVuBD9EgSa6t0d+7bHHi8hQapFyL X-Received: by 2002:a17:902:8607:: with SMTP id f7mr21691969plo.123.1547398488447; Sun, 13 Jan 2019 08:54:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547398488; cv=none; d=google.com; s=arc-20160816; b=Q7LE92IMRV2P8z10whGRy58S9blLpMrC0G6yZ3iL7H1MI/1pw39SaSspQBaAt/OgTR smskxr2Cwvu9xi7Id3LoK82FMx0HpqQ+F9uRNQ5UcrsdSYaPDYIbJkj01WobRLuGTIHa AZ1da5QnaC/60GrhuMVFbb/Zdu9C2PC18BKAlmEcPItEkOh5GUzZ01pOVtXHqk7hsPfT 9GDFFPqylBOHl62K96ruTXW77fXE3KBbCnTcmb2YbTuRzXz7T3wh/zlRcW5YTaNMy+s7 G4kn0gMAHZ5ESCDeepIJBzeXZwLiMeFdZlMpQoNgYmebN/3Rpn1+cN8pNn1mSiA817es jI8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wrZm73XoQCJ9+KwY5y7yjv8JJNYe/WdlAJUCzKjmak4=; b=VPINCI4D3wNts6rR7ZRd3Z6zhIwGk0s3UimA7N6JxRyWXNed5vQl+n6BB1M7agYKJw PiX0DwJMyhOQshJ62+z0tikGQYzU47cK6K4t+23+G9yOBsZiHTkDov+ADB6YmjGRXgtz X1We7d9zf/+8bqT53htw7sIWx8DLBCbBRIqO3PbwZZwQB/Th7Y9ykKLHreYd6QLuRmRp oX246S3figR2k9y8HJ+m117mmkvIkKHxxu9dh/z9UESZWoN8wPBsyjiDMPqBHWq5lGXk 73QUyGVxSdjKnD/Z9lBNeJK52sLzmbSvb6Dpd5GLmBHlctcRJ22wkJhzqqbwtXBJ0B9H usHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=bnvOxTNc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n34si5682315pld.381.2019.01.13.08.54.19; Sun, 13 Jan 2019 08:54:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=bnvOxTNc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726760AbfAMQtp (ORCPT + 99 others); Sun, 13 Jan 2019 11:49:45 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:55164 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbfAMQto (ORCPT ); Sun, 13 Jan 2019 11:49:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wrZm73XoQCJ9+KwY5y7yjv8JJNYe/WdlAJUCzKjmak4=; b=bnvOxTNcPIsfTh7rVGKvYNIhY 2VyR6sCq5y8Z7HRM2cNWQvmi9QsuwB9D3QTcwBkKt2IU0WvPJqdCczlYuoUmT1GgEhiFaSNvLxZia 1e+OKkHFz0Z+CYhn/++w7S0zOcyTCy+S4X8eI/gNAknsU6wuy5WIA2tBGgTQ9/+iNexNPjOOCDJnv qIzsOf5M1ybNwURSPjtdwOqyiSL2ASxKWafBqWS/V6gq2GpY7M2fEptT+cLsMOeHAWBm/RVybXHUD 4RiEQA8HGPSMORyQZc9mbcLAtihbNwgxIcgxldkd0U510htG4QWtV16E5vmNo6UFR7hW7UvyUVTcU kxFxfscGg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1giix6-00041e-Bt; Sun, 13 Jan 2019 16:49:36 +0000 Date: Sun, 13 Jan 2019 08:49:36 -0800 From: Matthew Wilcox To: Jason Gunthorpe Cc: Joe Perches , Gal Pressman , Bart Van Assche , Stephen Warren , Tariq Toukan , "xavier.huwei@huawei.com" , "netdev@vger.kernel.org" , "linux-rdma@vger.kernel.org" , Doug Ledford , Stephen Warren , Christoph Hellwig , Andrew Morton , Linus Torvalds , "linux-doc@vger.kernel.org" , Jonathan Corbet , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v4] coding-style: Clarify the expectations around bool Message-ID: <20190113164936.GW6310@bombadil.infradead.org> References: <20190110234805.GN6890@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190110234805.GN6890@ziepe.ca> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 10, 2019 at 11:48:13PM +0000, Jason Gunthorpe wrote: > +The Linux kernel bool type is an alias for the C99 _Bool type. bool values can > +only evaluate to 0 or 1, and implicit or explicit conversion to bool > +automatically converts the value to true or false. When using bool types the > +!! construction is not needed, which eliminates a class of bugs. > + > +When working with bool values the true and false definitions should be used > +instead of 0 and 1. > + > +bool function return types and stack variables are always fine to use whenever > +appropriate. Use of bool is encouraged to improve readability and is often a > +better option than 'int' for storing boolean values. It's awkward to start a sentence with a lower case letter. How about rephrasing this paragraph and the following one as: Using bool as the return type of a function or as a variable is always fine when appropriate. It often improves readability and is a better option than int for storing boolean values. Using bool in data structures is more debatable; its size and alignment can vary between architectures. > +Do not use bool if cache line layout or size of the value matters, its size > +and alignment varies based on the compiled architecture. Structures that are > +optimized for alignment and size should not use bool. > + > +If a structure has many true/false values, consider consolidating them into a > +bitfield with 1 bit members, or using an appropriate fixed width type, such as > +u8.