diff options
| author | Sasha Levitskiy <sanek@google.com> | 2013-10-23 11:31:02 -0700 |
|---|---|---|
| committer | Colin Cross <ccross@android.com> | 2014-06-11 11:10:28 -0700 |
| commit | 140b13546ac30a836e39ad4f22da042b3fcb57a4 (patch) | |
| tree | 3a61afc007e174d8a14f5b73d27ecf71d6082172 /toolbox | |
| parent | 38e5f07c0f93e333b35cffc9bb902de599a3bef9 (diff) | |
| download | system_core-140b13546ac30a836e39ad4f22da042b3fcb57a4.tar.gz system_core-140b13546ac30a836e39ad4f22da042b3fcb57a4.tar.bz2 system_core-140b13546ac30a836e39ad4f22da042b3fcb57a4.zip | |
Getevent: make sure the monotonic timestamp is displayed; warning cleanup.
Change-Id: I6c500ab55470155ddf692fe5f655bdd575f195f5
Signed-off-by: Sasha Levitskiy <sanek@google.com>
Diffstat (limited to 'toolbox')
| -rw-r--r-- | toolbox/getevent.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/toolbox/getevent.c b/toolbox/getevent.c index c2256ff8d..da83ec38d 100644 --- a/toolbox/getevent.c +++ b/toolbox/getevent.c @@ -295,6 +295,7 @@ static int open_device(const char *device, int print_flags) { int version; int fd; + int clkid = CLOCK_MONOTONIC; struct pollfd *new_ufds; char **new_device_names; char name[80]; @@ -335,6 +336,11 @@ static int open_device(const char *device, int print_flags) idstr[0] = '\0'; } + if (ioctl(fd, EVIOCSCLOCKID, &clkid) != 0) { + fprintf(stderr, "Can't enable monotonic clock reporting: %s\n", strerror(errno)); + // a non-fatal error + } + new_ufds = realloc(ufds, sizeof(ufds[0]) * (nfds + 1)); if(new_ufds == NULL) { fprintf(stderr, "out of memory\n"); @@ -470,9 +476,9 @@ static int scan_dir(const char *dirname, int print_flags) return 0; } -static void usage(int argc, char *argv[]) +static void usage(char *name) { - fprintf(stderr, "Usage: %s [-t] [-n] [-s switchmask] [-S] [-v [mask]] [-d] [-p] [-i] [-l] [-q] [-c count] [-r] [device]\n", argv[0]); + fprintf(stderr, "Usage: %s [-t] [-n] [-s switchmask] [-S] [-v [mask]] [-d] [-p] [-i] [-l] [-q] [-c count] [-r] [device]\n", name); fprintf(stderr, " -t: show time stamps\n"); fprintf(stderr, " -n: don't print newlines\n"); fprintf(stderr, " -s: print switch states for given bits\n"); @@ -568,7 +574,7 @@ int getevent_main(int argc, char *argv[]) fprintf(stderr, "%s: invalid option -%c\n", argv[0], optopt); case 'h': - usage(argc, argv); + usage(argv[0]); exit(1); } } while (1); @@ -580,7 +586,7 @@ int getevent_main(int argc, char *argv[]) optind++; } if (optind != argc) { - usage(argc, argv); + usage(argv[0]); exit(1); } nfds = 1; |
