From 7b3b691ba69b909ea8c172aae693fa2a6938fd14 Mon Sep 17 00:00:00 2001 From: Mariusz Tkaczyk Date: Thu, 23 Mar 2023 17:50:16 +0100 Subject: mdadm: define is_devname_ignore() Use function instead of direct checks across code. Signed-off-by: Mariusz Tkaczyk Signed-off-by: Jes Sorensen --- config.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'config.c') diff --git a/config.c b/config.c index f44cc1d3..e61c0496 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. @@ -404,7 +416,7 @@ void arrayline(char *line) * * or anything that doesn't start '/' or '<' */ - if (strcasecmp(w, "") == 0 || + if (is_devname_ignore(w) == true || strncmp(w, DEV_MD_DIR, DEV_MD_DIR_LEN) == 0 || (w[0] != '/' && w[0] != '<') || (strncmp(w, DEV_NUM_PREF, DEV_NUM_PREF_LEN) == 0 && @@ -571,7 +583,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) -- cgit v1.2.3