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

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