[3/5] winapi_test: Fix TEST_FIELD() so it correctly tests the field size.

Francois Gouget fgouget at free.fr
Wed Jan 7 17:23:22 CST 2009


---

Let's say we have a structure definition like this (with a packing of 4):

  typedef struct { int f1; int f2; } s;

We were doing the following check.

  TEST_TYPE_SIZE(int, 4)

Such a test would still compile and succeed if the PSDK contained the 
following definition instead:

   typedef struct { short f1; int f2; } s;

So it's pretty useless. What we want to check is the size of f1 itself.


 tools/winapi/winapi_test |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/winapi/winapi_test b/tools/winapi/winapi_test
index 9731342..7cce9e0 100755
--- a/tools/winapi/winapi_test
+++ b/tools/winapi/winapi_test
@@ -571,10 +571,10 @@ sub output_header($$$) {
     print OUT " * Test macros\n";
     print OUT " */\n";
     print OUT "\n";
-    print OUT "#define TEST_FIELD(type, field_type, field_name, field_offset, field_size, field_align) \\\n";
-    print OUT "  TEST_TYPE_SIZE(field_type, field_size); \\\n";
-    print OUT "  TEST_FIELD_ALIGNMENT(type, field_name, field_align); \\\n";
-    print OUT "  TEST_FIELD_OFFSET(type, field_name, field_offset); \\\n";
+    print OUT "#define TEST_FIELD(type, field, field_offset, field_size, field_align) \\\n";
+    print OUT "  TEST_TYPE_SIZE((((type*)0)->field), field_size); \\\n";
+    print OUT "  TEST_FIELD_ALIGNMENT(type, field, field_align); \\\n";
+    print OUT "  TEST_FIELD_OFFSET(type, field, field_offset)\n";
     print OUT "\n";
     print OUT "#define TEST_TYPE(type, size, align) \\\n";
     print OUT "  TEST_TYPE_ALIGNMENT(type, align); \\\n";
@@ -731,14 +731,14 @@ sub output_test_pack_fields($$$$$$$) {
 	    $field_offset += $offset;
 	    if ($field_name eq "DUMMYSTRUCTNAME") {
 		print OUT "#ifdef NONAMELESSSTRUCT\n";
-		print OUT "    TEST_FIELD($type_name, $field_type_name, $field_name, ";
+		print OUT "    TEST_FIELD($type_name, $field_name, ";
 		print OUT "$field_offset, $field_size, $field_align);\n";
 		print OUT "#else\n";
 		output_test_pack_fields(\*OUT, $type_name2type, $type_name2optional, $type_name2optional_fields,
 					$type_name, $$type_name2type{$field_type_name}, $field_offset);	
 		print OUT "#endif\n";
 	    } else {
-		print OUT "    TEST_FIELD($type_name, $field_type_name, $field_name, ";
+		print OUT "    TEST_FIELD($type_name, $field_name, ";
 		print OUT "$field_offset, $field_size, $field_align);\n";
 	    }
 	} else {
-- 
1.5.6.5




More information about the wine-patches mailing list