[BusyBox] [PATCH] size optimization for openvt.c

Tito farmatito at tiscali.it
Mon Jan 12 22:12:01 UTC 2004


Hi to all,
the attached patch for openvt removes not needed vars and code so
size for openvt.o is reduced from:

text    data     bss     dec     hex  filename
209         0        0      209       d1 openvt_orig.o
rw-r--r--    1 root     root         1448 Jan 11 19:55 openvt_orig.o

to:

text    data     bss     dec     hex filename
194         0         0     194      c2 openvt.o
-rw-r--r--    1 root     root         1400 Jan 11 22:47 openvt.o

it also removes #define VTNAME "/dev/tty%d" and substitutes it 
with VC_FORMAT as defined in libbb.h ( I hope this is ok : I tested it
with CONFIG_FEATURE_DEVFS enabled and disabled and it worked ),

Ciao,
Tito
-------------- next part --------------
--- busybox-1.00-pre5/console-tools/openvt.c	2003-12-20 06:00:08.000000000 +0000
+++ busybox-1.00-pre5_new/console-tools/openvt.c	2004-01-12 21:26:50.000000000 +0000
@@ -32,31 +32,22 @@
 
 #include "busybox.h"
 
-#define VTNAME "/dev/tty%d"
-
 int openvt_main(int argc, char **argv)
 {
-	int pid;
 	int fd;
-	int vtno;
-	char vtname[sizeof VTNAME + 2];
+	char vtname[sizeof VC_FORMAT + 2];
 
 
 	if (argc < 3)
         bb_show_usage();
 
-	if (!isdigit(argv[1][0]))
-	        bb_show_usage();
-
-	/* check for Illegal vt number */
-	vtno=bb_xgetlarg(argv[1], 10, 1, 12);
-
-	sprintf(vtname, VTNAME, vtno);
+	/* check for Illegal vt number: < 1 or > 12 */
+	sprintf(vtname, VC_FORMAT,(int)bb_xgetlarg(argv[1], 10, 1, 12));
 
 	argv+=2;
 	argc-=2;
 
-	if((pid = fork()) == 0) {
+	if(fork() == 0) {
 		/* leave current vt */
 
 #ifdef   ESIX_5_3_2_D


More information about the busybox mailing list