* [Qemu-devel] [PATCH v5] hw/unicore32: remove wrong assertion in puv machine init
@ 2017-03-30 16:50 Suramya Shah
2017-03-30 16:52 ` Marcel Apfelbaum
2017-03-31 12:55 ` Thomas Huth
0 siblings, 2 replies; 4+ messages in thread
From: Suramya Shah @ 2017-03-30 16:50 UTC (permalink / raw)
To: qemu-devel; +Cc: marcel, gxt, Suramya Shah
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
Signed-off-by: Suramya Shah <shah.suramya@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v5] hw/unicore32: remove wrong assertion in puv machine init
2017-03-30 16:50 [Qemu-devel] [PATCH v5] hw/unicore32: remove wrong assertion in puv machine init Suramya Shah
@ 2017-03-30 16:52 ` Marcel Apfelbaum
2017-03-31 1:47 ` Xuetao Guan
2017-03-31 12:55 ` Thomas Huth
1 sibling, 1 reply; 4+ messages in thread
From: Marcel Apfelbaum @ 2017-03-30 16:52 UTC (permalink / raw)
To: Suramya Shah, qemu-devel; +Cc: gxt
On 03/30/2017 07:50 PM, Suramya Shah wrote:
> 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
> Signed-off-by: Suramya Shah <shah.suramya@gmail.com>
> ---
> 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);
>
Hi,
The patch looks good to me.
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Thanks,
Marcel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v5] hw/unicore32: remove wrong assertion in puv machine init
2017-03-30 16:52 ` Marcel Apfelbaum
@ 2017-03-31 1:47 ` Xuetao Guan
0 siblings, 0 replies; 4+ messages in thread
From: Xuetao Guan @ 2017-03-31 1:47 UTC (permalink / raw)
To: Marcel Apfelbaum; +Cc: Suramya Shah, qemu-devel, gxt
> On 03/30/2017 07:50 PM, Suramya Shah wrote:
>> 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
>> Signed-off-by: Suramya Shah <shah.suramya@gmail.com>
Thanks Suramya
Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
>> ---
>> 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);
>>
>
> Hi,
>
> The patch looks good to me.
>
> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
>
> Thanks,
> Marcel
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v5] hw/unicore32: remove wrong assertion in puv machine init
2017-03-30 16:50 [Qemu-devel] [PATCH v5] hw/unicore32: remove wrong assertion in puv machine init Suramya Shah
2017-03-30 16:52 ` Marcel Apfelbaum
@ 2017-03-31 12:55 ` Thomas Huth
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Huth @ 2017-03-31 12:55 UTC (permalink / raw)
To: Suramya Shah, qemu-devel; +Cc: marcel, gxt
On 30.03.2017 18:50, Suramya Shah wrote:
> 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
> Signed-off-by: Suramya Shah <shah.suramya@gmail.com>
Nit: There should be a blank line between the description and the
"Signed-off-by" line.
And another nit: Since some people are still using 80-columns terminal
windows, it's also nicer to wrap the description at the 80 columns
barrier (or even 76 columns already) 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");
It's maybe better to give clear instructions to the user, like:
"Need a kernel, please provide one with the '-kernel' option"
> + exit(1);
> + }
> +
> /* only zImage format supported */
> size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR,
> KERNEL_MAX_SIZE);
>
Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-31 12:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-30 16:50 [Qemu-devel] [PATCH v5] hw/unicore32: remove wrong assertion in puv machine init Suramya Shah
2017-03-30 16:52 ` Marcel Apfelbaum
2017-03-31 1:47 ` Xuetao Guan
2017-03-31 12:55 ` Thomas Huth
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).