summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/label.c
diff options
context:
space:
mode:
authorKarel Zak2015-08-04 13:03:14 +0200
committerKarel Zak2015-08-04 13:03:14 +0200
commit1c3c92cd8dbfb856d4262c90ed55c107e21ac408 (patch)
treec6caa150a76bedf6447b09a781c3f1fdab483ae4 /libfdisk/src/label.c
parentlibblkid: remove dead code [coverity scan] (diff)
downloadkernel-qcow2-util-linux-1c3c92cd8dbfb856d4262c90ed55c107e21ac408.tar.gz
kernel-qcow2-util-linux-1c3c92cd8dbfb856d4262c90ed55c107e21ac408.tar.xz
kernel-qcow2-util-linux-1c3c92cd8dbfb856d4262c90ed55c107e21ac408.zip
libfdisk: cleanup assert() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/label.c')
-rw-r--r--libfdisk/src/label.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/libfdisk/src/label.c b/libfdisk/src/label.c
index 92b82cc18..d3009f5cb 100644
--- a/libfdisk/src/label.c
+++ b/libfdisk/src/label.c
@@ -121,12 +121,10 @@ int fdisk_label_get_fields_ids(
size_t i, n;
int *c;
- assert(cxt);
-
- if (!lb)
- lb = cxt->label;
- if (!lb)
+ if (!cxt || (!lb && !cxt->label))
return -EINVAL;
+
+ lb = cxt->label;
if (!lb->fields || !lb->nfields)
return -ENOSYS;
c = calloc(lb->nfields, sizeof(int));
@@ -175,12 +173,10 @@ int fdisk_label_get_fields_ids_all(
size_t i, n;
int *c;
- assert(cxt);
-
- if (!lb)
- lb = cxt->label;
- if (!lb)
+ if (!cxt || (!lb && !cxt->label))
return -EINVAL;
+
+ lb = cxt->label;
if (!lb->fields || !lb->nfields)
return -ENOSYS;
c = calloc(lb->nfields, sizeof(int));