Skip to contentSkip to conversation

hw/unicore32: remove wrong assertion in puv machine init

PATCH Superseded Suramya Shah 2 participants 2 messages Mar 30, 2017

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hw/unicore32: remove wrong assertion in puv machine init

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(-)
hw/unicore32/puv3.c +5 -2
index 032078f..2c17cc9 100644
@@ -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);
Signature · 1 line
2.9.3
#1 lore raw

On 03/30/2017 06:44 PM, Suramya Shah wrote:

Hi,

Quoted 1 line

Please add the SOB after the description.

Quoted 1 line

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

Quoted 16 lines

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(-)
hw/unicore32/puv3.c +0 -0
index 032078f..2c17cc9 100644
@@ -93,8 +93,11 @@ static void puv3_load_kernel(const char *kernel_filename)
     if (kernel_filename == NULL && qtest_enabled()) {
         return;
     }

hw/unicore32/puv3.c static void puv3_load_kernel(const char *kernel_filename) · line 103

Quoted 10 lines
hw/unicore32/puv3.c +5 -2
-    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