From 3941cbcb97446a72c096da27171a3144a36fdfb7 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 12 May 2023 14:46:59 +0200 Subject: Adding upstream version 4.2+20230508. Signed-off-by: Daniel Baumann --- config.c | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'config.c') diff --git a/config.c b/config.c index eeedd0c..450880e 100644 --- a/config.c +++ b/config.c @@ -119,6 +119,18 @@ int match_keyword(char *word) return -1; } +/** + * is_devname_ignore() - check if &devname is a special "" keyword. + */ +bool is_devname_ignore(char *devname) +{ + static const char keyword[] = ""; + + if (strcasecmp(devname, keyword) == 0) + return true; + return false; +} + /** * ident_init() - Set defaults. * @ident: ident pointer, not NULL. @@ -373,17 +385,6 @@ void devline(char *line) struct mddev_ident *mddevlist = NULL; struct mddev_ident **mddevlp = &mddevlist; -static int is_number(char *w) -{ - /* check if there are 1 or more digits and nothing else */ - int digits = 0; - while (*w && isdigit(*w)) { - digits++; - w++; - } - return (digits && ! *w); -} - void arrayline(char *line) { char *w; @@ -404,13 +405,11 @@ void arrayline(char *line) * * or anything that doesn't start '/' or '<' */ - if (strcasecmp(w, "") == 0 || - strncmp(w, "/dev/md/", 8) == 0 || + if (is_devname_ignore(w) == true || + strncmp(w, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0 || (w[0] != '/' && w[0] != '<') || - (strncmp(w, "/dev/md", 7) == 0 && - is_number(w + 7)) || - (strncmp(w, "/dev/md_d", 9) == 0 && - is_number(w + 9))) { + is_devname_md_numbered(w) == true || + is_devname_md_d_numbered(w) == true) { /* This is acceptable */; if (mis.devname) pr_err("only give one device per ARRAY line: %s and %s\n", @@ -571,7 +570,7 @@ void homehostline(char *line) char *w; for (w = dl_next(line); w != line; w = dl_next(w)) { - if (strcasecmp(w, "") == 0) + if (is_devname_ignore(w) == true) require_homehost = 0; else if (home_host == NULL) { if (strcasecmp(w, "") == 0) @@ -1102,13 +1101,13 @@ int devname_matches(char *name, char *match) * mdNN with NN * then just strcmp */ - if (strncmp(name, "/dev/md/", 8) == 0) - name += 8; + if (strncmp(name, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0) + name += DEV_MD_DIR_LEN; else if (strncmp(name, "/dev/", 5) == 0) name += 5; - if (strncmp(match, "/dev/md/", 8) == 0) - match += 8; + if (strncmp(match, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0) + match += DEV_MD_DIR_LEN; else if (strncmp(match, "/dev/", 5) == 0) match += 5; -- cgit v1.2.3