This is a small set of patches for elflink branch based on feng's elflink branch. hpa, It seems that I can't log on terminus by ssh at home. So I can't push these patches on my git tree. Liu Aleaxander (4): elflink: Cleanup some warnings elflink: Fix the wrong malloc size in enter_cmdline elflink: Do clear screen even if we have no pDraw_Menu method elflink: Add Ctrl-p + Ctrl-n key binds core/elflink/cli.c | 10 +++++----- core/elflink/execute.c | 3 +++ core/elflink/get_key.c | 2 ++ core/elflink/getadv.c | 2 +- core/elflink/load_env32.c | 11 ++++++----- core/elflink/readconfig.c | 1 - 6 files changed, 17 insertions(+), 12 deletions(-)
Liu Aleaxander
2010-Oct-02 16:36 UTC
[syslinux] [PATCH 1/4] elflink: Cleanup some warnings
Cleanup some unused variables, goto lables, and add the missing
header files.
Signed-off-by: Liu Aleaxander <Aleaxander at gmail.com>
---
core/elflink/cli.c | 1 -
core/elflink/execute.c | 3 +++
core/elflink/get_key.c | 2 ++
core/elflink/getadv.c | 2 +-
core/elflink/load_env32.c | 6 ++++--
core/elflink/readconfig.c | 1 -
6 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/core/elflink/cli.c b/core/elflink/cli.c
index f029ae4..4876dca 100644
--- a/core/elflink/cli.c
+++ b/core/elflink/cli.c
@@ -404,7 +404,6 @@ void process_command(const char *cmd)
else
execute(temp_cmd, KT_KERNEL);
-cleanup:
free(argv);
free(temp_cmd);
}
diff --git a/core/elflink/execute.c b/core/elflink/execute.c
index 29e9933..1d024a6 100644
--- a/core/elflink/execute.c
+++ b/core/elflink/execute.c
@@ -15,7 +15,10 @@
#include <stdio.h>
#include <com32.h>
+#include <sys/exec.h>
#include "menu.h"
+#include "core.h"
+#include "core-elf.h"
void execute(const char *cmdline, enum kernel_type type)
{
diff --git a/core/elflink/get_key.c b/core/elflink/get_key.c
index b2f7092..2a10290 100644
--- a/core/elflink/get_key.c
+++ b/core/elflink/get_key.c
@@ -43,6 +43,8 @@
#include <sys/times.h>
#include <sys/module.h>
+#include <syslinux/idle.h>
+
#include "getkey.h"
struct keycode {
diff --git a/core/elflink/getadv.c b/core/elflink/getadv.c
index 456084b..5578313 100644
--- a/core/elflink/getadv.c
+++ b/core/elflink/getadv.c
@@ -39,7 +39,7 @@
const void *syslinux_getadv(int tag, size_t * size)
{
const uint8_t *p;
- size_t left, len;
+ size_t left;
p = syslinux_adv_ptr();
left = syslinux_adv_size();
diff --git a/core/elflink/load_env32.c b/core/elflink/load_env32.c
index 8d0a557..3f4b6ff 100644
--- a/core/elflink/load_env32.c
+++ b/core/elflink/load_env32.c
@@ -68,7 +68,7 @@ static void call_constr(void)
void enter_cmdline(void)
{
struct cli_command *comm, *aux;
- char *cmdline;
+ const char *cmdline;
/* Enter endless command line prompt, should support "exit" */
while (1) {
@@ -89,7 +89,7 @@ void enter_cmdline(void)
/* parameter is the config file name if any */
void start_ui(char *config_file)
{
- char *cmdline;
+ const char *cmdline;
char *argv[2] = {config_file, NULL};
mp("enter, config file = %s", config_file);
@@ -112,6 +112,8 @@ void start_ui(char *config_file)
/* note to self: do _*NOT*_ use static key word on this function */
void load_env32(com32sys_t * regs)
{
+ (void)regs;
+
printf("Starting 32 bit elf module subsystem...\n");
call_constr();
openconsole(&dev_rawcon_r, &dev_ansiserial_w);
diff --git a/core/elflink/readconfig.c b/core/elflink/readconfig.c
index c984fa8..30abbcd 100644
--- a/core/elflink/readconfig.c
+++ b/core/elflink/readconfig.c
@@ -1135,7 +1135,6 @@ void parse_configs(char **argv)
const char *filename;
struct menu *m;
struct menu_entry *me;
- char *cmdline;
mp("enter");
empty_string = refstrdup("");
--
1.7.0.1
Liu Aleaxander
2010-Oct-02 16:36 UTC
[syslinux] [PATCH 2/4] elflink: Fix the wrong malloc size in enter_cmdline
Signed-off-by: Liu Aleaxander <Aleaxander at gmail.com>
---
core/elflink/load_env32.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/core/elflink/load_env32.c b/core/elflink/load_env32.c
index 3f4b6ff..99bf7a3 100644
--- a/core/elflink/load_env32.c
+++ b/core/elflink/load_env32.c
@@ -76,9 +76,8 @@ void enter_cmdline(void)
/* feng: give up the aux check here */
//aux = list_entry(cli_history_head.next, typeof(*aux), list);
//if (strcmp(aux->command, cmdline)) {
- comm = (struct cli_command *)malloc(sizeof(struct cli_command *));
- comm->command - (char *)malloc(sizeof(char) * (strlen(cmdline) + 1));
+ comm = malloc(sizeof(struct cli_command));
+ comm->command = malloc(sizeof(char) * (strlen(cmdline) + 1));
strcpy(comm->command, cmdline);
list_add(&(comm->list), &cli_history_head);
process_command(cmdline);
--
1.7.0.1
Liu Aleaxander
2010-Oct-02 16:36 UTC
[syslinux] [PATCH 3/4] elflink: Do clear screen even if we have no pDraw_Menu method
Do clear screen even if we have no pDraw_Menu method, since user
may work in CLI mode and want to clear screen by pressing 'Ctrl-L'.
Signed-off-by: Liu Aleaxander <Aleaxander at gmail.com>
---
core/elflink/cli.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/core/elflink/cli.c b/core/elflink/cli.c
index 4876dca..3099cb4 100644
--- a/core/elflink/cli.c
+++ b/core/elflink/cli.c
@@ -94,14 +94,13 @@ const char *edit_cmdline(const char *input, int top /*, int
width */ ,
x = y = 0;
while (!done) {
- if (redraw > 1 && pDraw_Menu != NULL) {
+ if (redraw > 1) {
/* Clear and redraw whole screen */
/* Enable ASCII on G0 and DEC VT on G1; do it in this order
to avoid confusing the Linux console */
- /* clear_screen();
- draw_menu(-1, top, 1); */
clear_screen();
- (*pDraw_Menu) (-1, top, 1);
+ if (pDraw_Menu)
+ (*pDraw_Menu) (-1, top, 1);
prev_len = 0;
// printf("\033[0m\033[2J\033[H");
}
--
1.7.0.1
Liu Aleaxander
2010-Oct-02 16:36 UTC
[syslinux] [PATCH 4/4] elflink: Add Ctrl-p + Ctrl-n key binds
Add ctrl-p and ctrl-n key binds to get the prev and next
command. They are much easier to reach than KEY_UP and
KEY_DOWN.
Signed-off-by: Liu Aleaxander <Aleaxander at gmail.com>
---
core/elflink/cli.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/core/elflink/cli.c b/core/elflink/cli.c
index 3099cb4..408921e 100644
--- a/core/elflink/cli.c
+++ b/core/elflink/cli.c
@@ -281,6 +281,7 @@ const char *edit_cmdline(const char *input, int top /*, int
width */ ,
redraw = 1;
}
break;
+ case KEY_CTRL('P'):
case KEY_UP:
{
if (!list_empty(&cli_history_head)) {
@@ -297,6 +298,7 @@ const char *edit_cmdline(const char *input, int top /*, int
width */ ,
}
}
break;
+ case KEY_CTRL('N'):
case KEY_DOWN:
{
if (!list_empty(&cli_history_head)) {
--
1.7.0.1