config_parser: parse_line() must not return EINVAL for unknown strings The function parse_line(char *str, struct config_par *parv) checks if the line is valid. The function returns 0 if the line is empty, if the line has only spaces, of if the line is a comment line. The function checks if the string (str) starts with a known name like "resume device" or "splash" in a list of names. If the name is found then checks if the name has a correct value. If the value is wrong, the function returns EINVAL. If the function don't find the value in the tables name, returns EINVAL too. This is a mistake. The parse() function has the config_par argument to receive the list of valid names. If we have two lists in the code, the arguments that are in one list and not in the other list will be detected as error, parse_line will return EINVAL and the function parse will fail. Else, the function parse() and parse_line() can use always only one config_par list with all the possible parameters, therefore the parameter config_par is not needed. In this case (only one list), if the code has lists to different functions, the parse() function will read all always. Currently the suspend-utils code has two lists, parameters, for suspend options and s2ram_parameters for s2ram parameters, but both lists cannot be used at the same time in the config file. Then, probably the best option is remove the return EINVAL return for unknown names. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
diff --git a/config_parser.c b/config_parser.c index d017ccd..24a9cf9 100644 --- a/config_parser.c +++ b/config_parser.c
@@ -71,10 +71,6 @@ } } - if (!parv[i].name) { - error = -EINVAL; - } - cleanup: return error; }