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