From 4f15b7d510dc7c6361a26a7c6d2f7c3a17f8d878 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 10 Jul 2020 11:55:11 +0200 Subject: [PATCH] Fix sizeof(http_parser) assert The result should be 32 on both 32 bits and 64 bits x86 because of struct padding. Fixes: https://github.com/nodejs/http-parser/issues/507 PR-URL: https://github.com/nodejs/http-parser/pull/510 Reviewed-By: Fedor Indutny --- test.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test.c b/test.c index 53a3163d..3f7c77b3 100644 --- a/test.c +++ b/test.c @@ -4343,7 +4343,13 @@ main (void) printf("http_parser v%u.%u.%u (0x%06lx)\n", major, minor, patch, version); printf("sizeof(http_parser) = %u\n", (unsigned int)sizeof(http_parser)); - assert(sizeof(http_parser) == 4 + 4 + 8 + 2 + 2 + 4 + sizeof(void *)); + +#if defined(__i386__) || defined(__x86_64__) + /* Should be 32 on both 32 bits and 64 bits x86 because of struct padding, + * see https://github.com/nodejs/http-parser/issues/507. + */ + assert(sizeof(http_parser) == 32); +#endif //// API test_preserve_data();