From: Ian Jackson Subject: Re: [PATCH 14/22] libelf: use C99 bool for booleans Date: Tue, 11 Jun 2013 15:50:45 +0100 Message-ID: <20919.14661.895725.930780@mariner.uk.xensource.com> References: <1370629642-6990-1-git-send-email-ian.jackson@eu.citrix.com> <1370629642-6990-15-git-send-email-ian.jackson@eu.citrix.com> <51B64E84.2030606@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <51B64E84.2030606@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: "xen-devel@lists.xensource.com" , "mattjd@gmail.com" , "security@xen.org" List-Id: xen-devel@lists.xenproject.org Andrew Cooper writes ("Re: [PATCH 14/22] libelf: use C99 bool for booleans"): > On 07/06/13 19:27, Ian Jackson wrote: > > @@ -46,7 +46,7 @@ static void log_callback(struct elf_binary *elf, void *caller_data, > > > > void xc_elf_set_logfile(xc_interface *xch, struct elf_binary *elf, > > int verbose) { > > - elf_set_log(elf, log_callback, xch, verbose); > > + elf_set_log(elf, log_callback, xch, verbose /* convert to bool */); > > Change the function prototype from int verbose to bool verbose ? > > If not, for API reasons, then use !!verbose to correctly convert an > integer to a boolean. Not, for API reasons, as you surmise. As I write in the commit message: For the one visible libelf boolean in libxc's public interface we retain the use of int to avoid changing the ABI; libxc converts it to a bool for consumption by libelf. It is not necessary to use !!verbose. See C99 6.3.1.2. Any conversion of a scalar to a _Bool is equivalent to a comparison !=0 (which is the same test as for ?: (6.5.15(4)) and "if" (6.8.4.1(2)). Some of this is explained in the commit message. Ian.