[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v7 11/35] util: introduce qemu_file_getlength()
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-devel] [PATCH v7 11/35] util: introduce qemu_file_getlength() |
Date: |
Wed, 4 Nov 2015 12:44:10 -0200 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Wed, Nov 04, 2015 at 11:17:09AM +0800, Xiao Guangrong wrote:
>
>
> On 11/04/2015 07:21 AM, Eduardo Habkost wrote:
> >On Mon, Nov 02, 2015 at 05:13:13PM +0800, Xiao Guangrong wrote:
> >[...]
> >>+size_t qemu_file_getlength(const char *file, Error **errp)
> >>+{
> >>+ int64_t size;
> >[...]
> >>+ return size;
> >
> >Can you guarantee that SIZE_MAX >= INT64_MAX on all platforms supported
> >by QEMU?
> >
>
> Actually, this function is abstracted from the common function,
> raw_getlength(),
> in raw-posix.c whose return value is int64_t.
>
> And i think int64_t is large enough for block devices.
int64_t should be enough, but I don't know if size_t is large enough on
all platforms.
I believe it's going to be either one of those cases:
* If you are absolutely sure SIZE_MAX >= INT64_MAX on all platforms,
please explain why (and maybe add a QEMU_BUILD_BUG_ON?). (I don't
think this will be the case)
* If SIZE_MAX < INT64_MAX is possible but you believe
size <= SIZE_MAX is always true here, please explain why (and maybe
add an assert()).
* Otherwise, we need to set an appropriate error if size > SIZE_MAX
or change the type of qemu_file_getlength(). What about making it
uint64_t?
--
Eduardo
Re: [Qemu-devel] [PATCH v7 11/35] util: introduce qemu_file_getlength(), Eduardo Habkost, 2015/11/06
[Qemu-devel] [PATCH v7 13/35] hostmem-file: use whole file size if possible, Xiao Guangrong, 2015/11/02
[Qemu-devel] [PATCH v7 14/35] pc-dimm: remove DEFAULT_PC_DIMMSIZE, Xiao Guangrong, 2015/11/02
[Qemu-devel] [PATCH v7 12/35] util: let qemu_fd_getlength support block device, Xiao Guangrong, 2015/11/02