aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2010-12-16 15:37:41 +0100
committerKevin Wolf <kwolf@redhat.com>2010-12-17 16:11:03 +0100
commitad7171394f2fe3f9b5fe02f0c62496291a859a92 (patch)
treefe0487891f82d023bb3cdc12dba037a48ad2424d
parent15654a6d7c3269e922b92f9596e48078c9bfcbfa (diff)
Remove NULL checks for bdrv_new return value
It's an indirect call to qemu_malloc, which never returns an error. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--hw/xen_disk.c17
-rw-r--r--qemu-img.c5
-rw-r--r--qemu-io.c2
-rw-r--r--qemu-nbd.c2
4 files changed, 7 insertions, 19 deletions
diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index 85a1c85524..ed9e5eb4d7 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -634,17 +634,12 @@ static int blk_init(struct XenDevice *xendev)
if (!blkdev->dinfo) {
/* setup via xenbus -> create new block driver instance */
xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
- blkdev->bs = bdrv_new(blkdev->dev);
- if (blkdev->bs) {
- if (bdrv_open(blkdev->bs, blkdev->filename, qflags,
- bdrv_find_whitelisted_format(blkdev->fileproto))
- != 0) {
- bdrv_delete(blkdev->bs);
- blkdev->bs = NULL;
- }
- }
- if (!blkdev->bs)
- return -1;
+ blkdev->bs = bdrv_new(blkdev->dev);
+ if (bdrv_open(blkdev->bs, blkdev->filename, qflags,
+ bdrv_find_whitelisted_format(blkdev->fileproto)) != 0) {
+ bdrv_delete(blkdev->bs);
+ return -1;
+ }
} else {
/* setup via qemu cmdline -> already setup for us */
xen_be_printf(&blkdev->xendev, 2, "get configured bdrv (cmdline setup)\n");
diff --git a/qemu-img.c b/qemu-img.c
index 0b871d842c..afd9ed2e0e 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -215,10 +215,7 @@ static BlockDriverState *bdrv_new_open(const char *filename,
char password[256];
bs = bdrv_new("");
- if (!bs) {
- error_report("Not enough memory");
- goto fail;
- }
+
if (fmt) {
drv = bdrv_find_format(fmt);
if (!drv) {
diff --git a/qemu-io.c b/qemu-io.c
index ff353ebba3..0f6d1b6b23 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -1509,8 +1509,6 @@ static int openfile(char *name, int flags, int growable)
}
} else {
bs = bdrv_new("hda");
- if (!bs)
- return 1;
if (bdrv_open(bs, name, flags, NULL) < 0) {
fprintf(stderr, "%s: can't open device %s\n", progname, name);
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 99f1d22884..e858033e06 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -336,8 +336,6 @@ int main(int argc, char **argv)
bdrv_init();
bs = bdrv_new("hda");
- if (bs == NULL)
- return 1;
if ((ret = bdrv_open(bs, argv[optind], flags, NULL)) < 0) {
errno = -ret;