[syslinux] [PATCH 05/20] com32: console is already initialised when we enter main()

Matt Fleming matt at console-pimps.org
Sat Apr 16 07:17:33 PDT 2011


From: Matt Fleming <matt.fleming at linux.intel.com>

There's no need to initialise the console when we enter main() as
ldlinux.c32 will already have initialised it for us. Leaving the calls
to openconsole() causes the console settings to be reset whenever we
run a module.

Signed-off-by: Matt Fleming <matt.fleming at linux.intel.com>
---
 com32/modules/cat.c       |    2 --
 com32/modules/chain.c     |    2 --
 com32/modules/config.c    |    2 --
 com32/modules/cpuid.c     |    2 --
 com32/modules/cpuidtest.c |    1 -
 com32/modules/dir.c       |    2 --
 com32/modules/disk.c      |    2 --
 com32/modules/dmitest.c   |    1 -
 com32/modules/elf.c       |    2 --
 com32/modules/ethersel.c  |    1 -
 com32/modules/gpxecmd.c   |    2 --
 com32/modules/host.c      |    2 --
 com32/modules/ifplop.c    |    2 --
 com32/modules/kbdmap.c    |    2 --
 com32/modules/linux.c     |    2 --
 com32/modules/ls.c        |    2 --
 com32/modules/meminfo.c   |    2 --
 com32/modules/pcitest.c   |    2 --
 com32/modules/pmload.c    |    2 --
 com32/modules/pwd.c       |    1 -
 com32/modules/sanboot.c   |    2 --
 com32/modules/sdi.c       |    2 --
 com32/modules/vesainfo.c  |    2 --
 com32/modules/vpdtest.c   |    1 -
 com32/modules/whichsys.c  |    2 --
 com32/sysdump/main.c      |    1 -
 26 files changed, 0 insertions(+), 46 deletions(-)

diff --git a/com32/modules/cat.c b/com32/modules/cat.c
index 0a9514c..2a7683f 100644
--- a/com32/modules/cat.c
+++ b/com32/modules/cat.c
@@ -9,8 +9,6 @@ int main(int argc, char *argv[])
     int len;
     char buf[4096];
 
