[Qemu-devel] [PATCH v2] hw/unicore32: remove wrong assertion in puv machine init

Suramya Shah posted 1 patch 7 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170330154413.22014-1-shah.suramya@gmail.com
Test checkpatch passed
There is a newer version of this series
hw/unicore32/puv3.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
[Qemu-devel] [PATCH v2] hw/unicore32: remove wrong assertion in puv machine init
Posted by Suramya Shah 7 years ago
Signed-off-by: Suramya Shah <shah.suramya@gmail.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>

Running QEMU with qemu-system-unicore32 without the kernel parameter results in an assertion error.
Assert should not be used to check user provided parameters. Report an error and exit instead
---
 hw/unicore32/puv3.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/unicore32/puv3.c b/hw/unicore32/puv3.c
index 032078f..2c17cc9 100644
--- a/hw/unicore32/puv3.c
+++ b/hw/unicore32/puv3.c
@@ -93,8 +93,11 @@ static void puv3_load_kernel(const char *kernel_filename)
     if (kernel_filename == NULL && qtest_enabled()) {
         return;
     }
-    assert(kernel_filename != NULL);
-
+    if (kernel_filename == NULL) {
+        error_report("No kernel found");
+        exit(1);
+    }
+
     /* only zImage format supported */
     size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR,
             KERNEL_MAX_SIZE);
-- 
2.9.3


Re: [Qemu-devel] [PATCH v2] hw/unicore32: remove wrong assertion in puv machine init
Posted by Marcel Apfelbaum 7 years ago
On 03/30/2017 06:44 PM, Suramya Shah wrote:

Hi,

> Signed-off-by: Suramya Shah <shah.suramya@gmail.com>

Please add the SOB after the description.

> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>

Please do not add a reviewer to your patch
unless he approved /added his signature by himself.

>
> Running QEMU with qemu-system-unicore32 without the kernel parameter results in an assertion error.
> Assert should not be used to check user provided parameters. Report an error and exit instead
> ---
>  hw/unicore32/puv3.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/hw/unicore32/puv3.c b/hw/unicore32/puv3.c
> index 032078f..2c17cc9 100644
> --- a/hw/unicore32/puv3.c
> +++ b/hw/unicore32/puv3.c
> @@ -93,8 +93,11 @@ static void puv3_load_kernel(const char *kernel_filename)
>      if (kernel_filename == NULL && qtest_enabled()) {
>          return;
>      }
> -    assert(kernel_filename != NULL);
> -
> +    if (kernel_filename == NULL) {
> +        error_report("No kernel found");
> +        exit(1);
> +    }
> +
>      /* only zImage format supported */
>      size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR,
>              KERNEL_MAX_SIZE);
>

The patch can't be applied, please create the patch with "git format patch".

Thanks,
Marcel