diff options
author | Denis Vlasenko | 2006-10-08 12:49:22 +0000 |
---|---|---|
committer | Denis Vlasenko | 2006-10-08 12:49:22 +0000 |
commit | 1385899416a4396385ad421ae1f532be7103738a (patch) | |
tree | fc4d14a910593d1235318bb36abe5e9f72d2039e /console-tools/setkeycodes.c | |
parent | 5625415085e68ac5e150f54e685417c866620d76 (diff) | |
download | busybox-1385899416a4396385ad421ae1f532be7103738a.zip busybox-1385899416a4396385ad421ae1f532be7103738a.tar.gz |
attempt to regularize atoi mess.
Diffstat (limited to 'console-tools/setkeycodes.c')
-rw-r--r-- | console-tools/setkeycodes.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/console-tools/setkeycodes.c b/console-tools/setkeycodes.c index 607b8c7..d825257 100644 --- a/console-tools/setkeycodes.c +++ b/console-tools/setkeycodes.c @@ -27,7 +27,6 @@ enum { extern int setkeycodes_main(int argc, char** argv) { - char *ep; int fd, sc; struct kbkeycode a; @@ -38,19 +37,13 @@ setkeycodes_main(int argc, char** argv) fd = get_console_fd(); while (argc > 2) { - a.keycode = atoi(argv[2]); - a.scancode = sc = strtol(argv[1], &ep, 16); - if (*ep) { - bb_error_msg_and_die("error reading SCANCODE: '%s'", argv[1]); - } + a.keycode = xatoul_range(argv[2], 0, 127); + a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255); if (a.scancode > 127) { a.scancode -= 0xe000; a.scancode += 128; } - if (a.scancode > 255 || a.keycode > 127) { - bb_error_msg_and_die("SCANCODE or KEYCODE outside bounds"); - } - if (ioctl(fd,KDSETKEYCODE,&a)) { + if (ioctl(fd, KDSETKEYCODE, &a)) { bb_perror_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode); } argc -= 2; |