[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [Qemu-devel] [PATCH 05/10] hw/i386/pc.c: Don't use load_i
From: |
Peter Maydell |
Subject: |
Re: [Qemu-ppc] [Qemu-devel] [PATCH 05/10] hw/i386/pc.c: Don't use load_image() |
Date: |
Sat, 1 Dec 2018 11:52:16 +0000 |
On Fri, 30 Nov 2018 at 15:31, Peter Maydell <address@hidden> wrote:
>
> The load_image() function is deprecated, as it does not let the
> caller specify how large the buffer to read the file into is.
> Use the glib g_file_get_contents() function instead, which does
> the whole "allocate memory for the file and read it in" operation.
>
> Signed-off-by: Peter Maydell <address@hidden>
> ---
> - initrd_size = get_image_size(initrd_filename);
> - if (initrd_size < 0) {
> + if (!g_file_get_contents(initrd_filename, &initrd_data,
> + &initrd_size, &gerr)) {
> fprintf(stderr, "qemu: error reading initrd %s: %s\n",
> - initrd_filename, strerror(errno));
> + initrd_filename, gerr->message);
> exit(1);
> - } else if (initrd_size >= initrd_max) {
> + }
> + if (initrd_size >= initrd_max) {
> fprintf(stderr, "qemu: initrd is too large, cannot support."
> - "(max: %"PRIu32", need %"PRId64")\n", initrd_max,
> initrd_size);
> + "(max: %"PRIu32", need %"PRId64")\n",
> + initrd_max, initrd_size);
patchew reports that this introduces a format string
error on 32-bit hosts:
/tmp/qemu-test/src/hw/i386/pc.c: In function 'load_linux':
/tmp/qemu-test/src/hw/i386/pc.c:983:29: error: format '%lld' expects
argument of type 'long long int', but argument 4 has type 'gsize {aka
unsigned int}' [-Werror=format=]
fprintf(stderr, "qemu: initrd is too large, cannot support."
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The underlying problem here is glib's weird insistance
on using its own types, which then interact badly
with everything else that's using standard POSIX types :-(
thanks
-- PMM
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-ppc] [Qemu-devel] [PATCH 05/10] hw/i386/pc.c: Don't use load_image(),
Peter Maydell <=