dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/maps-Use-keyvalue-for-null-terminator-to-indicate-un.patch

2c1b57
From 5e8e35fb7e17495032e144f319517dcae38d1b56 Mon Sep 17 00:00:00 2001
2c1b57
From: Jes Sorensen <jsorensen@fb.com>
2c1b57
Date: Thu, 20 Apr 2017 00:19:44 -0400
2c1b57
Subject: [RHEL7.5 PATCH 084/169] maps: Use keyvalue for null terminator to
2c1b57
 indicate 'unset' value
2c1b57
2c1b57
This simplifies the code calling map_name() so it no longer has to
2c1b57
manually check for UnSet and convert the value manually.
2c1b57
2c1b57
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2c1b57
---
2c1b57
 maps.c  | 17 +++++++++--------
2c1b57
 sysfs.c |  2 --
2c1b57
 2 files changed, 9 insertions(+), 10 deletions(-)
2c1b57
2c1b57
diff --git a/maps.c b/maps.c
2c1b57
index a2d293b..11dd3d2 100644
2c1b57
--- a/maps.c
2c1b57
+++ b/maps.c
2c1b57
@@ -44,7 +44,7 @@ mapping_t r5layout[] = {
2c1b57
 	{ "ddf-N-restart", ALGORITHM_LEFT_ASYMMETRIC},
2c1b57
 	{ "ddf-N-continue", ALGORITHM_LEFT_SYMMETRIC},
2c1b57
 
2c1b57
-	{ NULL, 0}
2c1b57
+	{ NULL, UnSet }
2c1b57
 };
2c1b57
 mapping_t r6layout[] = {
2c1b57
 	{ "left-asymmetric", ALGORITHM_LEFT_ASYMMETRIC},
2c1b57
@@ -70,7 +70,7 @@ mapping_t r6layout[] = {
2c1b57
 	{ "right-symmetric-6", ALGORITHM_RIGHT_SYMMETRIC_6},
2c1b57
 	{ "parity-first-6", ALGORITHM_PARITY_0_6},
2c1b57
 
2c1b57
-	{ NULL, 0}
2c1b57
+	{ NULL, UnSet }
2c1b57
 };
2c1b57
 
2c1b57
 mapping_t pers[] = {
2c1b57
@@ -93,7 +93,7 @@ mapping_t pers[] = {
2c1b57
 	{ "10", 10},
2c1b57
 	{ "faulty", LEVEL_FAULTY},
2c1b57
 	{ "container", LEVEL_CONTAINER},
2c1b57
-	{ NULL, 0}
2c1b57
+	{ NULL, UnSet }
2c1b57
 };
2c1b57
 
2c1b57
 mapping_t modes[] = {
2c1b57
@@ -106,7 +106,7 @@ mapping_t modes[] = {
2c1b57
 	{ "grow", GROW},
2c1b57
 	{ "incremental", INCREMENTAL},
2c1b57
 	{ "auto-detect", AUTODETECT},
2c1b57
-	{ NULL, 0 }
2c1b57
+	{ NULL, UnSet }
2c1b57
 };
2c1b57
 
2c1b57
 mapping_t faultylayout[] = {
2c1b57
@@ -127,7 +127,7 @@ mapping_t faultylayout[] = {
2c1b57
 	{ "flush", ClearFaults},
2c1b57
 	{ "none", ClearErrors},
2c1b57
 	{ "default", ClearErrors},
2c1b57
-	{ NULL, 0}
2c1b57
+	{ NULL, UnSet }
2c1b57
 };
2c1b57
 
2c1b57
 mapping_t consistency_policies[] = {
2c1b57
@@ -137,7 +137,7 @@ mapping_t consistency_policies[] = {
2c1b57
 	{ "bitmap", CONSISTENCY_POLICY_BITMAP},
2c1b57
 	{ "journal", CONSISTENCY_POLICY_JOURNAL},
2c1b57
 	{ "ppl", CONSISTENCY_POLICY_PPL},
2c1b57
-	{ NULL, 0}
2c1b57
+	{ NULL, UnSet }
2c1b57
 };
2c1b57
 
2c1b57
 mapping_t sysfs_array_states[] = {
2c1b57
@@ -154,7 +154,7 @@ mapping_t sysfs_array_states[] = {
2c1b57
 	{ "read-auto", ARRAY_READ_AUTO },
2c1b57
 	{ "clean", ARRAY_CLEAN },
2c1b57
 	{ "write-pending", ARRAY_WRITE_PENDING },
2c1b57
-	{ NULL, 0 }
2c1b57
+	{ NULL, ARRAY_UNKNOWN_STATE }
2c1b57
 };
2c1b57
 
2c1b57
 char *map_num(mapping_t *map, int num)
2c1b57
@@ -174,5 +174,6 @@ int map_name(mapping_t *map, char *name)
2c1b57
 			return map->num;
2c1b57
 		map++;
2c1b57
 	}
2c1b57
-	return UnSet;
2c1b57
+
2c1b57
+	return map->num;
2c1b57
 }
2c1b57
diff --git a/sysfs.c b/sysfs.c
2c1b57
index c6df9b0..712f8b3 100644
2c1b57
--- a/sysfs.c
2c1b57
+++ b/sysfs.c
2c1b57
@@ -250,8 +250,6 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
2c1b57
 		if (load_sys(fname, buf, sizeof(buf)))
2c1b57
 			goto abort;
2c1b57
 		sra->array_state = map_name(sysfs_array_states, buf);
2c1b57
-		if (sra->array_state == UnSet)
2c1b57
-			sra->array_state = ARRAY_UNKNOWN_STATE;
2c1b57
 	}
2c1b57
 
2c1b57
 	if (options & GET_CONSISTENCY_POLICY) {
2c1b57
-- 
2c1b57
2.7.4
2c1b57