attempt to regularize atoi mess.
This commit is contained in:
@@ -7,11 +7,6 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
@@ -29,7 +24,7 @@ int chvt_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
fd = get_console_fd();
|
||||
num = bb_xgetlarg(argv[1], 10, 0, INT_MAX);
|
||||
num = xatoul_range(argv[1], 1, 63);
|
||||
if ((-1 == ioctl(fd, VT_ACTIVATE, num))
|
||||
|| (-1 == ioctl(fd, VT_WAITACTIVE, num))) {
|
||||
bb_perror_msg_and_die("ioctl");
|
||||
|
@@ -10,11 +10,6 @@
|
||||
|
||||
/* no options, no getopt */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
@@ -26,15 +21,13 @@ int deallocvt_main(int argc, char *argv[])
|
||||
int num = 0;
|
||||
|
||||
switch (argc) {
|
||||
case 2:
|
||||
if ((num = bb_xgetlarg(argv[1], 10, 0, INT_MAX)) == 0) {
|
||||
bb_error_msg_and_die("0: illegal VT number");
|
||||
}
|
||||
case 2:
|
||||
num = xatoul_range(argv[1], 1, 63);
|
||||
/* Fallthrough */
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
bb_show_usage();
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) {
|
||||
|
@@ -10,14 +10,6 @@
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
int openvt_main(int argc, char **argv)
|
||||
@@ -29,8 +21,8 @@ int openvt_main(int argc, char **argv)
|
||||
if (argc < 3) {
|
||||
bb_show_usage();
|
||||
}
|
||||
/* check for Illegal vt number: < 1 or > 12 */
|
||||
sprintf(vtname, VC_FORMAT, (int)bb_xgetlarg(argv[1], 10, 1, 12));
|
||||
/* check for illegal vt number: < 1 or > 63 */
|
||||
sprintf(vtname, VC_FORMAT, (int)xatoul_range(argv[1], 1, 63));
|
||||
|
||||
if (fork() == 0) {
|
||||
/* leave current vt */
|
||||
|
@@ -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;
|
||||
|
@@ -22,7 +22,7 @@ extern int setlogcons_main(int argc, char **argv)
|
||||
arg.subarg = 0; /* to specified console (current as default) */
|
||||
|
||||
if (argc == 2)
|
||||
arg.subarg = atoi(argv[1]);
|
||||
arg.subarg = xatoul_range(argv[1], 0, 63);
|
||||
|
||||
if (ioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg))
|
||||
bb_perror_msg_and_die("TIOCLINUX");
|
||||
|
Reference in New Issue
Block a user