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

Alasdair G Kergon agk at redhat.com
Mon Nov 29 21:17:40 UTC 2010


On Thu, Nov 25, 2010 at 11:55:19AM +0100, Zdenek Kabelac wrote:
> 'data' is initialized as NULL and if 'dev' would be NULL from info->dev

If we hit that condition we must do a scan.

> 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);

This makes it fall through to the scan.
Ack.

Alasdair




More information about the lvm-devel mailing list