From: Stefan Weil <weil@mail.berlios.de>
To: Markus Armbruster <armbru@redhat.com>
Cc: Alexandre Raymond <cerbere@gmail.com>,
qemu-trivial@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH 5/6] Remove warning in printf due to type mismatch
Date: Fri, 27 May 2011 22:44:54 +0200 [thread overview]
Message-ID: <4DE00D46.5030604@mail.berlios.de> (raw)
In-Reply-To: <m38vtst0up.fsf@blackfin.pond.sub.org>
Am 27.05.2011 21:11, schrieb Markus Armbruster:
> Stefan Weil <weil@mail.berlios.de> writes:
>
>> Am 27.05.2011 19:22, schrieb Alexandre Raymond:
>>> ----8<----
>>> qemu/target-lm32/translate.c: In function
>>> ‘gen_intermediate_code_internal’:
>>> qemu/target-lm32/translate.c:1135: warning: format ‘%zd’ expects
>>> type ‘signed size_t’, but argument 4 has type ‘int’
>>> ----8<----
>>>
>>> Both gen_opc_ptr and gen_opc_buf are "uint16_t *", so a simple '%d'
>>> should
>>> be able to describe their relative difference.
>>>
>>> Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
>>> ---
>>> target-lm32/translate.c | 2 +-
>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/target-lm32/translate.c b/target-lm32/translate.c
>>> index eb21158..0f69f27 100644
>>> --- a/target-lm32/translate.c
>>> +++ b/target-lm32/translate.c
>>> @@ -1132,7 +1132,7 @@ static void
>>> gen_intermediate_code_internal(CPUState *env,
>>> if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
>>> qemu_log("\n");
>>> log_target_disas(pc_start, dc->pc - pc_start, 0);
>>> - qemu_log("\nisize=%d osize=%zd\n",
>>> + qemu_log("\nisize=%d osize=%d\n",
>>> dc->pc - pc_start, gen_opc_ptr - gen_opc_buf);
>>> }
>>> #endif
>>
>> Nack.
>>
>> The original code is correct, because the difference of two pointers
>> is always of type ssize_t (well, obviously not with your compiler,
>> but then I assume that your compiler is broken).
>
> ISO/IEC 9899:1999 §6.5.6 on pointer subtraction:
>
> The size of the result is implementation-defined, and its type (a
> signed integer type) is ptrdiff_t defined in the <stddef.h> header.
>
> The pedantically correct way to print a pointer difference is the 't'
> type modifier. Ibid. §7.19.6.1 on fprintf():
>
> t Specifies that a following d, i, o, u, x, or X conversion
> specifier applies to a ptrdiff_t or the corresponding unsigned
> integer type argument; or that a following n conversion
> specifier applies to a pointer to a ptrdiff_t argument.
>
> ssize_t is POSIX, not ISO C. It can differ from ptrdiff_t only if
> ptrdiff_t has a different size than size_t, which would be kind of sick.
> ISO C permits all kinds of sickness. Whether tolerating a particular
> sickness is worth our while is another question.
>
> [...]
That's correct. And ptrdiff_t needs %td.
Alexandre, could you please try %td instead of %zd?
Cheers,
Stefan W.
next prev parent reply other threads:[~2011-05-27 20:45 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-27 17:22 [Qemu-trivial] [PATCH 0/6] Fix compilation issues under darwin Alexandre Raymond
2011-05-27 17:22 ` [Qemu-trivial] [PATCH 1/6] Fix incorrect check for fdatasync() in configure Alexandre Raymond
2011-05-29 14:50 ` [Qemu-trivial] [Qemu-devel] " Andreas Färber
2011-05-29 15:46 ` Alexandre Raymond
2011-05-29 17:05 ` Andreas Färber
2011-05-27 17:22 ` [Qemu-trivial] [PATCH 2/6] Cocoa: avoid displaying window when command-line contains '-h' Alexandre Raymond
2011-05-28 15:05 ` [Qemu-trivial] [Qemu-devel] " Andreas Färber
2011-05-27 17:22 ` [Qemu-trivial] [PATCH 3/6] Fix compilation warning due to incorrectly specified type Alexandre Raymond
2011-05-27 17:42 ` [Qemu-trivial] [Qemu-devel] " Stefan Weil
2011-05-29 15:02 ` Andreas Färber
2011-05-27 17:22 ` [Qemu-trivial] [PATCH 4/6] Fix missing prototype under cocoa for qemu_main Alexandre Raymond
2011-05-29 15:11 ` [Qemu-trivial] [Qemu-devel] " Andreas Färber
2011-05-27 17:22 ` [Qemu-trivial] [PATCH 5/6] Remove warning in printf due to type mismatch Alexandre Raymond
2011-05-27 17:35 ` [Qemu-trivial] [Qemu-devel] " Stefan Weil
2011-05-27 19:11 ` Markus Armbruster
2011-05-27 20:44 ` Stefan Weil [this message]
2011-05-27 22:10 ` Alexandre Raymond
2011-05-28 6:55 ` [Qemu-trivial] " Paolo Bonzini
2011-05-27 17:22 ` [Qemu-trivial] [PATCH 6/6] Avoid compilation warning regarding kvm under darwin Alexandre Raymond
2011-05-27 17:39 ` [Qemu-trivial] [Qemu-devel] " Stefan Weil
2011-05-28 14:55 ` [Qemu-trivial] [Qemu-devel] [PATCH 0/6] Fix compilation issues " Andreas Färber
2011-05-28 19:41 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DE00D46.5030604@mail.berlios.de \
--to=weil@mail.berlios.de \
--cc=armbru@redhat.com \
--cc=cerbere@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).