multipath-tools: fix minor compilation issues
PATCH 1/1 multipath-tools: fix minor compilation issues
Hi Christophe,
our checker found some minor issues:
- refwwid in libmultipath/configure.c:get_refwwid() might be used uninitialized. As dev_type is a simple 'int' there is nothing which prevents the unsuspecting user to call it with an unhandled value. We shoud rather use an enum and set refwwid to NULL to be on the safe side.
- attr in libmultipath/discovery.c:devt2devname() might be used uninitialized. Quite unlikely, but might happen in principle. So better have it initialized.
- r in multipath/main.c:main() might be used uninitialized. True. So have it initialized.
Please apply.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke [email protected] SuSE Linux Products GmbH S390 & zSeries Maxfeldstraße 5 +49 911 74053 688 90409 Nürnberg http://www.suse.de
libmultipath/config.h +1 -1
@@ -48,7 +48,7 @@ struct config {int with_sysfs;int pgpolicy;struct checker * checker; -int dev_type; +enum devtypes dev_type;int minio;int checkint;int max_checkint;
libmultipath/configure.c +2 -2
@@ -547,11 +547,11 @@ coalesce_paths (struct vectors * vecs, v }extern char * -get_refwwid (char * dev,int dev_type,vector pathvec) +get_refwwid (char * dev,enum devtypes dev_type,vector pathvec) {struct path * pp;char buff[FILE_NAME_SIZE ]; -char * refwwid; +char * refwwid =NULL ;if (dev_type ==DEV_NONE )return NULL ;
libmultipath/configure.h +1 -1
@@ -25,5 +25,5 @@ int setup_map (struct multipath * mpp);int domap (struct multipath * mpp);int reinstate_paths (struct multipath *mpp);int coalesce_paths (struct vectors *vecs,vector curmp,char * refwwid); -char *get_refwwid (char * dev,int dev_type,vector pathvec); +char *get_refwwid (char * dev,enum devtypes dev_type,vector pathvec);
libmultipath/discovery.c +1 -1
@@ -237,7 +237,7 @@ devt2devname (char *devname, char *devt)struct dlist * ls;char attr_path[FILE_NAME_SIZE ];char block_path[FILE_NAME_SIZE ]; -struct sysfs_attribute * attr; +struct sysfs_attribute * attr =NULL ;struct sysfs_class * class;struct sysfs_class_device * dev;
libmultipath/print.c +1 -1
@@ -13,8 +13,8 @@#include "structs_vec.h" #include "print.h" #include "dmparser.h" -#include "configure.h" #include "config.h" +#include "configure.h" #include "pgpolicies.h" #include "defaults.h" #include "parser.h"
multipath/main.c +1 -1
@@ -305,7 +305,7 @@ main (int argc, char *argv[])int arg;extern char *optarg;extern int optind; -int i, r; +int i, r =1 ;if (getuid () !=0 ) {fprintf (stderr,"need to be root\n" );
Christophe Varoqui
AppliedQuoted 15 lines · Hannes Reinecke
Hi Christophe,
our checker found some minor issues:
- refwwid in libmultipath/configure.c:get_refwwid() might be used uninitialized. As
dev_typeis a simple 'int' there is nothing which prevents the unsuspecting user to call it with an unhandled value. We shoud rather use an enum and set refwwid to NULL to be on the safe side.
- attr in libmultipath/discovery.c:devt2devname() might be used uninitialized. Quite unlikely, but might happen in principle. So better have it initialized.
- r in multipath/main.c:main() might be used uninitialized. True. So have it initialized.
Quoted 2 lines
Please apply.
Applied, thanks.
Regards,
cvaroqui