Ivan Gyurdiev wrote:
Type: Cleanup
Why: The const qualifier is unnecessarily restrictive. I intend to allocate and free such data on the heap in a future patch. Instead, const should be primarily used on function parameters.
Question: do you realy have to use void pointers? Void pointers are compatible with every pointer type and thus will disable the type checking of the compiler. Also you do not need to to cast a rvalue to void * if the type of the lvalue is void *.
bye michael
dlls/d3d9/tests/stateblock.c | 40 ++++++++++++++++++++-------------------- 1 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/dlls/d3d9/tests/stateblock.c b/dlls/d3d9/tests/stateblock.c index 65a11e6..68b431a 100644 --- a/dlls/d3d9/tests/stateblock.c +++ b/dlls/d3d9/tests/stateblock.c @@ -105,20 +105,20 @@ typedef struct state_test { * as the default data, but a write can have side effects. * The initial data is tested first, before any writes take place * The default data can be tested after a write */
- const void* initial_data;
void* initial_data;
/* The default data is the standard state to compare
- against, and restore to */
- const void* default_data;
void* default_data;
/* The test data is the experiment data to try
- in - what we want to write
- out - what windows will actually write (not necessarily the same) */
- const void* test_data_in;
- const void* test_data_out;
void* test_data_in;
void* test_data_out;
/* The poison data is the data to preinitialize the return buffer to */
- const void* poison_data;
void* poison_data;
/* Return buffer */ void* return_data;
@@ -562,11 +562,11 @@ static void shader_constants_queue_test( shader_constant_arg* arg = buffer; shader_constant_data* return_data = (shader_constant_data*) (arg + 1);
- test->test_data_in = &shader_constant_test_data;
- test->test_data_out = &shader_constant_test_data;
- test->default_data = &shader_constant_default_data;
- test->initial_data = &shader_constant_default_data;
- test->poison_data = &shader_constant_poison_data;
- test->test_data_in = (void*) &shader_constant_test_data;
- test->test_data_out = (void*) &shader_constant_test_data;
- test->default_data = (void*) &shader_constant_default_data;
- test->initial_data = (void*) &shader_constant_default_data;
- test->poison_data = (void*) &shader_constant_poison_data; test->return_data = return_data; test->data_size = sizeof(shader_constant_data); test->set_handler = shader_constant_set_handler;
@@ -697,11 +697,11 @@ static void lights_queue_test( light_arg* arg = buffer; light_data* return_data = (light_data*) (arg + 1);
- test->test_data_in = &light_test_data_in;
- test->test_data_out = &light_test_data_out;
- test->default_data = &light_default_data;
- test->initial_data = &light_initial_data;
- test->poison_data = &light_poison_data;
- test->test_data_in = (void*) &light_test_data_in;
- test->test_data_out = (void*) &light_test_data_out;
- test->default_data = (void*) &light_default_data;
- test->initial_data = (void*) &light_initial_data;
- test->poison_data = (void*) &light_poison_data; test->return_data = return_data; test->data_size = sizeof(light_data); test->set_handler = light_set_handler;
@@ -856,11 +856,11 @@ static void transform_queue_test( { transform_data* return_data = buffer;
- test->test_data_in = &transform_test_data;
- test->test_data_out = &transform_test_data;
- test->default_data = &transform_default_data;
- test->initial_data = &transform_default_data;
- test->poison_data = &transform_poison_data;
- test->test_data_in = (void*) &transform_test_data;
- test->test_data_out = (void*) &transform_test_data;
- test->default_data = (void*) &transform_default_data;
- test->initial_data = (void*) &transform_default_data;
- test->poison_data = (void*) &transform_poison_data; test->return_data = return_data; test->data_size = sizeof(transform_data); test->set_handler = transform_set_handler;
Michael Stefaniuc wrote:
Ivan Gyurdiev wrote:
Type: Cleanup
Why: The const qualifier is unnecessarily restrictive. I intend to allocate and free such data on the heap in a future patch. Instead, const should be primarily used on function parameters.
Question: do you realy have to use void pointers?
Yes.
Void pointers are compatible with every pointer type and thus will disable the type checking of the compiler.
This is intentional - it's a form of polymorphism. The data stored can be of many different types. Each test knows what type of data it is using.
Also you do not need to to cast a rvalue to void * if the type of the lvalue is void *.
Yes, you do...the type of the lvalue is void*, while the type of the rvalue is const void*. Not casting produces a warning (correctly). Casting replaces the compile-time guarantee that the value will be kept constant by runtime contract [ because both const and non-const rvalue will be used in the future ].