diff options
author | David 'Digit' Turner <digit@android.com> | 2011-05-10 14:40:18 -0700 |
---|---|---|
committer | Android Code Review <code-review@android.com> | 2011-05-10 14:40:18 -0700 |
commit | b9697ca80a8403f2cc07de010511510fdaa87315 (patch) | |
tree | f88726b42a65d6565014d06c07d9257ed1bb4cd5 | |
parent | cee98de91c5380efbc321bf01a6025675fbed748 (diff) | |
parent | 88935f701f51d84ed536cb55cc7b2ba391d7597e (diff) | |
download | external_qemu-b9697ca80a8403f2cc07de010511510fdaa87315.zip external_qemu-b9697ca80a8403f2cc07de010511510fdaa87315.tar.gz external_qemu-b9697ca80a8403f2cc07de010511510fdaa87315.tar.bz2 |
Merge "console: Fix 'event send' handling."
-rw-r--r-- | android/console.c | 6 | ||||
-rw-r--r-- | android/hw-events.c | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/android/console.c b/android/console.c index 505d331..daae2d7 100644 --- a/android/console.c +++ b/android/console.c @@ -1854,9 +1854,10 @@ do_event_send( ControlClient client, char* args ) p = args; while (*p) { char* q; + char temp[128]; int type, code, value, ret; - p += strspn( args, " \t" ); /* skip spaces */ + p += strspn( p, " \t" ); /* skip spaces */ if (*p == 0) break; @@ -1865,7 +1866,8 @@ do_event_send( ControlClient client, char* args ) if (q == p) break; - ret = android_event_from_str( p, &type, &code, &value ); + snprintf(temp, sizeof temp, "%.*s", q-p, p); + ret = android_event_from_str( temp, &type, &code, &value ); if (ret < 0) { if (ret == -1) { control_write( client, diff --git a/android/hw-events.c b/android/hw-events.c index 7c3f9e9..4318f65 100644 --- a/android/hw-events.c +++ b/android/hw-events.c @@ -106,7 +106,7 @@ eventList_findCodeByName( EventList list, if (namelen <= 0) return -1; - for ( ; list != NULL; list += 1 ) { + for ( ; list->name != NULL; list += 1 ) { if ( !memcmp(name, list->name, namelen) && list->name[namelen] == 0 ) { @@ -167,7 +167,11 @@ android_event_from_str( const char* name, q = pend; list = eventList_findByType( *ptype ); - *pcode = eventList_findCodeByName( list, p, q-p ); + if (list == NULL) { + *pcode = -1; + } else { + *pcode = eventList_findCodeByName( list, p, q-p ); + } if (*pcode < 0) { *pcode = (int) strtol( p, &end, 0 ); if (end != q) |