From: Eric Blake <eblake@redhat.com>
To: "Tomáš Golembiovský" <tgolembi@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] qemu-nbd: Shrink image size by specified offset
Date: Mon, 3 Oct 2016 10:12:50 -0500 [thread overview]
Message-ID: <28217cec-a26d-0a42-b6d2-06f9524864a0@redhat.com> (raw)
In-Reply-To: <20161003155045.6889f89d@fiorina>
[-- Attachment #1: Type: text/plain, Size: 1348 bytes --]
On 10/03/2016 08:50 AM, Tomáš Golembiovský wrote:
>> Additional context:
>>
>> off_t dev_offset = 0;
>>
>> off_t fd_size;
>>
>>>
>>> + if (dev_offset >= fd_size) {
>>> + error_report("Offset (%lu) has to be smaller than the image size (%lu)",
>>> + dev_offset, fd_size);
>>
>> Whoops, this fails to compile on 32-bit platforms. %lu is not
>> necessarily synonymous with off_t values.
>
> After some digging I figured off_t is in fact signed type. That makes
> the formatting wrong everywhere. Unfortunately I didn't find any good
> definition of the type. Any suggestion what format flag should I use? Or
> should I just use a temporary variable of known size for that?
Easiest is probably casting to a type with an easier format flag, as in
either of:
error_report("offset %lld ...", (long long) dev_offset)
error_report("offset %jd ...", (intmax_t) dev_offset)
off_t is particularly problematic because there is no magic % sequence
reserved for it, nothing in <inttypes.h> for it, and there are 32-bit
compilation environments where it is still 32 bits (although qemu
prefers to explicitly request large-file compilation so that off_t is
always 64 bits)
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
prev parent reply other threads:[~2016-10-03 15:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-20 9:37 [Qemu-devel] [PATCH 1/2] qemu-nbd: Shrink image size by specified offset Tomáš Golembiovský
2016-09-20 9:59 ` Paolo Bonzini
2016-09-20 14:09 ` Eric Blake
2016-10-03 13:50 ` Tomáš Golembiovský
2016-10-03 15:12 ` Eric Blake [this message]
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=28217cec-a26d-0a42-b6d2-06f9524864a0@redhat.com \
--to=eblake@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=tgolembi@redhat.com \
/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).