[master] edd71dd57 param: Set all and none as bit parameters values
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Tue Nov 21 06:03:09 UTC 2023
commit edd71dd5796f69be9193130ee79b113906e4a57d
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Tue Nov 7 07:34:58 2023 +0100
param: Set all and none as bit parameters values
As opposed to special values. This enables setting "absolute" values
atomically:
param.set foo none,+bar,+baz
diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c
index bfd0f2bee..0a8e1e595 100644
--- a/bin/varnishd/mgt/mgt_param_tweak.c
+++ b/bin/varnishd/mgt/mgt_param_tweak.c
@@ -634,6 +634,14 @@ bit_tweak(struct vsb *vsb, uint8_t *p, unsigned l, const char *arg,
}
for (i = 1; av[i] != NULL; i++) {
s = av[i];
+ if (sign == '+' && !strcmp(s, "none")) {
+ bit_clear(p, l);
+ continue;
+ }
+ if (sign == '-' && !strcmp(s, "all")) {
+ bit_clear(p, l);
+ continue;
+ }
if (*s != '-' && *s != '+') {
VSB_printf(vsb, "Missing '+' or '-' (%s)\n", s);
VAV_Free(av);
@@ -678,12 +686,7 @@ tweak_generic_bits(struct vsb *vsb, const struct parspec *par, const char *arg,
}
if (arg != NULL && arg != JSON_FMT) {
- if (sign == '+' && !strcmp(arg, "none"))
- bit_clear(p, l);
- else if (sign == '-' && !strcmp(arg, "all"))
- bit_clear(p, l);
- else
- return (bit_tweak(vsb, p, l, arg, tags, desc, sign));
+ return (bit_tweak(vsb, p, l, arg, tags, desc, sign));
} else {
if (arg == JSON_FMT)
VSB_putc(vsb, '"');
More information about the varnish-commit
mailing list