[lvm-devel] [PATCH 15/29] Modify test to catch passing NULL pointer

Zdenek Kabelac zkabelac at redhat.com
Thu Nov 25 10:55:19 UTC 2010


Reason for this change is to avoid passing NULL 'data' to
_add_pv_to_list().

'data' is initialized as NULL and if 'dev' would be NULL from info->dev
'data' assignement would skipped and NULL would be passed through.
Also it would not make big sence to pass 'data' pointer twice in case
'dev' would be NULL.

Another fix could be that 'dev' could never be NULL in this place - so
the test could be to completely removed?

Signed-off-by: Zdenek Kabelac <zkabelac at redhat.com>
---
 lib/format1/disk-rep.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/format1/disk-rep.c b/lib/format1/disk-rep.c
index bc58744..071b39d 100644
--- a/lib/format1/disk-rep.c
+++ b/lib/format1/disk-rep.c
@@ -471,7 +471,7 @@ int read_pvs_in_vg(const struct format_type *fmt, const char *vg_name,
 	    vginfo->infos.n) {
 		dm_list_iterate_items(info, &vginfo->infos) {
 			dev = info->dev;
-			if (dev && !(data = read_disk(fmt, dev, mem, vg_name)))
+			if (!dev || !(data = read_disk(fmt, dev, mem, vg_name)))
 				break;
 			_add_pv_to_list(head, data);
 		}
-- 
1.7.3.2




More information about the lvm-devel mailing list