aboutsummaryrefslogtreecommitdiff
path: root/console-tools
diff options
context:
space:
mode:
Diffstat (limited to 'console-tools')
-rw-r--r--console-tools/chvt.c3
-rw-r--r--console-tools/deallocvt.c2
-rw-r--r--console-tools/dumpkmap.c2
-rw-r--r--console-tools/kbd_mode.c17
-rw-r--r--console-tools/loadfont.c2
-rw-r--r--console-tools/loadkmap.c2
-rw-r--r--console-tools/setkeycodes.c6
7 files changed, 16 insertions, 18 deletions
diff --git a/console-tools/chvt.c b/console-tools/chvt.c
index ea3e7c048..302ffb4f9 100644
--- a/console-tools/chvt.c
+++ b/console-tools/chvt.c
@@ -19,7 +19,6 @@ int chvt_main(int argc, char **argv)
}
num = xatou_range(argv[1], 1, 63);
- /* double cast suppresses "cast to ptr from int of different size" */
- console_make_active(get_console_fd(), num);
+ console_make_active(get_console_fd_or_die(), num);
return EXIT_SUCCESS;
}
diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c
index e9a3989c7..09748834f 100644
--- a/console-tools/deallocvt.c
+++ b/console-tools/deallocvt.c
@@ -28,6 +28,6 @@ int deallocvt_main(int argc UNUSED_PARAM, char **argv)
}
/* double cast suppresses "cast to ptr from int of different size" */
- xioctl(get_console_fd(), VT_DISALLOCATE, (void *)(ptrdiff_t)num);
+ xioctl(get_console_fd_or_die(), VT_DISALLOCATE, (void *)(ptrdiff_t)num);
return EXIT_SUCCESS;
}
diff --git a/console-tools/dumpkmap.c b/console-tools/dumpkmap.c
index 1d6bbdc63..c382b5af9 100644
--- a/console-tools/dumpkmap.c
+++ b/console-tools/dumpkmap.c
@@ -32,7 +32,7 @@ int dumpkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
/* bb_warn_ignoring_args(argc>=2);*/
- fd = xopen(CURRENT_VC, O_RDWR);
+ fd = get_console_fd_or_die();
write(STDOUT_FILENO, "bkeymap", 7);
diff --git a/console-tools/kbd_mode.c b/console-tools/kbd_mode.c
index 2162fd4fc..cb97947ce 100644
--- a/console-tools/kbd_mode.c
+++ b/console-tools/kbd_mode.c
@@ -19,17 +19,15 @@ int kbd_mode_main(int argc UNUSED_PARAM, char **argv)
int fd;
unsigned opt;
enum {
- SCANCODE = (1<<0),
- ASCII = (1<<1),
- MEDIUMRAW= (1<<2),
- UNICODE = (1<<3)
+ SCANCODE = (1 << 0),
+ ASCII = (1 << 1),
+ MEDIUMRAW = (1 << 2),
+ UNICODE = (1 << 3)
};
static const char KD_xxx[] ALIGN1 = "saku";
opt = getopt32(argv, KD_xxx);
- fd = get_console_fd();
-/* if (fd < 0)
- return EXIT_FAILURE;
-*/
+ fd = get_console_fd_or_die();
+
if (!opt) { /* print current setting */
const char *mode = "unknown";
int m;
@@ -46,7 +44,8 @@ int kbd_mode_main(int argc UNUSED_PARAM, char **argv)
printf("The keyboard is in %s mode\n", mode);
} else {
opt = opt & UNICODE ? 3 : opt >> 1;
- xioctl(fd, KDSKBMODE, opt);
+ /* double cast prevents warnings about widening conversion */
+ xioctl(fd, KDSKBMODE, (void*)(ptrdiff_t)opt);
}
if (ENABLE_FEATURE_CLEAN_UP)
diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c
index 48b298002..567aa38ae 100644
--- a/console-tools/loadfont.c
+++ b/console-tools/loadfont.c
@@ -174,7 +174,7 @@ int loadfont_main(int argc, char **argv UNUSED_PARAM)
if (argc != 1)
bb_show_usage();
- fd = xopen(CURRENT_VC, O_RDWR);
+ fd = get_console_fd_or_die();
loadnewfont(fd);
return EXIT_SUCCESS;
diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c
index b891c9b0e..56948e0d0 100644
--- a/console-tools/loadkmap.c
+++ b/console-tools/loadkmap.c
@@ -35,7 +35,7 @@ int loadkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
/* bb_warn_ignoring_args(argc>=2);*/
- fd = xopen(CURRENT_VC, O_RDWR);
+ fd = get_console_fd_or_die();
xread(STDIN_FILENO, flags, 7);
if (strncmp(flags, BINARY_KEYMAP_MAGIC, 7))
diff --git a/console-tools/setkeycodes.c b/console-tools/setkeycodes.c
index e9a050862..597272a2f 100644
--- a/console-tools/setkeycodes.c
+++ b/console-tools/setkeycodes.c
@@ -26,11 +26,11 @@ int setkeycodes_main(int argc, char **argv)
int fd, sc;
struct kbkeycode a;
- if (argc % 2 != 1 || argc < 2) {
+ if (!(argc & 1) /* if even */ || argc < 2) {
bb_show_usage();
}
- fd = get_console_fd();
+ fd = get_console_fd_or_die();
while (argc > 2) {
a.keycode = xatou_range(argv[2], 0, 127);
@@ -40,7 +40,7 @@ int setkeycodes_main(int argc, char **argv)
a.scancode += 128;
}
ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a,
- "failed to set SCANCODE %x to KEYCODE %d",
+ "can't set SCANCODE %x to KEYCODE %d",
sc, a.keycode);
argc -= 2;
argv += 2;