diff mbox series

[v8,05/15] hw/i386/pc: avoid an assignment in if condition in x86_load_linux()

Message ID 20191010143125.67246-6-slp@redhat.com
State New
Headers show
Series [v8,01/15] hw/virtio: Factorize virtio-mmio headers | expand

Commit Message

Sergio Lopez Oct. 10, 2019, 2:31 p.m. UTC
Follow checkpatch.pl recommendation an avoid an assignment in if
condition in x86_load_linux().

Signed-off-by: Sergio Lopez <slp@redhat.com>
---
 hw/i386/pc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé Oct. 10, 2019, 3:39 p.m. UTC | #1
On 10/10/19 4:31 PM, Sergio Lopez wrote:
> Follow checkpatch.pl recommendation an avoid an assignment in if

Paolo, do you mind fixing: "and avoid"? Thanks!

> condition in x86_load_linux().
> 
> Signed-off-by: Sergio Lopez <slp@redhat.com>
> ---
>   hw/i386/pc.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index e6bcc3ff42..90e2d68096 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -1045,7 +1045,14 @@ static void x86_load_linux(PCMachineState *pcms,
>   
>       /* load the kernel header */
>       f = fopen(kernel_filename, "rb");
> -    if (!f || !(kernel_size = get_file_size(f)) ||
> +    if (!f) {
> +        fprintf(stderr, "qemu: could not open kernel file '%s': %s\n",
> +                kernel_filename, strerror(errno));
> +        exit(1);
> +    }
> +
> +    kernel_size = get_file_size(f);
> +    if (!kernel_size ||
>           fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) !=
>           MIN(ARRAY_SIZE(header), kernel_size)) {
>           fprintf(stderr, "qemu: could not load kernel '%s': %s\n",
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
diff mbox series

Patch

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e6bcc3ff42..90e2d68096 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1045,7 +1045,14 @@  static void x86_load_linux(PCMachineState *pcms,
 
     /* load the kernel header */
     f = fopen(kernel_filename, "rb");
-    if (!f || !(kernel_size = get_file_size(f)) ||
+    if (!f) {
+        fprintf(stderr, "qemu: could not open kernel file '%s': %s\n",
+                kernel_filename, strerror(errno));
+        exit(1);
+    }
+
+    kernel_size = get_file_size(f);
+    if (!kernel_size ||
         fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) !=
         MIN(ARRAY_SIZE(header), kernel_size)) {
         fprintf(stderr, "qemu: could not load kernel '%s': %s\n",