[master] ac82a96a1 Also fix "$ABI vrt", and make sure it stays fixed.
Poul-Henning Kamp
phk at FreeBSD.org
Mon Jul 4 12:05:06 UTC 2022
commit ac82a96a1f9cb734b2a575aad250014a14ded501
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Jul 4 12:04:21 2022 +0000
Also fix "$ABI vrt", and make sure it stays fixed.
diff --git a/bin/varnishtest/tests/m00003.vtc b/bin/varnishtest/tests/m00003.vtc
index 41155b926..c02d80071 100644
--- a/bin/varnishtest/tests/m00003.vtc
+++ b/bin/varnishtest/tests/m00003.vtc
@@ -69,8 +69,8 @@ filewrite -a ${tmpdir}/libvmod_wrong.so {
"Vmod_vmod_wrong_Func",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
- 0,
- 0
+ "0",
+ "0U"
]
]
}
@@ -87,8 +87,8 @@ filewrite -a ${tmpdir}/libvmod_wrong.so {
"Vmod_vmod_wrong_Func",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
- 1,
- 0
+ "1U",
+ "0"
]
]
}
@@ -108,8 +108,8 @@ filewrite -a ${tmpdir}/libvmod_wrong.so {
"Vmod_vmod_wrong_Func",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
- 15,
- 0
+ "15",
+ "0"
], [
"$FOOBAR"
]
@@ -128,8 +128,8 @@ filewrite -a ${tmpdir}/libvmod_wrong.so {
"Vmod_vmod_wrong_Func",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
- 15,
- 0
+ "15",
+ "0"
]
]
}
@@ -146,8 +146,8 @@ filewrite -a ${tmpdir}/libvmod_wrong.so {
"Vmod_vmod_wrong_Func",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
- 15,
- 0
+ "15",
+ "0"
], [
"$CPROTO"
], [
diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c
index a0ecfe96a..bb244ef99 100644
--- a/lib/libvcc/vcc_vmod.c
+++ b/lib/libvcc/vcc_vmod.c
@@ -131,6 +131,7 @@ vcc_ParseJSON(const struct vcc *tl, const char *jsn, struct vmod_import *vim)
{
const struct vjsn_val *vv, *vv2, *vv3;
const char *err;
+ char *p;
vim->vj = vjsn_parse(jsn, &err);
if (err != NULL)
@@ -180,13 +181,15 @@ vcc_ParseJSON(const struct vcc *tl, const char *jsn, struct vmod_import *vim)
vv3 = VTAILQ_NEXT(vv3, list);
AN(vv3);
- assert(vjsn_is_number(vv3));
- vim->major = atoi(vv3->value);
+ assert(vjsn_is_string(vv3));
+ vim->major = strtoul(vv3->value, &p, 10);
+ assert(p == NULL || *p == '\0' || *p == 'U');
vv3 = VTAILQ_NEXT(vv3, list);
AN(vv3);
- assert(vjsn_is_number(vv3));
- vim->minor = atoi(vv3->value);
+ assert(vjsn_is_string(vv3));
+ vim->minor = strtoul(vv3->value, &p, 10);
+ assert(p == NULL || *p == '\0' || *p == 'U');
if (!vcc_IdIs(vim->t_mod, vim->name)) {
VSB_printf(tl->sb, "Wrong file for VMOD %.*s\n",
diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py
index 5001522be..da7157766 100755
--- a/lib/libvcc/vmodtool.py
+++ b/lib/libvcc/vmodtool.py
@@ -1100,7 +1100,9 @@ class vcc():
yield i + " "
def json(self, fo, fnx):
- fo.write('#define STRINGIFY(arg) #arg\n')
+ fo.write('#define STRINGIFY3(arg) #arg\n')
+ fo.write('#define STRINGIFY2(arg) STRINGIFY3(#arg)\n')
+ fo.write('#define STRINGIFY1(arg) STRINGIFY2(arg)\n')
fo.write("\nstatic const char Vmod_Json[] = {\n")
fo.write('\t"VMOD_JSON_SPEC\x02"\n')
@@ -1114,8 +1116,8 @@ class vcc():
# Hand-munge the JSON to insert stuff only known by
# the C-compiler at compile-time.
fo.write(',"\n\t" \\"" VMOD_ABI_Version "\\", "\n')
- fo.write('\t STRINGIFY(%s) ", "\n' % self.vrt_major)
- fo.write('\t STRINGIFY(%s)\n' % self.vrt_minor)
+ fo.write('\t STRINGIFY1(%s) ", "\n' % self.vrt_major)
+ fo.write('\t STRINGIFY1(%s)\n' % self.vrt_minor)
else:
fo.write('"\n')
fo.write('\t\"\\n\\x03\"\n};\n')
diff --git a/vmod/vmod_debug.vcc b/vmod/vmod_debug.vcc
index 2fb67e8ab..df8ba6247 100644
--- a/vmod/vmod_debug.vcc
+++ b/vmod/vmod_debug.vcc
@@ -27,8 +27,9 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
+# NB: We use this vmod to test "$ABI vrt" handling.
-$ABI strict
+$ABI vrt
$Prefix xyzzy
$Module debug 3 "Development, test and debug"
$Synopsis auto
diff --git a/vmod/vmod_vtc.vcc b/vmod/vmod_vtc.vcc
index 52578e7b3..7ac3f6997 100644
--- a/vmod/vmod_vtc.vcc
+++ b/vmod/vmod_vtc.vcc
@@ -27,7 +27,8 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
-$ABI strict
+# NB: Default to strict $ABI handling, so that path is tested in vmodtool.py
+
$Module vtc 3 "Utility module for varnishtest"
DESCRIPTION
More information about the varnish-commit
mailing list