[PATCH v1] bfd: use correct format specifier for uint64_t
Jan Beulich
jbeulich@suse.com
Thu Jan 22 14:02:09 GMT 2026
On 22.01.2026 14:29, Rainer Orth wrote:
> Hi Jan,
>
>> On 22.01.2026 13:57, Matthieu Longo wrote:
>>> ---
>>> bfd/elf-attrs.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> Counts as obvious, I'd say, but just in case: Okay.
>
> testing on sparc-sun-solaris2.11, i386-pc-solaris2.11, and
> i686-pc-linux-gnu with --enable-64-bit-bfd, I needed two more to
> address
>
> In file included from bfd/elf-attrs.c:140:
> bfd/elf-attrs.c: In function ‘oav2_parse_subsection’:
> bfd/elf-attrs.c:2752:29: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
> 2752 | _bfd_error_handler (_("%pB: error: bad subsection length (%u > max=%lu)"),
>
> In file included from /vol/src/gnu/binutils/hg/master/testing/bfd/sysdep.h:165,
> from /vol/src/gnu/binutils/hg/master/testing/bfd/elf-attrs.c:140:
> bfd/elf-attrs.c: In function ‘_bfd_elf_parse_attributes’:
> bfd/elf-attrs.c:2910:12: error: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘bfd_size_type’ {aka ‘unsigned int’} [-Werror=format=]
> 2910 | (_("%pB: error: attribute section '%pA' too big: %" PRId64),
>
> Tested on all of the above.
>
> Ok for trunk?
Only almost.
> --- a/bfd/elf-attrs.c
> +++ b/bfd/elf-attrs.c
> @@ -2749,8 +2749,8 @@ oav2_parse_subsection (bfd *abfd,
> cursor += F_SUBSECTION_LEN;
> if (subsection_len > max_read)
> {
> - _bfd_error_handler (_("%pB: error: bad subsection length (%u > max=%lu)"),
> - abfd, subsection_len, max_read);
> + _bfd_error_handler (_("%pB: error: bad subsection length (%u > max=%"
> + PRIu64 ")"), abfd, subsection_len, max_read);
Please don't wrap the format string in such a case, and especially not like
this. It running slightly past 80 chars ought to be okay(ish). Else move
everything from the opening parenthesis onwards to the next line. In no case
should more arguments follow on the same line that already continues an
argument from an earlier one.
(I'm sure I had pointed out this particular instance to Matthieu.)
Okay with at least this adjustment, but read on.
@@ -2908,7 +2908,7 @@ void
{
_bfd_error_handler
(_("%pB: error: attribute section '%pA' too big: %" PRId64),
- abfd, hdr->bfd_section, hdr->sh_size);
+ abfd, hdr->bfd_section, (uint64_t) hdr->sh_size);
Could I talk you into switching PRId64 to PRIu64 here at the same time?
Jan
More information about the Binutils
mailing list