summaryrefslogtreecommitdiff
path: root/console-tools
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-08-05 23:32:27 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-08-05 23:32:27 +0000
commit2afd5ab62ca5f2438a3953f37e738f73553595da (patch)
treef6406254bd52e449ac58851e370774ed29e449c2 /console-tools
parente0143a1aad60e9141245034379469477006dba81 (diff)
downloadbusybox-w32-2afd5ab62ca5f2438a3953f37e738f73553595da.tar.gz
busybox-w32-2afd5ab62ca5f2438a3953f37e738f73553595da.tar.bz2
busybox-w32-2afd5ab62ca5f2438a3953f37e738f73553595da.zip
*: use get_console_fd() as appropriate, and make it fail on open error -
get_console_fd_or_die(). function old new delta get_console_fd_or_die - 163 +163 loadkmap_main 211 201 -10 loadfont_main 440 430 -10 dumpkmap_main 218 208 -10 kbd_mode_main 158 146 -12 setkeycodes_main 156 143 -13 get_console_fd 163 - -163 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 0/5 up/down: 163/-218) Total: -55 bytes
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)
19 } 19 }
20 20
21 num = xatou_range(argv[1], 1, 63); 21 num = xatou_range(argv[1], 1, 63);
22 /* double cast suppresses "cast to ptr from int of different size" */ 22 console_make_active(get_console_fd_or_die(), num);
23 console_make_active(get_console_fd(), num);
24 return EXIT_SUCCESS; 23 return EXIT_SUCCESS;
25} 24}
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)
28 } 28 }
29 29
30 /* double cast suppresses "cast to ptr from int of different size" */ 30 /* double cast suppresses "cast to ptr from int of different size" */
31 xioctl(get_console_fd(), VT_DISALLOCATE, (void *)(ptrdiff_t)num); 31 xioctl(get_console_fd_or_die(), VT_DISALLOCATE, (void *)(ptrdiff_t)num);
32 return EXIT_SUCCESS; 32 return EXIT_SUCCESS;
33} 33}
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)
32 32
33/* bb_warn_ignoring_args(argc>=2);*/ 33/* bb_warn_ignoring_args(argc>=2);*/
34 34
35 fd = xopen(CURRENT_VC, O_RDWR); 35 fd = get_console_fd_or_die();
36 36
37 write(STDOUT_FILENO, "bkeymap", 7); 37 write(STDOUT_FILENO, "bkeymap", 7);
38 38
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)
19 int fd; 19 int fd;
20 unsigned opt; 20 unsigned opt;
21 enum { 21 enum {
22 SCANCODE = (1<<0), 22 SCANCODE = (1 << 0),
23 ASCII = (1<<1), 23 ASCII = (1 << 1),
24 MEDIUMRAW= (1<<2), 24 MEDIUMRAW = (1 << 2),
25 UNICODE = (1<<3) 25 UNICODE = (1 << 3)
26 }; 26 };
27 static const char KD_xxx[] ALIGN1 = "saku"; 27 static const char KD_xxx[] ALIGN1 = "saku";
28 opt = getopt32(argv, KD_xxx); 28 opt = getopt32(argv, KD_xxx);
29 fd = get_console_fd(); 29 fd = get_console_fd_or_die();
30/* if (fd < 0) 30
31 return EXIT_FAILURE;
32*/
33 if (!opt) { /* print current setting */ 31 if (!opt) { /* print current setting */
34 const char *mode = "unknown"; 32 const char *mode = "unknown";
35 int m; 33 int m;
@@ -46,7 +44,8 @@ int kbd_mode_main(int argc UNUSED_PARAM, char **argv)
46 printf("The keyboard is in %s mode\n", mode); 44 printf("The keyboard is in %s mode\n", mode);
47 } else { 45 } else {
48 opt = opt & UNICODE ? 3 : opt >> 1; 46 opt = opt & UNICODE ? 3 : opt >> 1;
49 xioctl(fd, KDSKBMODE, opt); 47 /* double cast prevents warnings about widening conversion */
48 xioctl(fd, KDSKBMODE, (void*)(ptrdiff_t)opt);
50 } 49 }
51 50
52 if (ENABLE_FEATURE_CLEAN_UP) 51 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)
174 if (argc != 1) 174 if (argc != 1)
175 bb_show_usage(); 175 bb_show_usage();
176 176
177 fd = xopen(CURRENT_VC, O_RDWR); 177 fd = get_console_fd_or_die();
178 loadnewfont(fd); 178 loadnewfont(fd);
179 179
180 return EXIT_SUCCESS; 180 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)
35 35
36/* bb_warn_ignoring_args(argc>=2);*/ 36/* bb_warn_ignoring_args(argc>=2);*/
37 37
38 fd = xopen(CURRENT_VC, O_RDWR); 38 fd = get_console_fd_or_die();
39 39
40 xread(STDIN_FILENO, flags, 7); 40 xread(STDIN_FILENO, flags, 7);
41 if (strncmp(flags, BINARY_KEYMAP_MAGIC, 7)) 41 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)
26 int fd, sc; 26 int fd, sc;
27 struct kbkeycode a; 27 struct kbkeycode a;
28 28
29 if (argc % 2 != 1 || argc < 2) { 29 if (!(argc & 1) /* if even */ || argc < 2) {
30 bb_show_usage(); 30 bb_show_usage();
31 } 31 }
32 32
33 fd = get_console_fd(); 33 fd = get_console_fd_or_die();
34 34
35 while (argc > 2) { 35 while (argc > 2) {
36 a.keycode = xatou_range(argv[2], 0, 127); 36 a.keycode = xatou_range(argv[2], 0, 127);
@@ -40,7 +40,7 @@ int setkeycodes_main(int argc, char **argv)
40 a.scancode += 128; 40 a.scancode += 128;
41 } 41 }
42 ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a, 42 ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a,
43 "failed to set SCANCODE %x to KEYCODE %d", 43 "can't set SCANCODE %x to KEYCODE %d",
44 sc, a.keycode); 44 sc, a.keycode);
45 argc -= 2; 45 argc -= 2;
46 argv += 2; 46 argv += 2;