This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Use CHAR_BIT instead of NBBY in libctf


On 4 Jun 2019, Tom Tromey uttered the following:

> On x86-64 Fedora 29, I tried to build a mingw-hosted gdb that targets
> ppc-linux.  You can do this with:
>
>     ../binutils-gdb/configure --host=i686-w64-mingw32 --target=ppc-linux \
>         --disable-{binutils,gas,gold,gprof,ld}
>
> The build failed with these errors in libctf:
>
> In file included from ../../binutils-gdb/libctf/ctf-create.c:20:
> ../../binutils-gdb/libctf/ctf-create.c: In function 'ctf_add_encoded':
> ../../binutils-gdb/libctf/ctf-create.c:803:59: error: 'NBBY' undeclared (first use in this function)
>    dtd->dtd_data.ctt_size = clp2 (P2ROUNDUP (ep->cte_bits, NBBY) / NBBY);

Hm, something else I thought was portable that actually isn't.

> ../../binutils-gdb/libctf/ctf-create.c: In function 'ctf_add_type':
> ../../binutils-gdb/libctf/ctf-create.c:1822:16: warning: unknown conversion type character 'z' in format [-Wformat=]
>    ctf_dprintf ("Conflict for type %s against ID %lx: "
>                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I suppose we could explicitly cast size_t arguments instead of using
%zi. I can implement that if you think it's sensible. (Ironically, it's
not that long ago that I ripped those casts out and moved to %zi
everywhere...)

> This patch fixes the actual errors in here.  I did not try to fix the
> printf warnings, though I think someone ought to.

I'll fix those.

> Ok?

Looks good to me (<limits.h> is pulled in via ctf-impl.h so CHAR_BIT is
always in scope).

Thanks for the patch!


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]