On 04/20/2017 05:49 PM, NeilBrown wrote:
On Thu, Apr 20 2017, Jes Sorensen wrote:
I think I got it right this time and pushed it into git. It made things
a lot prettier too IMHO :)
In the process I also changed the behavior of
sysfs_read(GET_ARRAY_STATE) as I really didn't like how it was copying
in the string rather than parsing it.
I am traveling at the moment and don't yet have my new raid test box
setup back at the office, so my testing is limited. If I broke something
badly, feel free to throw rotten tomatoes at me.
Cheers,
Jes
Looks good to me, except...
/*
* Beware map_name() uses strcmp() so active-idle must come before
* active, to be detected correctly.
*/
???
If map_name() used strncmp() you might need to be careful, but not with
strcmp.
Hmmm I should know better than that! I did work on glibc back in the day
after all :(
Also:
int map_name(mapping_t *map, char *name)
{
while (map->name) {
if (strcmp(map->name, name)==0)
return map->num;
map++;
}
return map->num;
}
Both returns do the same thing... so there should (could) just be one.
is:
while (map->name && strcmp(map->name, name) != 0)
map++;
return map->num;
too terse??
Looks good to me - applied a patch for it.
I do like that you could use map_name to parse the array_state file.
I actually had it done first with a large if list, but then discovered
maps.c and felt I had to change it :)
Cheers,
Jes
Thanks,
NeilBrown
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html