[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [git commit] hostid: do not output sign-extended host id. Closes 6056
From: Ralf Friedl <Ralf.Friedl () online ! de>
Date: 2013-03-15 8:12:20
Message-ID: 5142D7E4.3080703 () online ! de
[Download RAW message or body]
Denys Vlasenko wrote:
> On Wednesday 06 March 2013 08:27, Thierry Reding wrote:
>
>> On Mon, Mar 04, 2013 at 03:04:38AM +0100, Denys Vlasenko wrote:
>>
>>> commit: http://git.busybox.net/busybox/commit/?id=9bbf6b98c42a212b8a4b1aa02975ac18bb612922
>>> branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master
>>>
>>> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
>>> ---
>>> coreutils/hostid.c | 3 ++-
>>> 1 files changed, 2 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/coreutils/hostid.c b/coreutils/hostid.c
>>> index 5c1a4e0..e5b1f51 100644
>>> --- a/coreutils/hostid.c
>>> +++ b/coreutils/hostid.c
>>> @@ -36,7 +36,8 @@ int hostid_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
>>> bb_show_usage();
>>> }
>>>
>>> - printf("%08lx\n", gethostid());
>>> + /* POSIX says gethostid returns a "32-bit identifier" */
>>> + printf("%08x\n", (unsigned)(uint32_t)gethostid());
>>>
>> That's a bit over the top. uint32_t is already unsigned.
>>
>
> But unsigned may one day be wider than 32 bits,
> therefore, formally, if you want to print uint32_t using %d,
> %u or %x, you need to widen it.
Actually, you could pass unsigned char to printf and the compiler would
widen it automatically.
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic