[Piglit] [PATCH 25/29] tests/egl: Add missing type cast

Chad Versace chad.versace at linux.intel.com
Wed May 23 13:46:29 PDT 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/23/2012 07:55 AM, Pauli Nieminen wrote:
> On Tue, May 22, 2012 at 03:43:46PM -0700, Chad Versace wrote:
>> On 05/21/2012 11:09 AM, Pauli Nieminen wrote:
>>> Protable code should cast to EGL native types always before passing
>>> variables to functions taking a native parameter.
>>>
>>> Signed-off-by: Pauli Nieminen <pauli.nieminen at linux.intel.com>
>>> ---
>>>  tests/egl/egl-util.c |    2 +-
>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/tests/egl/egl-util.c b/tests/egl/egl-util.c
>>> index 41fc31f..639515e 100644
>>> --- a/tests/egl/egl-util.c
>>> +++ b/tests/egl/egl-util.c
>>> @@ -179,7 +179,7 @@ egl_util_run(const struct egl_test *test, int argc, char *argv[])
>>>  	}
>>>  
>>>  
>>> -	state.egl_dpy = eglGetDisplay(state.dpy);
>>> +	state.egl_dpy = eglGetDisplay((EGLNativeDisplayType)state.dpy);
>>>  	if (state.egl_dpy == EGL_NO_DISPLAY) {
>>>  		fprintf(stderr, "eglGetDisplay() failed\n");
>>>  		piglit_report_result(PIGLIT_FAIL);
>>
>> I think that this indicates that there is a type mismatch somewhere.
>> I don't believe such casting is ever necessary. In fact, I believe such
>> casts will mask real bugs.
> 
> The bugs like eglplatform.h having matching integer types instead of
> pointers or vice-versa. But that probably should be considred in
> eglplatform.h.
>>
>> Waffle never makes casts for EGLNative types, and it compiles without any warnings.
>> For example, in the x11_egl backend, Waffle passes a Display* to eglGetDisplay without any typecast;
>> see the two lines below:
>>
>> line 54, http://cgit.freedesktop.org/~chadversary/waffle/tree/src/waffle/x11_egl/xegl_display.c?id=0.3#n54
>> line 29, http://cgit.freedesktop.org/~chadversary/waffle/tree/src/waffle/egl/egl_native_template.c?id=0.3
>>
>> What problem did you encounter that prompted this patch?
>>
> 
> There is problem that EGLNative* types vary between platform but are
> defined in dispatch. Including EGL/eglplatform.h did feel like a
> working solution to provide platform independ interface.
> 
> I had a idea that dispatch could defined native types to uintptr_t
> and generate platform specific wrappers to truncate types back to
> platform specific types behind dispatch.
> 
> Another option would be filtering out native types from dispatch. Too
> bad that prevents user of dispatch from using egl native types in same
> C file as egl functions use through dispatch. Or at least makes it a
> lot more complex than it should be.

This is a difficult thing to solve without introducing lots of complexity.
I think I need to better understand your dispatch patches before discussing
this more.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJPvUykAAoJEAIvNt057x8i4PEQAKKL519a5xwfZ0HJD0Y5WDk+
D0f3nGkouIQRIfTT5h4s+LVTzAR4VxJPgc73d9p+7kOyfpUOINahgyVH7B5yF1Qz
f9XQ0J5LTo6Jrg7Nd8l7e2WJX3FiZkVXA/Q9y08RN0wxNtx0+raRkVG/GICd9l4r
EdojanV6i+4aGnuBj6wGKmaFORztrkkuE+5DgzhPVZasFlVW8vX7jedlBPmEebJE
IjRrnu35li13LlJzt/lstBLNTyypwqVx0lw1RSMD19MFWDEVor3pJuKYNysJaAkk
QwR6LcsrAVPijo2JbAbc7mMONCT5n5F1NBRC6BIY8PE5rNkaruIjDG6OAMF5Czdg
A143zyj9KM036KJ6NrutfUN7jFpbLn9ydQ34aFQRTwxHEMw/XwqQOWq/H+YRTpYF
/a93J/w37OebclxL5L5WC0y42CMIn4dlSKq4KOYzdrFhhGgHVSRc1UBMAwB8Eup0
h7LKgLPjq/VCkYptw0ktCdYwmuF/N9aX808bSiZQOKvZg/DKg+cUcMfhhaePxiOf
yHy8Vnf2CpDCFV8WZn+gnsf6oRFFSW3PEmqQvAkShoOxG/ZcCSvR3aQXSBHPVk6F
/rOY6Xaptlij2NvxbWpUbF9MneVwGMm/sXupPv1kptGue6ROyv0XREesYUeXpxev
4kW14+/ohfjN2K4Zn7tY
=wR4/
-----END PGP SIGNATURE-----


More information about the Piglit mailing list