Getevent: make sure the monotonic timestamp is displayed; warning cleanup.

Change-Id: I6c500ab55470155ddf692fe5f655bdd575f195f5
Signed-off-by: Sasha Levitskiy <sanek@google.com>
This commit is contained in:
Sasha Levitskiy 2013-10-23 11:31:02 -07:00
parent c15e993467
commit 2037a307a4
1 changed files with 10 additions and 4 deletions

View File

@ -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");
@ -570,7 +576,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);
@ -582,7 +588,7 @@ int getevent_main(int argc, char *argv[])
optind++;
}
if (optind != argc) {
usage(argc, argv);
usage(argv[0]);
exit(1);
}
nfds = 1;