Blame SOURCES/0066-mdadm-create-ident_init.patch

91179e
From 7fcbfd7c620e2dcd3b539d18e93cb503ee3a8a62 Mon Sep 17 00:00:00 2001
91179e
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
91179e
Date: Wed, 21 Dec 2022 12:50:17 +0100
91179e
Subject: [PATCH 66/83] mdadm: create ident_init()
91179e
91179e
Add a wrapper for repeated initializations in mdadm.c and config.c.
91179e
Move includes up.
91179e
91179e
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
91179e
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
91179e
---
91179e
 config.c | 45 +++++++++++++++++++++++++++++----------------
91179e
 mdadm.c  | 16 ++--------------
91179e
 mdadm.h  |  7 +++++--
91179e
 3 files changed, 36 insertions(+), 32 deletions(-)
91179e
91179e
diff --git a/config.c b/config.c
91179e
index dc1620c1..eeedd0c6 100644
91179e
--- a/config.c
91179e
+++ b/config.c
91179e
@@ -119,6 +119,34 @@ int match_keyword(char *word)
91179e
 	return -1;
91179e
 }
91179e
 
91179e
+/**
91179e
+ * ident_init() - Set defaults.
91179e
+ * @ident: ident pointer, not NULL.
91179e
+ */
91179e
+inline void ident_init(struct mddev_ident *ident)
91179e
+{
91179e
+	assert(ident);
91179e
+
91179e
+	ident->assembled = false;
91179e
+	ident->autof = 0;
91179e
+	ident->bitmap_fd = -1;
91179e
+	ident->bitmap_file = NULL;
91179e
+	ident->container = NULL;
91179e
+	ident->devices = NULL;
91179e
+	ident->devname = NULL;
91179e
+	ident->level = UnSet;
91179e
+	ident->member = NULL;
91179e
+	ident->name[0] = 0;
91179e
+	ident->next = NULL;
91179e
+	ident->raid_disks = UnSet;
91179e
+	ident->spare_group = NULL;
91179e
+	ident->spare_disks = 0;
91179e
+	ident->st = NULL;
91179e
+	ident->super_minor = UnSet;
91179e
+	ident->uuid[0] = 0;
91179e
+	ident->uuid_set = 0;
91179e
+}
91179e
+
91179e
 struct conf_dev {
91179e
 	struct conf_dev *next;
91179e
 	char *name;
91179e
@@ -363,22 +391,7 @@ void arrayline(char *line)
91179e
 	struct mddev_ident mis;
91179e
 	struct mddev_ident *mi;
91179e
 
91179e
-	mis.uuid_set = 0;
91179e
-	mis.super_minor = UnSet;
91179e
-	mis.level = UnSet;
91179e
-	mis.raid_disks = UnSet;
91179e
-	mis.spare_disks = 0;
91179e
-	mis.devices = NULL;
91179e
-	mis.devname = NULL;
91179e
-	mis.spare_group = NULL;
91179e
-	mis.autof = 0;
91179e
-	mis.next = NULL;
91179e
-	mis.st = NULL;
91179e
-	mis.bitmap_fd = -1;
91179e
-	mis.bitmap_file = NULL;
91179e
-	mis.name[0] = 0;
91179e
-	mis.container = NULL;
91179e
-	mis.member = NULL;
91179e
+	ident_init(&mis;;
91179e
 
91179e
 	for (w = dl_next(line); w != line; w = dl_next(w)) {
91179e
 		if (w[0] == '/' || strchr(w, '=') == NULL) {
91179e
diff --git a/mdadm.c b/mdadm.c
91179e
index 972adb52..74fdec31 100644
91179e
--- a/mdadm.c
91179e
+++ b/mdadm.c
91179e
@@ -107,25 +107,13 @@ int main(int argc, char *argv[])
91179e
 
91179e
 	srandom(time(0) ^ getpid());
91179e
 
91179e
-	ident.uuid_set = 0;
91179e
-	ident.level = UnSet;
91179e
-	ident.raid_disks = UnSet;
91179e
-	ident.super_minor = UnSet;
91179e
-	ident.devices = 0;
91179e
-	ident.spare_group = NULL;
91179e
-	ident.autof = 0;
91179e
-	ident.st = NULL;
91179e
-	ident.bitmap_fd = -1;
91179e
-	ident.bitmap_file = NULL;
91179e
-	ident.name[0] = 0;
91179e
-	ident.container = NULL;
91179e
-	ident.member = NULL;
91179e
-
91179e
 	if (get_linux_version() < 2006015) {
91179e
 		pr_err("This version of mdadm does not support kernels older than 2.6.15\n");
91179e
 		exit(1);
91179e
 	}
91179e
 
91179e
+	ident_init(&ident);
91179e
+
91179e
 	while ((option_index = -1),
91179e
 	       (opt = getopt_long(argc, argv, shortopt, long_options,
91179e
 				  &option_index)) != -1) {
91179e
diff --git a/mdadm.h b/mdadm.h
91179e
index 3673494e..23ffe977 100644
91179e
--- a/mdadm.h
91179e
+++ b/mdadm.h
91179e
@@ -33,8 +33,10 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
91179e
 # endif
91179e
 #endif
91179e
 
91179e
+#include	<assert.h>
91179e
 #include	<sys/types.h>
91179e
 #include	<sys/stat.h>
91179e
+#include	<stdarg.h>
91179e
 #include	<stdint.h>
91179e
 #include	<stdlib.h>
91179e
 #include	<time.h>
91179e
@@ -1552,6 +1554,8 @@ extern void enable_fds(int devices);
91179e
 extern void manage_fork_fds(int close_all);
91179e
 extern int continue_via_systemd(char *devnm, char *service_name);
91179e
 
91179e
+extern void ident_init(struct mddev_ident *ident);
91179e
+
91179e
 extern int parse_auto(char *str, char *msg, int config);
91179e
 extern struct mddev_ident *conf_get_ident(char *dev);
91179e
 extern struct mddev_dev *conf_get_devs(void);
91179e
@@ -1779,8 +1783,7 @@ static inline sighandler_t signal_s(int sig, sighandler_t handler)
91179e
 #define dprintf_cont(fmt, arg...) \
91179e
         ({ if (0) fprintf(stderr, fmt, ##arg); 0; })
91179e
 #endif
91179e
-#include <assert.h>
91179e
-#include <stdarg.h>
91179e
+
91179e
 static inline int xasprintf(char **strp, const char *fmt, ...) {
91179e
 	va_list ap;
91179e
 	int ret;
91179e
-- 
91179e
2.38.1
91179e