Make mdconfig(8) WARNS=6 clean:

- Constify geom_config_get() name argument.
- Add void keyword for usage().
- Initialize mdunit to NULL.
- Don't call md_prthumanval() at all if length is NULL.

Approved by:	trasz (mentor)
This commit is contained in:
Jaakko Heinonen 2010-01-22 08:51:58 +00:00
parent e48fbf26e8
commit a4ca6a4926
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=202784
2 changed files with 6 additions and 8 deletions

View File

@ -4,7 +4,6 @@ PROG= mdconfig
MAN= mdconfig.8 MAN= mdconfig.8
MLINKS= mdconfig.8 vnconfig.8 MLINKS= mdconfig.8 vnconfig.8
WARNS?= 2
DPADD= ${LIBUTIL} ${LIBGEOM} ${LIBBSDXML} ${LIBSBUF} DPADD= ${LIBUTIL} ${LIBGEOM} ${LIBBSDXML} ${LIBSBUF}
LDADD= -lutil -lgeom -lbsdxml -lsbuf LDADD= -lutil -lgeom -lbsdxml -lsbuf

View File

@ -41,7 +41,7 @@ static void usage(void);
static int md_find(char *, const char *); static int md_find(char *, const char *);
static int md_query(char *name); static int md_query(char *name);
static int md_list(char *units, int opt); static int md_list(char *units, int opt);
static char *geom_config_get(struct gconf *g, char *name); static char *geom_config_get(struct gconf *g, const char *name);
static void md_prthumanval(char *length); static void md_prthumanval(char *length);
#define OPT_VERBOSE 0x01 #define OPT_VERBOSE 0x01
@ -52,7 +52,7 @@ static void md_prthumanval(char *length);
#define CLASS_NAME_MD "MD" #define CLASS_NAME_MD "MD"
static void static void
usage() usage(void)
{ {
fprintf(stderr, fprintf(stderr,
"usage: mdconfig -a -t type [-n] [-o [no]option] ... [-f file]\n" "usage: mdconfig -a -t type [-n] [-o [no]option] ... [-f file]\n"
@ -74,7 +74,7 @@ main(int argc, char **argv)
int ch, fd, i, vflag; int ch, fd, i, vflag;
char *p; char *p;
int cmdline = 0; int cmdline = 0;
char *mdunit; char *mdunit = NULL;
bzero(&mdio, sizeof(mdio)); bzero(&mdio, sizeof(mdio));
mdio.md_file = malloc(PATH_MAX); mdio.md_file = malloc(PATH_MAX);
@ -379,10 +379,9 @@ md_list(char *units, int opt)
if (strcmp(type, "vnode") == 0) if (strcmp(type, "vnode") == 0)
file = geom_config_get(gc, "file"); file = geom_config_get(gc, "file");
length = geom_config_get(gc, "length"); length = geom_config_get(gc, "length");
if (length == NULL)
length = "<a>";
printf("\t%s\t", type); printf("\t%s\t", type);
md_prthumanval(length); if (length != NULL)
md_prthumanval(length);
if (file != NULL) { if (file != NULL) {
printf("\t%s", file); printf("\t%s", file);
file = NULL; file = NULL;
@ -409,7 +408,7 @@ md_list(char *units, int opt)
* Returns value of 'name' from gconfig structure. * Returns value of 'name' from gconfig structure.
*/ */
static char * static char *
geom_config_get(struct gconf *g, char *name) geom_config_get(struct gconf *g, const char *name)
{ {
struct gconfig *gce; struct gconfig *gce;