From 05fe983757a85fb79267c1a3b1015aebd8c32894 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Wed, 13 Jan 2021 23:02:55 +0100 Subject: [PATCH] android: Use event identifier instead of userdata pointer (#1826) ndk-glue currently sets both the `ident` field and user-data pointer to `0` or `1` for the event pipe and input queue respectively, to tell these sources apart. While it works to reinterpret this `data` pointer as integer identifier it shouldn't be abused for that, in particular when one may wish to provide extra information with an event in the future; then the `data` field is used as pointer (or abused as abstract value) for that. --- src/platform_impl/android/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform_impl/android/mod.rs b/src/platform_impl/android/mod.rs index 31447ddd..add163a0 100644 --- a/src/platform_impl/android/mod.rs +++ b/src/platform_impl/android/mod.rs @@ -30,7 +30,7 @@ enum EventSource { fn poll(poll: Poll) -> Option { match poll { - Poll::Event { data, .. } => match data as usize { + Poll::Event { ident, .. } => match ident { 0 => Some(EventSource::Callback), 1 => Some(EventSource::InputQueue), _ => unreachable!(),