On 12/11/2014 09:18 AM, ROMANO MASPERO wrote:
> The problem is, on my compiler, if I do something like:
> 
> bool is_found = ISFOUND (cursor);
> 
> the compiler downgrades cursor->found_count to a bool type (8 bit), so if 
> cursor->found_count is a multiple of 256 then ISFOUND returns 0.

That is NOT compliant behavior for a C99 compiler (all non-zero values
must be collapsed to 1, regardless of original size), but IS the
behavior to expect when using gnulib's <stdbool.h> replacement on a C89
compiler (where there is no native bool support, and where gnulib
documents that such assignments are unsafe).  Since we don't require a
C99 compiler in tar, this is a bug in our source code, and we should
instead write:

bool is_found = !!ISFOUND (cursor);

or some similar construct that guarantees a C89-compliant force-to-1
semantics that we need; or fix the ISFOUND() macro to guarantee bool
output to begin with.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to