Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1643007

Re: [PATCH v4 1/1] x86, relocs: add printf attribute to die()

From Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Newsgroups linux.kernel
Subject Re: [PATCH v4 1/1] x86, relocs: add printf attribute to die()
Date 2017-05-17 08:50 +0200
Message-ID <tI0Wt-83r-7@gated-at.bofh.it> (permalink)
References <thFuh-1BG-5@gated-at.bofh.it> <tinlE-83G-13@gated-at.bofh.it> <tisOm-3ze-25@gated-at.bofh.it> <tq6xk-52S-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hello,

The patch I sent a few months ago still applies cleanly on top of
4.12-rc1. What should I do in order to get it merged in 4.13?

In case you no longer have my initial email, the patch has been
archived in https://patchwork.kernel.org/patch/9604651/ .

Thanks,
Nicolas

On Tue, Mar 28, 2017 at 11:06 PM, Nicolas Iooss
<nicolas.iooss_linux@m4x.org> wrote:
> On Tue, Mar 7, 2017 at 1:37 PM, Nicolas Iooss
> <nicolas.iooss_linux@m4x.org> wrote:
>> On Tue, Mar 7, 2017 at 10:16 AM, Ingo Molnar <mingo@kernel.org> wrote:
>>>
>>> * Nicolas Iooss <nicolas.iooss_linux@m4x.org> wrote:
>>>
>>>> Adding such an attribute helps to detect errors in the format string at
>>>> build time. After doing this, the compiler complains about some issues:
>>>>
>>>>     arch/x86/tools/relocs.c:460:5: error: format specifies type 'int'
>>>>     but the argument has type 'Elf64_Xword' (aka 'unsigned long')
>>>>     [-Werror,-Wformat]
>>>>                                     sec->shdr.sh_size);
>>>>                                     ^~~~~~~~~~~~~~~~~
>>>>     arch/x86/tools/relocs.c:464:5: error: format specifies type 'int'
>>>>     but the argument has type 'Elf64_Off' (aka 'unsigned long')
>>>>     [-Werror,-Wformat]
>>>>                                     sec->shdr.sh_offset, strerror(errno));
>>>>                                     ^~~~~~~~~~~~~~~~~~~
>>>>
>>>> When relocs.c is included by relocs_32.c, sec->shdr.sh_size and
>>>> sec->shdr.sh_offset are 32-bit unsigned integers. When the file is
>>>> included by relocs_64.c, these expressions are 64-bit unsigned integers.
>>>>
>>>> Add casts to unsigned long long, which length is always 64-bit, and use
>>>> %llu to format sec->shdr.sh_size and sec->shdr.sh_offset in relocs.c.
>>>>
>>>> While at it, constify the format attribute of die().
>>>>
>>>> Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
>>>> ---
>>>>  arch/x86/tools/relocs.c        | 31 +++++++++++++++++--------------
>>>>  arch/x86/tools/relocs.h        |  3 ++-
>>>>  arch/x86/tools/relocs_common.c |  2 +-
>>>>  3 files changed, 20 insertions(+), 16 deletions(-)
>>>>
>>>> diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
>>>> index 73eb7fd4aec4..3cc02065c677 100644
>>>> --- a/arch/x86/tools/relocs.c
>>>> +++ b/arch/x86/tools/relocs.c
>>>> @@ -397,8 +397,8 @@ static void read_shdrs(FILE *fp)
>>>>                   ehdr.e_shnum);
>>>>       }
>>>>       if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) {
>>>> -             die("Seek to %d failed: %s\n",
>>>> -                     ehdr.e_shoff, strerror(errno));
>>>> +             die("Seek to %llu failed: %s\n",
>>>> +                     (unsigned long long)ehdr.e_shoff, strerror(errno));
>>>
>>> Isn't "(u64)" shorter to write?
>>
>> u64 does not seem to be defined in this file right now. Adding
>> "#include <linux/types.h>" defines u64 and __u64 in the following way:
>> - "typedef uint64_t u64;" from tools/include/linux/types.h
>> - "typedef unsigned long long __u64;" from /usr/include/asm-generic/int-ll64.h
>>
>> uint64_t is unsigned long on x86-64 and gcc complains when using %llu
>> on such a type, so using a cast to u64 forces using PRIu64 too.
>>
>> Nevertheless "(__u64)" is shorter than "(unsigned long long)" and
>> seems to work fine in my quick tests because it is always unsigned
>> long long (on both x86-32 and x86-64). Would you prefer to use this
>> cast?
>
> Hello,
> After the question I had on the 4th revision of this patch, I have not
> received any reply or comment for three weeks. What should I do in
> order to get this merged?
>
> Thanks,
> Nicolas

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: [PATCH v4 1/1] x86, relocs: add printf attribute to die() Nicolas Iooss <nicolas.iooss_linux@m4x.org> - 2017-05-17 08:50 +0200

csiph-web