Skip to content

Commit

Permalink
Remove useless NULL checks for qemu_malloc return value
Browse files Browse the repository at this point in the history
Found with this Coccinelle semantic patch:
@@
expression E;
identifier ptr;
identifier fn ~= "qemu_mallocz*";
@@

-ptr = fn(E);
-if (ptr == NULL) { ... }
-
+ptr = fn(E);

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
  • Loading branch information
blueswirl committed Aug 19, 2010
1 parent 760e77e commit 8e00128
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions vl.c
Expand Up @@ -2316,12 +2316,6 @@ int main(int argc, char **argv, char **envp)
len += strlen(qemu_opt_get(opts, "security_model"));
arg_fsdev = qemu_malloc((len + 1) * sizeof(*arg_fsdev));

if (!arg_fsdev) {
fprintf(stderr, "No memory to parse -fsdev for %s\n",
optarg);
exit(1);
}

sprintf(arg_fsdev, "%s,id=%s,path=%s,security_model=%s",
qemu_opt_get(opts, "fstype"),
qemu_opt_get(opts, "mount_tag"),
Expand All @@ -2332,12 +2326,6 @@ int main(int argc, char **argv, char **envp)
len += 2*strlen(qemu_opt_get(opts, "mount_tag"));
arg_9p = qemu_malloc((len + 1) * sizeof(*arg_9p));

if (!arg_9p) {
fprintf(stderr, "No memory to parse -device for %s\n",
optarg);
exit(1);
}

sprintf(arg_9p, "virtio-9p-pci,fsdev=%s,mount_tag=%s",
qemu_opt_get(opts, "mount_tag"),
qemu_opt_get(opts, "mount_tag"));
Expand Down

0 comments on commit 8e00128

Please sign in to comment.