diff mbox series

[29/31] vl: Assert drive_new() does not fail in default_drive()

Message ID 20181008173125.19678-30-armbru@redhat.com
State New
Headers show
Series Replace some unwise uses of error_report() & friends | expand

Commit Message

Markus Armbruster Oct. 8, 2018, 5:31 p.m. UTC
If creating (empty) default drives fails, it's a bug.  Therefore,
assert() is more appropriate than exit(1).

Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 vl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Eric Blake Oct. 8, 2018, 8:48 p.m. UTC | #1
On 10/8/18 12:31 PM, Markus Armbruster wrote:
> If creating (empty) default drives fails, it's a bug.  Therefore,
> assert() is more appropriate than exit(1).
> 
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Max Reitz <mreitz@redhat.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>   vl.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)

The assert disappears in the next patch (replaced by an &error_fatal), 
but the separation of patches makes sense.

Reviewed-by: Eric Blake <eblake@redhat.com>
Max Reitz Oct. 8, 2018, 9:08 p.m. UTC | #2
On 08.10.18 19:31, Markus Armbruster wrote:
> If creating (empty) default drives fails, it's a bug.  Therefore,
> assert() is more appropriate than exit(1).
> 
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Max Reitz <mreitz@redhat.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  vl.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)

Reviewed-by: Max Reitz <mreitz@redhat.com>
diff mbox series

Patch

diff --git a/vl.c b/vl.c
index 4aa976c4cc..0d25956b2f 100644
--- a/vl.c
+++ b/vl.c
@@ -1156,9 +1156,7 @@  static void default_drive(int enable, int snapshot, BlockInterfaceType type,
     }
 
     dinfo = drive_new(opts, type);
-    if (!dinfo) {
-        exit(1);
-    }
+    assert(dinfo);
     dinfo->is_default = true;
 
 }