udev_rules_parse_file: issue diagnostics about duplicate LABEL tokens
When a rules contains several LABEL tokens, the parser used to silently discard all of them besides the last one without any diagnostics at all. It's time to break the vow of silence and let the parser issue a warning.
This commit is contained in:
@@ -1014,6 +1014,9 @@ static int parse_token(UdevRules *rules, const char *key, char *attr, UdevRuleOp
|
||||
return log_token_invalid_attr(rules, key);
|
||||
if (op != OP_ASSIGN)
|
||||
return log_token_invalid_op(rules, key);
|
||||
if (FLAGS_SET(rule_line->type, LINE_HAS_LABEL))
|
||||
log_token_warning(rules, "Contains multiple LABEL keys, ignoring LABEL=\"%s\".",
|
||||
rule_line->label);
|
||||
|
||||
rule_line->label = value;
|
||||
SET_FLAG(rule_line->type, LINE_HAS_LABEL, true);
|
||||
|
||||
@@ -262,6 +262,19 @@ ${rules}: udev rules check failed
|
||||
EOF
|
||||
assert_1 "${rules}"
|
||||
|
||||
cat >"${rules}" <<'EOF'
|
||||
GOTO="a"
|
||||
LABEL="a", LABEL="b"
|
||||
EOF
|
||||
cat >"${exp}" <<EOF
|
||||
${rules}:2 Contains multiple LABEL keys, ignoring LABEL="a".
|
||||
${rules}:1 GOTO="a" has no matching label, ignoring
|
||||
${rules}:1 The line takes no effect any more, dropping
|
||||
${rules}:2 LABEL="b" is unused.
|
||||
${rules}: udev rules check failed
|
||||
EOF
|
||||
assert_1 "${rules}"
|
||||
|
||||
# udevadm verify --root
|
||||
sed "s|sample-[0-9]*.rules|${workdir}/${rules_dir}/&|" sample-*.exp >"${workdir}/${exp}"
|
||||
cd -
|
||||
|
||||
Reference in New Issue
Block a user