udev-rule: make get_key() return negative errno
This commit is contained in:
parent
1f362ff185
commit
704dbfb279
|
@ -716,7 +716,7 @@ static int get_key(char **line, char **key, enum operation_type *op, char **valu
|
||||||
|
|
||||||
linepos = *line;
|
linepos = *line;
|
||||||
if (!linepos || linepos[0] == '\0')
|
if (!linepos || linepos[0] == '\0')
|
||||||
return -1;
|
return -EINVAL;
|
||||||
|
|
||||||
/* skip whitespace */
|
/* skip whitespace */
|
||||||
while (isspace(linepos[0]) || linepos[0] == ',')
|
while (isspace(linepos[0]) || linepos[0] == ',')
|
||||||
|
@ -724,13 +724,13 @@ static int get_key(char **line, char **key, enum operation_type *op, char **valu
|
||||||
|
|
||||||
/* get the key */
|
/* get the key */
|
||||||
if (linepos[0] == '\0')
|
if (linepos[0] == '\0')
|
||||||
return -1;
|
return -EINVAL;
|
||||||
*key = linepos;
|
*key = linepos;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
linepos++;
|
linepos++;
|
||||||
if (linepos[0] == '\0')
|
if (linepos[0] == '\0')
|
||||||
return -1;
|
return -EINVAL;
|
||||||
if (isspace(linepos[0]))
|
if (isspace(linepos[0]))
|
||||||
break;
|
break;
|
||||||
if (linepos[0] == '=')
|
if (linepos[0] == '=')
|
||||||
|
@ -747,7 +747,7 @@ static int get_key(char **line, char **key, enum operation_type *op, char **valu
|
||||||
while (isspace(linepos[0]))
|
while (isspace(linepos[0]))
|
||||||
linepos++;
|
linepos++;
|
||||||
if (linepos[0] == '\0')
|
if (linepos[0] == '\0')
|
||||||
return -1;
|
return -EINVAL;
|
||||||
|
|
||||||
/* get operation type */
|
/* get operation type */
|
||||||
if (linepos[0] == '=' && linepos[1] == '=') {
|
if (linepos[0] == '=' && linepos[1] == '=') {
|
||||||
|
@ -769,7 +769,7 @@ static int get_key(char **line, char **key, enum operation_type *op, char **valu
|
||||||
*op = OP_ASSIGN_FINAL;
|
*op = OP_ASSIGN_FINAL;
|
||||||
linepos += 2;
|
linepos += 2;
|
||||||
} else
|
} else
|
||||||
return -1;
|
return -EINVAL;
|
||||||
|
|
||||||
/* terminate key */
|
/* terminate key */
|
||||||
temp[0] = '\0';
|
temp[0] = '\0';
|
||||||
|
@ -778,13 +778,13 @@ static int get_key(char **line, char **key, enum operation_type *op, char **valu
|
||||||
while (isspace(linepos[0]))
|
while (isspace(linepos[0]))
|
||||||
linepos++;
|
linepos++;
|
||||||
if (linepos[0] == '\0')
|
if (linepos[0] == '\0')
|
||||||
return -1;
|
return -EINVAL;
|
||||||
|
|
||||||
/* get the value */
|
/* get the value */
|
||||||
if (linepos[0] == '"')
|
if (linepos[0] == '"')
|
||||||
linepos++;
|
linepos++;
|
||||||
else
|
else
|
||||||
return -1;
|
return -EINVAL;
|
||||||
*value = linepos;
|
*value = linepos;
|
||||||
|
|
||||||
/* terminate */
|
/* terminate */
|
||||||
|
@ -794,7 +794,7 @@ static int get_key(char **line, char **key, enum operation_type *op, char **valu
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (linepos[i] == '\0')
|
if (linepos[i] == '\0')
|
||||||
return -1;
|
return -EINVAL;
|
||||||
|
|
||||||
/* double quotes can be escaped */
|
/* double quotes can be escaped */
|
||||||
if (linepos[i] == '\\')
|
if (linepos[i] == '\\')
|
||||||
|
@ -1030,7 +1030,7 @@ static void add_rule(UdevRules *rules, char *line,
|
||||||
char *value;
|
char *value;
|
||||||
enum operation_type op;
|
enum operation_type op;
|
||||||
|
|
||||||
if (get_key(&linepos, &key, &op, &value) != 0) {
|
if (get_key(&linepos, &key, &op, &value) < 0) {
|
||||||
/* Avoid erroring on trailing whitespace. This is probably rare
|
/* Avoid erroring on trailing whitespace. This is probably rare
|
||||||
* so save the work for the error case instead of always trying
|
* so save the work for the error case instead of always trying
|
||||||
* to strip the trailing whitespace with strstrip(). */
|
* to strip the trailing whitespace with strstrip(). */
|
||||||
|
|
Loading…
Reference in a new issue