[master] 339650f9d vtc_http2: Avoid magic settings indices
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Tue Jan 31 11:47:06 UTC 2023
commit 339650f9ddcdd01be6378b78e6b4cfad201f105d
Author: Walid Boudebouda <walid.boudebouda at gmail.com>
Date: Mon Dec 5 18:04:09 2022 +0100
vtc_http2: Avoid magic settings indices
This will be useful as varnishtest will honor more settings.
Signed-off-by: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c
index 990ffd291..04389d25f 100644
--- a/bin/varnishtest/vtc_http2.c
+++ b/bin/varnishtest/vtc_http2.c
@@ -70,7 +70,11 @@ static const char * const h2_settings[] = {
NULL
};
-#define SETTINGS_MAX (sizeof(h2_settings)/sizeof(h2_settings[0]) - 1U)
+enum h2_settings_e {
+#define H2_SETTING(U,l,v,...) SETTINGS_##U = v,
+#include <tbl/h2_settings.h>
+ SETTINGS_MAX
+};
enum h2_type {
@@ -1026,9 +1030,9 @@ cmd_var_resolve(const struct stream *s, const char *spec, char *buf)
return (buf);
}
if (!strcmp(spec, "push")) {
- if (isnan(f->md.settings[2]))
+ if (isnan(f->md.settings[SETTINGS_ENABLE_PUSH]))
return (NULL);
- else if (f->md.settings[2] == 1)
+ else if (f->md.settings[SETTINGS_ENABLE_PUSH] == 1)
snprintf(buf, 20, "true");
else
snprintf(buf, 20, "false");
More information about the varnish-commit
mailing list