From 88fdae52930912a3e81c3d3e412cc51051116de2 Mon Sep 17 00:00:00 2001 From: Inaky Perez-Gonzalez Date: Thu, 8 Oct 2009 13:08:48 +0900 Subject: [PATCH] Fix broken libiWmxSDK callback parameter handling libiWmxSDK broke AGAIN the callback model, by passing a 'device_id' pointer that is not the original the callback was registered with. This makes it impossible to obtain the 'wmxsdk' that contains said 'device_id'. Thus, implemented device_id_to_wmxsdk() by iterating over the list of known wmxsdks looking for an index match. --- plugins/iwmxsdk.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/iwmxsdk.c b/plugins/iwmxsdk.c index 52437f5..f8a0501 100644 --- a/plugins/iwmxsdk.c +++ b/plugins/iwmxsdk.c @@ -47,7 +47,14 @@ static struct wmxsdk *g_iwmx_sdk_devs[IWMX_SDK_DEV_MAX]; static struct wmxsdk *deviceid_to_wmxsdk(WIMAX_API_DEVICE_ID *device_id) { - return container_of(device_id, struct wmxsdk, device_id); + unsigned cnt; + for (cnt = 0; cnt < IWMX_SDK_DEV_MAX; cnt++) { + struct wmxsdk *wmxsdk = g_iwmx_sdk_devs[cnt]; + if (wmxsdk && + wmxsdk->device_id.deviceIndex == device_id->deviceIndex) + return wmxsdk; + } + return NULL; } static WIMAX_API_DEVICE_ID g_api; -- 2.7.4