From b823c8f9d65eb7cf3338036c2a3fedf5128dedbc Mon Sep 17 00:00:00 2001 From: Mateusz Kusiak Date: Thu, 18 Jan 2024 11:28:41 +0100 Subject: Replace "none" with macro String "none" is used many times throughout the code. Replace "none" strings with predefined macro. Add str_is_none() for comparing strings with "none". Replace str(n)cmp calls with function. Signed-off-by: Mateusz Kusiak Signed-off-by: Mariusz Tkaczyk --- mdadm.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'mdadm.h') diff --git a/mdadm.h b/mdadm.h index 46692730..709b6104 100644 --- a/mdadm.h +++ b/mdadm.h @@ -2027,3 +2027,19 @@ static inline int is_container(const int level) return 1; return 0; } + +#define STR_COMMON_NONE "none" + +/** + * str_is_none() - check if @str starts with "none". + * @str: string + * + * return: + * true if string starts with "none", false otherwise. + */ +static inline bool str_is_none(char *str) +{ + if (strncmp(str, STR_COMMON_NONE, sizeof(STR_COMMON_NONE) - 1) == 0) + return true; + return false; +} -- cgit v1.2.3