From: Stefan Hajnoczi <stefanha@redhat.com>
To: rutu.shah.26@gmail.com
Cc: mark.cave-ayland@ilande.co.uk, qemu-devel@nongnu.org,
chouteau@adacore.com, agraf@suse.de, blauwirbel@gmail.com,
qemu-ppc@nongnu.org, scottwood@freescale.com
Subject: Re: [Qemu-devel] [PATCH] Added NULL check for qemu_find_file()
Date: Mon, 14 Mar 2016 11:44:13 +0000 [thread overview]
Message-ID: <20160314114413.GB27203@stefanha-x1.localdomain> (raw)
In-Reply-To: <1457814994-10698-1-git-send-email-rutu.shah.26@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3117 bytes --]
On Sun, Mar 13, 2016 at 02:06:34AM +0530, rutu.shah.26@gmail.com wrote:
> From: Rutuja Shah <rutu.shah.26@gmail.com>
>
> This patch adds NULL check for return value from qemu_find_file(), where it is missing. It avoids unnecessary function calls with NULL parameter which in turn return -1. Especially, incase of load_uimage(), two functions are called which return -1 on passing NULL filename.
What is the benefit of adding the NULL checks? The only difference I
see is that the error message from load_elf() is silenced.
Avoiding unnecessary function calls isn't worthwhile if all callers now
duplicate the if (filename) ... else size = -1 code.
Please wrap the commit description (the body of the commit message) to
72 characters or at most 80 characters.
Please include your Signed-off-by line here:
http://qemu-project.org/Contribute/SubmitAPatch#Patch_emails_must_include_a_Signed-off-by:_line
> ---
> hw/ppc/e500.c | 17 +++++++++++++----
> hw/sparc/leon3.c | 6 +++++-
> 2 files changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
> index 09154fa..006adf1 100644
> --- a/hw/ppc/e500.c
> +++ b/hw/ppc/e500.c
> @@ -1016,15 +1016,24 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
> }
> filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
>
> - bios_size = load_elf(filename, NULL, NULL, &bios_entry, &loadaddr, NULL,
> - 1, PPC_ELF_MACHINE, 0, 0);
> + if (filename) {
> + bios_size = load_elf(filename, NULL, NULL, &bios_entry, &loadaddr, NULL,
> + 1, PPC_ELF_MACHINE, 0, 0);
> + } else {
> + bios_size = -1;
> + }
> +
> if (bios_size < 0) {
> /*
> * Hrm. No ELF image? Try a uImage, maybe someone is giving us an
> * ePAPR compliant kernel
> */
> - kernel_size = load_uimage(filename, &bios_entry, &loadaddr, NULL,
> - NULL, NULL);
> + if (filename) {
> + kernel_size = load_uimage(filename, &bios_entry, &loadaddr, NULL,
> + NULL, NULL);
> + } else {
> + kernel_size = -1;
> + }
> if (kernel_size < 0) {
> fprintf(stderr, "qemu: could not load firmware '%s'\n", filename);
> exit(1);
> diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
> index c579f5b..b4e9334 100644
> --- a/hw/sparc/leon3.c
> +++ b/hw/sparc/leon3.c
> @@ -168,7 +168,11 @@ static void leon3_generic_hw_init(MachineState *machine)
> }
> filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
>
> - bios_size = get_image_size(filename);
> + if (filename) {
> + bios_size = get_image_size(filename);
> + } else {
> + bios_size = -1;
> + }
>
> if (bios_size > prom_size) {
> fprintf(stderr, "qemu: could not load prom '%s': file too big\n",
>
> 1.9.1
>
> Signed-off-by: Rutuja Shah <rutu.shah.26@gmail.com>
>
> Regards
> Rutuja Shah
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2016-03-14 11:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-12 20:36 [Qemu-devel] [PATCH] Added NULL check for qemu_find_file() rutu.shah.26
2016-03-14 11:44 ` Stefan Hajnoczi [this message]
2016-03-14 12:59 ` rutuja shah
2016-03-15 12:31 ` Stefan Hajnoczi
2016-03-15 12:56 ` rutuja shah
2016-03-16 11:35 ` Stefan Hajnoczi
2016-03-14 15:34 ` Eric Blake
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=20160314114413.GB27203@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=agraf@suse.de \
--cc=blauwirbel@gmail.com \
--cc=chouteau@adacore.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=rutu.shah.26@gmail.com \
--cc=scottwood@freescale.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).