* [Qemu-devel] [PATCH] block: fix a warning and possible truncation
@ 2010-06-14 18:55 Blue Swirl
2010-06-15 7:52 ` [Qemu-devel] " Kevin Wolf
2010-06-15 9:52 ` [Qemu-devel] " Alexander Graf
0 siblings, 2 replies; 5+ messages in thread
From: Blue Swirl @ 2010-06-14 18:55 UTC (permalink / raw)
To: Kevin Wolf, qemu-devel
Fix a warning from OpenBSD gcc (3.3.5 (propolice)):
/src/qemu/block.c: In function `bdrv_info_stats_bs':
/src/qemu/block.c:1548: warning: long long int format, long unsigned
int arg (arg 6)
There may be also truncation effects.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
Alternatively 'ULL' prefix could be appended to BDRV_SECTOR_SIZE
definition but that may have other side effects.
block.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/block.c b/block.c
index cacf11b..a7ab0b4 100644
--- a/block.c
+++ b/block.c
@@ -1545,7 +1545,8 @@ static QObject* bdrv_info_stats_bs(BlockDriverState *bs)
"} }",
bs->rd_bytes, bs->wr_bytes,
bs->rd_ops, bs->wr_ops,
- bs->wr_highest_sector * (long)BDRV_SECTOR_SIZE);
+ bs->wr_highest_sector *
+ (uint64_t)BDRV_SECTOR_SIZE);
dict = qobject_to_qdict(res);
if (*bs->device_name) {
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] Re: [PATCH] block: fix a warning and possible truncation
2010-06-14 18:55 [Qemu-devel] [PATCH] block: fix a warning and possible truncation Blue Swirl
@ 2010-06-15 7:52 ` Kevin Wolf
2010-06-15 8:08 ` Markus Armbruster
2010-06-15 9:52 ` [Qemu-devel] " Alexander Graf
1 sibling, 1 reply; 5+ messages in thread
From: Kevin Wolf @ 2010-06-15 7:52 UTC (permalink / raw)
To: Blue Swirl; +Cc: qemu-devel
Am 14.06.2010 20:55, schrieb Blue Swirl:
> Fix a warning from OpenBSD gcc (3.3.5 (propolice)):
> /src/qemu/block.c: In function `bdrv_info_stats_bs':
> /src/qemu/block.c:1548: warning: long long int format, long unsigned
> int arg (arg 6)
>
> There may be also truncation effects.
>
> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Thanks, applied to the block branch.
But why is this even needed? wr_highest_sector is already uint64_t, so
wouldn't you expect the result to be uint64_t, too?
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] Re: [PATCH] block: fix a warning and possible truncation
2010-06-15 7:52 ` [Qemu-devel] " Kevin Wolf
@ 2010-06-15 8:08 ` Markus Armbruster
0 siblings, 0 replies; 5+ messages in thread
From: Markus Armbruster @ 2010-06-15 8:08 UTC (permalink / raw)
To: Kevin Wolf; +Cc: Blue Swirl, qemu-devel
Kevin Wolf <kwolf@redhat.com> writes:
> Am 14.06.2010 20:55, schrieb Blue Swirl:
>> Fix a warning from OpenBSD gcc (3.3.5 (propolice)):
>> /src/qemu/block.c: In function `bdrv_info_stats_bs':
>> /src/qemu/block.c:1548: warning: long long int format, long unsigned
>> int arg (arg 6)
>>
>> There may be also truncation effects.
>>
>> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
>
> Thanks, applied to the block branch.
>
> But why is this even needed? wr_highest_sector is already uint64_t, so
> wouldn't you expect the result to be uint64_t, too?
Makes me wonder. To what's uint64_t typedef'ed on this machine? And to
what does PRId64 expand?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] block: fix a warning and possible truncation
2010-06-14 18:55 [Qemu-devel] [PATCH] block: fix a warning and possible truncation Blue Swirl
2010-06-15 7:52 ` [Qemu-devel] " Kevin Wolf
@ 2010-06-15 9:52 ` Alexander Graf
2010-06-15 9:59 ` Kevin Wolf
1 sibling, 1 reply; 5+ messages in thread
From: Alexander Graf @ 2010-06-15 9:52 UTC (permalink / raw)
To: Blue Swirl; +Cc: Kevin Wolf, qemu-devel
Am 14.06.2010 um 20:55 schrieb Blue Swirl <blauwirbel@gmail.com>:
> Fix a warning from OpenBSD gcc (3.3.5 (propolice)):
> /src/qemu/block.c: In function `bdrv_info_stats_bs':
> /src/qemu/block.c:1548: warning: long long int format, long unsigned
> int arg (arg 6)
>
> There may be also truncation effects.
>
> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
> ---
> Alternatively 'ULL' prefix could be appended to BDRV_SECTOR_SIZE
> definition but that may have other side effects.
... Which are probably wanted. If there are more truncations, we want
to catch them early, no?
Alex
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] block: fix a warning and possible truncation
2010-06-15 9:52 ` [Qemu-devel] " Alexander Graf
@ 2010-06-15 9:59 ` Kevin Wolf
0 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2010-06-15 9:59 UTC (permalink / raw)
To: Alexander Graf; +Cc: Blue Swirl, qemu-devel
Am 15.06.2010 11:52, schrieb Alexander Graf:
>
> Am 14.06.2010 um 20:55 schrieb Blue Swirl <blauwirbel@gmail.com>:
>
>> Fix a warning from OpenBSD gcc (3.3.5 (propolice)):
>> /src/qemu/block.c: In function `bdrv_info_stats_bs':
>> /src/qemu/block.c:1548: warning: long long int format, long unsigned
>> int arg (arg 6)
>>
>> There may be also truncation effects.
>>
>> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
>> ---
>> Alternatively 'ULL' prefix could be appended to BDRV_SECTOR_SIZE
>> definition but that may have other side effects.
>
> ... Which are probably wanted. If there are more truncations, we want
> to catch them early, no?
Actually, it's there:
#define BDRV_SECTOR_SIZE (1ULL << BDRV_SECTOR_BITS)
That compiler warning doesn't make any sense to me.
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-06-15 10:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-14 18:55 [Qemu-devel] [PATCH] block: fix a warning and possible truncation Blue Swirl
2010-06-15 7:52 ` [Qemu-devel] " Kevin Wolf
2010-06-15 8:08 ` Markus Armbruster
2010-06-15 9:52 ` [Qemu-devel] " Alexander Graf
2010-06-15 9:59 ` Kevin Wolf
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).