[lvm-devel] [PATCH 22/29] Ensure pointer first is notnull before dereference
Zdenek Kabelac
zkabelac at redhat.com
Thu Nov 25 10:55:26 UTC 2010
Modify code to put check into local function.
Old code expected _check_vgs had been give non empty pvs list which
should ensure some 'first' pointer is defined.
New code remove check for empty pvs list before call of _check_vgs
and leave this case to be handle inside this function - this
makes static analyzer less confused.
Signed-off-by: Zdenek Kabelac <zkabelac at redhat.com>
---
lib/format1/format1.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index 0dcec05..0745890 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -102,7 +102,10 @@ static int _check_vgs(struct dm_list *pvs, struct volume_group *vg)
pv_count++;
}
- /* On entry to fn, list known to be non-empty */
+ /* Empty pvs list is not valid */
+ if (!first)
+ return 0;
+
if (pv_count != first->vgd.pv_cur) {
log_error("%d PV(s) found for VG %s: expected %d",
pv_count, first->pvd.vg_name, first->vgd.pv_cur);
@@ -187,9 +190,6 @@ static struct volume_group *_build_vg(struct format_instance *fid,
if (!vg)
goto_bad;
- if (dm_list_empty(pvs))
- goto_bad;
-
vg->cmd = fid->fmt->cmd;
vg->vgmem = mem;
vg->fid = fid;
--
1.7.3.2
More information about the lvm-devel
mailing list