[dm-devel] [PATCH v3 09/19] libmultipath: remove unused code

Martin Wilck mwilck at suse.com
Mon Oct 1 21:28:16 UTC 2018


On Fri, 2018-09-21 at 18:05 -0500, Benjamin Marzinski wrote:
> since vector_foreach_slot() already checks if the entry is NULL,
> there's
> no point in checking it in the loop, since it can't be NULL there.
> Found
> by coverity.
> 
> Signed-off-by: Benjamin Marzinski <bmarzins at redhat.com>

Let's hope nobody ever removes that NULL check from
vector_foreach_slot()...

Reviewed-by: Martin Wilck <mwilck at suse.com>


> ---
>  libmultipath/print.c | 8 --------
>  1 file changed, 8 deletions(-)
> 
> diff --git a/libmultipath/print.c b/libmultipath/print.c
> index 9da6a77..7b610b9 100644
> --- a/libmultipath/print.c
> +++ b/libmultipath/print.c
> @@ -275,8 +275,6 @@ snprint_multipath_vpr (char * buff, size_t len,
> const struct multipath * mpp)
>  	int i, j;
>  
>  	vector_foreach_slot(mpp->pg, pgp, i) {
> -		if (!pgp)
> -			continue;
>  		vector_foreach_slot(pgp->paths, pp, j) {
>  			if (strlen(pp->vendor_id) && strlen(pp-
> >product_id))
>  				return snprintf(buff, len, "%s,%s",
> @@ -295,8 +293,6 @@ snprint_multipath_vend (char * buff, size_t len,
> const struct multipath * mpp)
>  	int i, j;
>  
>  	vector_foreach_slot(mpp->pg, pgp, i) {
> -		if (!pgp)
> -			continue;
>  		vector_foreach_slot(pgp->paths, pp, j) {
>  			if (strlen(pp->vendor_id))
>  				return snprintf(buff, len, "%s", pp-
> >vendor_id);
> @@ -313,8 +309,6 @@ snprint_multipath_prod (char * buff, size_t len,
> const struct multipath * mpp)
>  	int i, j;
>  
>  	vector_foreach_slot(mpp->pg, pgp, i) {
> -		if (!pgp)
> -			continue;
>  		vector_foreach_slot(pgp->paths, pp, j) {
>  			if (strlen(pp->product_id))
>  				return snprintf(buff, len, "%s", pp-
> >product_id);
> @@ -331,8 +325,6 @@ snprint_multipath_rev (char * buff, size_t len,
> const struct multipath * mpp)
>  	int i, j;
>  
>  	vector_foreach_slot(mpp->pg, pgp, i) {
> -		if (!pgp)
> -			continue;
>  		vector_foreach_slot(pgp->paths, pp, j) {
>  			if (strlen(pp->rev))
>  				return snprintf(buff, len, "%s", pp-
> >rev);

-- 
Dr. Martin Wilck <mwilck at suse.com>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)





More information about the dm-devel mailing list