Hello Dmitry,
On 08/19/2015 06:23 AM, Dmitry Timoshkov wrote:
dlls/kernel32/tests/process.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index 113ec35..a8abdc1 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -2302,7 +2302,7 @@ static void test_TerminateJobObject(void)
static void test_QueryInformationJobObject(void) {
- char buf[FIELD_OFFSET(JOBOBJECT_BASIC_PROCESS_ID_LIST, ProcessIdList[5])];
- char buf[sizeof(JOBOBJECT_BASIC_PROCESS_ID_LIST) + sizeof(ULONG_PTR) * 5];
this change looks odd.
Using offsetof (or FIELD_OFFSET) is the standard Wine way of getting the size of a struct with a variable length array. I have done quite a few patches on Alexandre's request that replace sizeof+sizeof*x with offsetof. E.g. 14e20162f9448a648f3973a86e03aea17387c040
Last but not least you're not allocating the same amount of memory: offsetof(struct, field[n]) == sizeof(struct) + (n-1) * sizeof(field)
bye michael
Michael Stefaniuc mstefani@redhat.com wrote:
- char buf[FIELD_OFFSET(JOBOBJECT_BASIC_PROCESS_ID_LIST, ProcessIdList[5])];
- char buf[sizeof(JOBOBJECT_BASIC_PROCESS_ID_LIST) + sizeof(ULONG_PTR) * 5];
this change looks odd.
Using offsetof (or FIELD_OFFSET) is the standard Wine way of getting the size of a struct with a variable length array. I have done quite a few patches on Alexandre's request that replace sizeof+sizeof*x with offsetof. E.g. 14e20162f9448a648f3973a86e03aea17387c040
Well, it was already discussed before, MSVC/PSDK compilers don't cope with such a construct, FIELD_OFFSET() is not a constant for them, and they fail. An ability to compile with MSVC/PSDK compilers is very critical thing at least for writing Wine tests, so we have to take that limitation into account.
Last but not least you're not allocating the same amount of memory: offsetof(struct, field[n]) == sizeof(struct) + (n-1) * sizeof(field)
Yes, I decided to make it visible that 5 fields are explicitely allocated instead of adding a comment that 1 field is already allocated in the base structure, but it shouldn't matter.