config: Various stylistic cleanups

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
This commit is contained in:
Jes Sorensen 2016-08-11 15:48:09 -04:00
parent 6a674388f8
commit 421c6c047e
1 changed files with 111 additions and 107 deletions

View File

@ -106,11 +106,13 @@ int match_keyword(char *word)
int len = strlen(word);
int n;
if (len < 3) return -1;
if (len < 3)
return -1;
for (n = 0; keywords[n]; n++) {
if (strncasecmp(word, keywords[n], len) == 0)
return n;
}
return -1;
}
@ -124,6 +126,7 @@ struct mddev_dev *load_partitions(void)
FILE *f = fopen("/proc/partitions", "r");
char buf[1024];
struct mddev_dev *rv = NULL;
if (f == NULL) {
pr_err("cannot open /proc/partitions\n");
return NULL;
@ -218,7 +221,8 @@ int parse_auto(char *str, char *msg, int config)
e--;
if (*e) {
num = atoi(e);
if (num <= 0) num = 1;
if (num <= 0)
num = 1;
}
if (e > str && e[-1] == '-')
e--;
@ -264,7 +268,8 @@ static void createline(char *line)
if (pw)
createinfo.uid = pw->pw_uid;
else
pr_err("CREATE user %s not found\n", w+6);
pr_err("CREATE user %s not found\n",
w + 6);
}
} else if (strncasecmp(w, "group=", 6) == 0) {
if (w[6] == 0) {
@ -279,7 +284,8 @@ static void createline(char *line)
if (gr)
createinfo.gid = gr->gr_gid;
else
pr_err("CREATE group %s not found\n", w+6);
pr_err("CREATE group %s not found\n",
w + 6);
}
} else if (strncasecmp(w, "mode=", 5) == 0) {
if (w[5] == 0) {
@ -296,8 +302,7 @@ static void createline(char *line)
/* style of metadata to use by default */
int i;
for (i = 0; superlist[i] && !createinfo.supertype; i++)
createinfo.supertype =
superlist[i]->match_metadata_desc(w+9);
createinfo.supertype = superlist[i]->match_metadata_desc(w + 9);
if (!createinfo.supertype)
pr_err("metadata format %s unknown, ignoring\n",
w+9);
@ -333,8 +338,7 @@ void devline(char *line)
cd->next = cdevlist;
cdevlist = cd;
} else {
pr_err("unreconised word on DEVICE line: %s\n",
w);
pr_err("unreconised word on DEVICE line: %s\n", w);
}
}
}
@ -394,8 +398,7 @@ void arrayline(char *line)
(strncmp(w, "/dev/md", 7) == 0 &&
is_number(w + 7)) ||
(strncmp(w, "/dev/md_d", 9) == 0 &&
is_number(w+9))
) {
is_number(w + 9))) {
/* This is acceptable */;
if (mis.devname)
pr_err("only give one device per ARRAY line: %s and %s\n",
@ -474,10 +477,12 @@ void arrayline(char *line)
int i;
for(i=0; superlist[i] && !mis.st; i++)
mis.st = superlist[i]->match_metadata_desc(w+9);
mis.st = superlist[i]->
match_metadata_desc(w + 9);
if (!mis.st)
pr_err("metadata format %s unknown, ignored.\n", w+9);
pr_err("metadata format %s unknown, ignored.\n",
w + 9);
} else if (strncasecmp(w, "auto=", 5) == 0 ) {
/* whether to create device special files as needed */
mis.autof = parse_auto(w + 5, "auto type", 0);
@ -485,8 +490,8 @@ void arrayline(char *line)
/* subarray within a container */
mis.member = xstrdup(w + 7);
} else if (strncasecmp(w, "container=", 10) == 0) {
/* the container holding this subarray. Either a device name
* or a uuid */
/* The container holding this subarray.
* Either a device name or a uuid */
mis.container = xstrdup(w + 10);
} else {
pr_err("unrecognised word on ARRAY line: %s\n",
@ -496,7 +501,8 @@ void arrayline(char *line)
if (mis.uuid_set == 0 && mis.devices == NULL &&
mis.super_minor == UnSet && mis.name[0] == 0 &&
(mis.container == NULL || mis.member == NULL))
pr_err("ARRAY line %s has no identity information.\n", mis.devname);
pr_err("ARRAY line %s has no identity information.\n",
mis.devname);
else {
mi = xmalloc(sizeof(*mi));
*mi = mis;
@ -597,7 +603,9 @@ void autoline(char *line)
return;
auto_seen = 1;
/* Parse the 'auto' line creating policy statements for the 'auto' policy.
/*
* Parse the 'auto' line creating policy statements for the 'auto'
* policy.
*
* The default is 'yes' but the 'auto' line might over-ride that.
* Words in the line are processed in order with the first
@ -623,7 +631,8 @@ void autoline(char *line)
* been seen gets an appropriate auto= entry.
*/
/* If environment variable MDADM_CONF_AUTO is defined, then
/*
* If environment variable MDADM_CONF_AUTO is defined, then
* it is prepended to the auto line. This allow a script
* to easily disable some metadata types.
*/
@ -682,8 +691,7 @@ void autoline(char *line)
if (strcasecmp(w + 1, version) == 0)
break;
/* 1 matches 1.x, 0 matches 0.90 */
if (version[1] == '.' &&
strlen(w+1) == 1 &&
if (version[1] == '.' && strlen(w + 1) == 1 &&
w[1] == version[0])
break;
/* 1.anything matches 1.x */
@ -697,12 +705,14 @@ void autoline(char *line)
if (seen[i])
/* already know about this metadata */
continue;
policy_add(rule_policy, pol_auto, val, pol_metadata, superlist[i]->name, NULL);
policy_add(rule_policy, pol_auto, val, pol_metadata,
superlist[i]->name, NULL);
seen[i] = 1;
}
for (i = 0; i < super_cnt; i++)
if (!seen[i])
policy_add(rule_policy, pol_auto, dflt, pol_metadata, superlist[i]->name, NULL);
policy_add(rule_policy, pol_auto, dflt, pol_metadata,
superlist[i]->name, NULL);
free(seen);
}
@ -847,8 +857,7 @@ void load_conffile(void)
* have a working mdadm, we read /etc/mdadm/mdadm.conf
* if /etc/mdadm.conf doesn't exist
*/
if (f == NULL &&
conffile == DefaultConfFile) {
if (f == NULL && conffile == DefaultConfFile) {
f = fopen(DefaultAltConfFile, "r");
if (f) {
conffile = DefaultAltConfFile;
@ -921,8 +930,8 @@ struct mddev_ident *conf_get_ident(char *dev)
struct mddev_ident *rv;
load_conffile();
rv = mddevlist;
while (dev && rv && (rv->devname == NULL
|| !devname_matches(dev, rv->devname)))
while (dev && rv && (rv->devname == NULL ||
!devname_matches(dev, rv->devname)))
rv = rv->next;
return rv;
}
@ -1068,11 +1077,9 @@ int devname_matches(char *name, char *match)
else if (strncmp(match, "/dev/", 5) == 0)
match += 5;
if (strncmp(name, "md", 2) == 0 &&
isdigit(name[2]))
if (strncmp(name, "md", 2) == 0 && isdigit(name[2]))
name += 2;
if (strncmp(match, "md", 2) == 0 &&
isdigit(match[2]))
if (strncmp(match, "md", 2) == 0 && isdigit(match[2]))
match += 2;
return (strcmp(name, match) == 0);
@ -1095,8 +1102,7 @@ int conf_name_is_free(char *name)
if (dev->name[0] && devname_matches(name, dev->name))
return 0;
sprintf(nbuf, "%d", dev->super_minor);
if (dev->super_minor != UnSet &&
devname_matches(name, nbuf))
if (dev->super_minor != UnSet && devname_matches(name, nbuf))
return 0;
}
return 1;
@ -1140,10 +1146,8 @@ struct mddev_ident *conf_match(struct supertype *st,
array_list->devname);
continue;
}
if (!array_list->uuid_set &&
!array_list->name[0] &&
!array_list->devices &&
array_list->super_minor == UnSet) {
if (!array_list->uuid_set && !array_list->name[0] &&
!array_list->devices && array_list->super_minor == UnSet) {
if (verbose >= 2 && array_list->devname)
pr_err("%s doesn't have any identifying information.\n",
array_list->devname);