parse-util: add parse_tristate() and use it everywhere
We parse tristates all the time, let's add an explicit parser for them.
This commit is contained in:
committed by
Yu Watanabe
parent
6a4d0efa00
commit
b71a721fbc
@@ -354,13 +354,7 @@ int config_parse_cake_tristate(
|
||||
else
|
||||
assert_not_reached();
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
*dest = -1;
|
||||
TAKE_PTR(qdisc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = parse_boolean(rvalue);
|
||||
r = parse_tristate(rvalue, dest);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to parse '%s=', ignoring assignment: %s",
|
||||
@@ -368,7 +362,6 @@ int config_parse_cake_tristate(
|
||||
return 0;
|
||||
}
|
||||
|
||||
*dest = r;
|
||||
TAKE_PTR(qdisc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+2
-10
@@ -223,14 +223,7 @@ int config_parse_controlled_delay_bool(
|
||||
|
||||
cd = CODEL(qdisc);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
cd->ecn = -1;
|
||||
|
||||
qdisc = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = parse_boolean(rvalue);
|
||||
r = parse_tristate(rvalue, &cd->ecn);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to parse '%s=', ignoring assignment: %s",
|
||||
@@ -238,8 +231,7 @@ int config_parse_controlled_delay_bool(
|
||||
return 0;
|
||||
}
|
||||
|
||||
cd->ecn = r;
|
||||
qdisc = NULL;
|
||||
TAKE_PTR(qdisc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -251,14 +251,7 @@ int config_parse_fair_queueing_controlled_delay_bool(
|
||||
|
||||
fqcd = FQ_CODEL(qdisc);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
fqcd->ecn = -1;
|
||||
|
||||
TAKE_PTR(qdisc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = parse_boolean(rvalue);
|
||||
r = parse_tristate(rvalue, &fqcd->ecn);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to parse '%s=', ignoring assignment: %s",
|
||||
@@ -266,7 +259,6 @@ int config_parse_fair_queueing_controlled_delay_bool(
|
||||
return 0;
|
||||
}
|
||||
|
||||
fqcd->ecn = r;
|
||||
TAKE_PTR(qdisc);
|
||||
|
||||
return 0;
|
||||
|
||||
+2
-9
@@ -267,14 +267,7 @@ int config_parse_fair_queueing_bool(
|
||||
|
||||
fq = FQ(qdisc);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
fq->pacing = -1;
|
||||
|
||||
qdisc = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = parse_boolean(rvalue);
|
||||
r = parse_tristate(rvalue, &fq->pacing);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to parse '%s=', ignoring assignment: %s",
|
||||
@@ -283,7 +276,7 @@ int config_parse_fair_queueing_bool(
|
||||
}
|
||||
|
||||
fq->pacing = r;
|
||||
qdisc = NULL;
|
||||
TAKE_PTR(qdisc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -163,14 +163,7 @@ int config_parse_generic_random_early_detection_bool(
|
||||
|
||||
gred = GRED(qdisc);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
gred->grio = -1;
|
||||
|
||||
TAKE_PTR(qdisc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = parse_boolean(rvalue);
|
||||
r = parse_tristate(rvalue, &gred->grio);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to parse '%s=', ignoring assignment: %s",
|
||||
@@ -178,7 +171,6 @@ int config_parse_generic_random_early_detection_bool(
|
||||
return 0;
|
||||
}
|
||||
|
||||
gred->grio = r;
|
||||
TAKE_PTR(qdisc);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user