Index: tools/lib/pv_read_all_pv_of_vg.c =================================================================== RCS file: /data/cvs/LVM/tools/lib/pv_read_all_pv_of_vg.c,v retrieving revision 1.4 diff -b -B -u -r1.4 pv_read_all_pv_of_vg.c --- tools/lib/pv_read_all_pv_of_vg.c 2001/04/24 14:29:21 1.4 +++ tools/lib/pv_read_all_pv_of_vg.c 2001/11/27 20:21:59 @@ -127,14 +127,12 @@ pv_this[p] = NULL; uuid_check_end: } - for ( pp = 0; pp < p - 2; pp++) { - if ( pv_this[pp] == NULL) { - pv_this[pp] = pv_this[pp+1]; - pv_this[pp+1] = NULL; - } - } - np = 0; - while ( pv_this[np] != NULL) np++; + + /* REMOVED 27-Nov-2001 Lars Kellogg-Stedman + * + * The list compacting code that was here was removed because + * we do the same thing further down in this function. + */ } /* avoid multiple access pathes */ @@ -158,21 +156,42 @@ } } } - /* make array contiguous again */ - for ( i = 0; i < np - 2; i++) { - if ( pv_this[i] == NULL) { - /* ensure we don't have a sequence of NULLs */ - if ( pv_this[i+1] == NULL) { - int j = i + 1; - while ( pv_this[j] == NULL && j < np - 1) j++; - if ( j < np - 1) pv_this[i+1] = pv_this[j]; } - pv_this[i] = pv_this[i+1]; - pv_this[i+1] = NULL; + + /* ADDED 27-Nov-2001 Lars Kellogg-Stedman + * + * Make arrays contiguous again. + * + * This replaces similar code that appeared in two places in the + * original version of this function. + */ + { + int i,j; + + debug("LKS: compacting PV list.\n"); + + for ( i=0, j=0; i < np - 1 && j < np; i++) { + if (pv_this[i] == NULL) { + /* find next non-null entry */ + if (j == 0) j = i + 1; + + for (;j < np; j++) { + if (pv_this[j] != NULL) { + pv_this[i] = pv_this[j]; + pv_this[j] = NULL; + + break; + } } } + } + np = 0; - while ( pv_this[np] != NULL) np++; + while ( pv_this[np] != NULL) { + debug("LKS: scanning found: %s\n", + pv_this[np]->pv_name); + np++; + } } /* now we only have pointers to single access path PVs