-    openconsole(&dev_stdcon_r, &dev_stdcon_w);
-
     if (argc < 2) {
 	fprintf(stderr, "Usage: %s filename...\n", argv[0]);
 	return 1;
diff --git a/com32/modules/chain.c b/com32/modules/chain.c
index 48f53ff..09cbeff 100644
--- a/com32/modules/chain.c
+++ b/com32/modules/chain.c
@@ -1314,8 +1314,6 @@ int main(int argc, char *argv[])
     addr_t load_base;
     static const char cmldr_signature[8] = "cmdcons";
 
-    openconsole(&dev_null_r, &dev_stdcon_w);
-
     drivename = "boot";
     partition = NULL;
 
diff --git a/com32/modules/config.c b/com32/modules/config.c
index 334a635..04cb0ab 100644
--- a/com32/modules/config.c
+++ b/com32/modules/config.c
@@ -24,8 +24,6 @@
 
 int main(int argc, char *argv[])
 {
-    openconsole(&dev_null_r, &dev_stdcon_w);
-
     if (argc < 2 || argc > 3) {
 	fprintf(stderr, "Usage: config <filename> [<directory>]\n");
 	return 1;
diff --git a/com32/modules/cpuid.c b/com32/modules/cpuid.c
index 78cb3f5..a243896 100644
--- a/com32/modules/cpuid.c
+++ b/com32/modules/cpuid.c
@@ -34,8 +34,6 @@ int main(int argc, char *argv[])
     uint32_t leaf, counter;
     uint32_t eax, ebx, ecx, edx;
 
-    openconsole(&dev_null_r, &dev_stdcon_w);
-
     if (argc < 2 || argc > 4) {
 	printf("Usage: %s leaf [counter]\n", argv[0]);
 	exit(1);
diff --git a/com32/modules/cpuidtest.c b/com32/modules/cpuidtest.c
index b768885..d00256f 100644
--- a/com32/modules/cpuidtest.c
+++ b/com32/modules/cpuidtest.c
@@ -42,7 +42,6 @@ char display_line;
 int main(void)
 {
     s_cpu cpu;
-    openconsole(&dev_stdcon_r, &dev_stdcon_w);
 
     for (;;) {
 	detect_cpu(&cpu);
diff --git a/com32/modules/dir.c b/com32/modules/dir.c
index c9d9370..01a99ed 100644
--- a/com32/modules/dir.c
+++ b/com32/modules/dir.c
@@ -155,8 +155,6 @@ int main(int argc, char *argv[])
 {
     int rv;
 
-    openconsole(&dev_rawcon_r, &dev_stdcon_w);
-    
     if (getscreensize(1, &rows, &cols)) {
 	/* Unknown screen size? */
 	rows = 24;
diff --git a/com32/modules/disk.c b/com32/modules/disk.c
index ca4b598..5d68381 100644
--- a/com32/modules/disk.c
+++ b/com32/modules/disk.c
@@ -27,8 +27,6 @@ int main(int argc, char *argv[])
 	(void)argc;
 	(void)argv;
 
-	openconsole(&dev_null_r, &dev_stdcon_w);
-
 	for (int disk = 0x80; disk < 0xff; disk++) {
 		memset(d, 0, sizeof(struct driveinfo));
 		d->disk = disk;
diff --git a/com32/modules/dmitest.c b/com32/modules/dmitest.c
index 294585b..4ce2eaa 100644
--- a/com32/modules/dmitest.c
+++ b/com32/modules/dmitest.c
@@ -179,7 +179,6 @@ int main(void)
 {
     char buffer[1024];
     s_dmi dmi;
-    openconsole(&dev_stdcon_r, &dev_stdcon_w);
 
     if (dmi_iterate(&dmi) == -ENODMITABLE) {
 	printf("No DMI Structure found\n");
diff --git a/com32/modules/elf.c b/com32/modules/elf.c
index 182afa6..84c80ac 100644
--- a/com32/modules/elf.c
+++ b/com32/modules/elf.c
@@ -269,8 +269,6 @@ int main(int argc, char *argv[])
     void *data;
     size_t data_len;
 
-    openconsole(&dev_null_r, &dev_stdcon_w);
-
     if (argc < 2) {
 	error("Usage: elf.c32 elf_file arguments...\n");
 	return 1;
diff --git a/com32/modules/ethersel.c b/com32/modules/ethersel.c
index 5c3cf02..d6b4774 100644
--- a/com32/modules/ethersel.c
+++ b/com32/modules/ethersel.c
@@ -185,7 +185,6 @@ int main(int argc, char *argv[])
     struct match *list, *match;
     struct pci_domain *pci_domain;
 
-    openconsole(&dev_null_r, &dev_stdcon_w);
     pci_domain = pci_scan();
 
     if (pci_domain) {
diff --git a/com32/modules/gpxecmd.c b/com32/modules/gpxecmd.c
index 057659b..9ae1b60 100644
--- a/com32/modules/gpxecmd.c
+++ b/com32/modules/gpxecmd.c
@@ -68,8 +68,6 @@ static void gpxecmd(const char **args)
 
 int main(int argc, const char *argv[])
 {
-    openconsole(&dev_null_r, &dev_stdcon_w);
-
     if (argc < 2) {
 	printf("Usage: gpxecmd command...\n");
 	return 1;
diff --git a/com32/modules/host.c b/com32/modules/host.c
index 94ca876..c9cea97 100644
--- a/com32/modules/host.c
+++ b/com32/modules/host.c
@@ -25,8 +25,6 @@ int main(int argc, char *argv[])
     int i;
     struct in_addr addr;
 
-    openconsole(&dev_null_r, &dev_stdcon_w);
-
     for (i = 1; i < argc; i++) {
 	addr = dnsresolve(argv[i]);
 
diff --git a/com32/modules/ifplop.c b/com32/modules/ifplop.c
index a846df8..f502e2b 100644
--- a/com32/modules/ifplop.c
+++ b/com32/modules/ifplop.c
@@ -144,8 +144,6 @@ int main(int argc, char *argv[])
     char **args[2];
     int arg = 0;
 
-    openconsole(&dev_null_r, &dev_stdcon_w);
-
     if (argc)
 	arg++;
     args[0] = &argv[arg];
diff --git a/com32/modules/kbdmap.c b/com32/modules/kbdmap.c
index f1c736d..7ec4001 100644
--- a/com32/modules/kbdmap.c
+++ b/com32/modules/kbdmap.c
@@ -27,8 +27,6 @@ int main(int argc, char *argv[])
     size_t map_size;
     void *kbdmap;
 
-    openconsole(&dev_null_r, &dev_stdcon_w);
-
     if (argc != 2) {
 	error("Usage: kbdmap mapfile\n");
 	return 1;
diff --git a/com32/modules/linux.c b/com32/modules/linux.c
index b902ebc..a5ce01f 100644
--- a/com32/modules/linux.c
+++ b/com32/modules/linux.c
@@ -122,8 +122,6 @@ int main(int argc, char *argv[])
     size_t dhcplen;
     char **argp, *arg, *p;
 
-    openconsole(&dev_null_r, &dev_stdcon_w);
-
     (void)argc;
     argp = argv + 1;
 
diff --git a/com32/modules/ls.c b/com32/modules/ls.c
index c311621..11c18ae 100644
--- a/com32/modules/ls.c
+++ b/com32/modules/ls.c
@@ -155,8 +155,6 @@ int main(int argc, char *argv[])
 {
     int rv;
 
-    openconsole(&dev_rawcon_r, &dev_stdcon_w);
-    
     if (getscreensize(1, &rows, &cols)) {
 	/* Unknown screen size? */
 	rows = 24;
diff --git a/com32/modules/meminfo.c b/com32/modules/meminfo.c
index 6e24f35..96006d4 100644
--- a/com32/modules/meminfo.c
+++ b/com32/modules/meminfo.c
@@ -117,8 +117,6 @@ static void dump_legacy(void)
 
 int main(void)
 {
-    openconsole(&dev_null_r, &dev_stdcon_w);
-
     dump_legacy();
     dump_e820();
 
diff --git a/com32/modules/pcitest.c b/com32/modules/pcitest.c
index 672023a..c4317ef 100644
--- a/com32/modules/pcitest.c
+++ b/com32/modules/pcitest.c
@@ -108,8 +108,6 @@ int main(int argc, char *argv[])
     (void)argc;
     (void)argv;
 
-    openconsole(&dev_stdcon_r, &dev_stdcon_w);
-
     /* Scanning to detect pci buses and devices */
     printf("PCI: Scanning PCI BUS\n");
     pci_domain = pci_scan();
diff --git a/com32/modules/pmload.c b/com32/modules/pmload.c
index 3064a94..88065fb 100644
--- a/com32/modules/pmload.c
+++ b/com32/modules/pmload.c
@@ -204,8 +204,6 @@ int main(int argc, char *argv[])
     size_t data_len;
     addr_t where;
 
-    openconsole(&dev_null_r, &dev_stdcon_w);
-
     if (argc < 3) {
 	error("Usage: pmload.c32 bin_file address arguments...\n");
 	return 1;
diff --git a/com32/modules/pwd.c b/com32/modules/pwd.c
index 880327d..2794e3d 100644
--- a/com32/modules/pwd.c
+++ b/com32/modules/pwd.c
@@ -36,7 +36,6 @@ int main(void)
     int rv = 0;
     char pwd[PATH_MAX], *pwdptr;
 
-    openconsole(&dev_rawcon_r, &dev_stdcon_w);
     pwdptr = getcwd(pwd, PATH_MAX);
     if (pwdptr) {
        if (pwd[0] != 0)
diff --git a/com32/modules/sanboot.c b/com32/modules/sanboot.c
index 46df6bc..01265de 100644
--- a/com32/modules/sanboot.c
+++ b/com32/modules/sanboot.c
@@ -69,8 +69,6 @@ static void sanboot(const char **args)
 
 int main(int argc, const char *argv[])
 {
-    openconsole(&dev_null_r, &dev_stdcon_w);
-
     if (argc < 2) {
 	printf("Usage: sanboot rootpath\n");
 	return 1;
diff --git a/com32/modules/sdi.c b/com32/modules/sdi.c
index 69841d2..e57ad4a 100644
--- a/com32/modules/sdi.c
+++ b/com32/modules/sdi.c
@@ -160,8 +160,6 @@ int main(int argc, char *argv[])
     void *data;
     size_t data_len;
 
-    openconsole(&dev_null_r, &dev_stdcon_w);
-
     if (argc != 2) {
 	error("Usage: sdi.c32 sdi_file\n");
 	return 1;
diff --git a/com32/modules/vesainfo.c b/com32/modules/vesainfo.c
index 00181e4..f9b2502 100644
--- a/com32/modules/vesainfo.c
+++ b/com32/modules/vesainfo.c
@@ -75,8 +75,6 @@ static void print_modes(void)
 
 int main(void)
 {
-    openconsole(&dev_rawcon_r, &dev_stdcon_w);
-
     print_modes();
     return 0;
 }
diff --git a/com32/modules/vpdtest.c b/com32/modules/vpdtest.c
index 1d50c68..c0f32ba 100644
--- a/com32/modules/vpdtest.c
+++ b/com32/modules/vpdtest.c
@@ -40,7 +40,6 @@
 int main(void)
 {
     s_vpd vpd;
-    openconsole(&dev_stdcon_r, &dev_stdcon_w);
 
     if (vpd_decode(&vpd) == -ENOVPDTABLE) {
 	printf("No VPD Structure found\n");
diff --git a/com32/modules/whichsys.c b/com32/modules/whichsys.c
index af133f2..777cb9e 100644
--- a/com32/modules/whichsys.c
+++ b/com32/modules/whichsys.c
@@ -78,8 +78,6 @@ int main(int argc, char *argv[])
 
     int arg = 0;
 
-    openconsole(&dev_null_r, &dev_stdcon_w);
-
     /* If no argument got passed, let's show the usage */
     if (argc == 1) {
 	    usage();
diff --git a/com32/sysdump/main.c b/com32/sysdump/main.c
index d0d40a7..155b980 100644
--- a/com32/sysdump/main.c
+++ b/com32/sysdump/main.c
@@ -73,7 +73,6 @@ int main(int argc, char *argv[])
 {
     struct backend **bep, *be;
 
-    openconsole(&dev_null_r, &dev_stdcon_w);
     fputs(version, stdout);
 
     if (argc < 2)
-- 
1.7.4.2




More information about the Syslinux mailing list