summaryrefslogtreecommitdiffstats
path: root/src/hci/readline.c
diff options
context:
space:
mode:
authorMichael Brown2006-12-20 00:37:51 +0100
committerMichael Brown2006-12-20 00:37:51 +0100
commitb613086bfe77e0d1afd3f88a7ddfc6501a43200d (patch)
treed4061a04c33b11145e4300235672c224e50b074c /src/hci/readline.c
parentFunctioning readline() (diff)
downloadipxe-b613086bfe77e0d1afd3f88a7ddfc6501a43200d.tar.gz
ipxe-b613086bfe77e0d1afd3f88a7ddfc6501a43200d.tar.xz
ipxe-b613086bfe77e0d1afd3f88a7ddfc6501a43200d.zip
Explicitly print out-of-memory message to avoid tricking the user into
thinking that a command executed successfully.
Diffstat (limited to 'src/hci/readline.c')
-rw-r--r--src/hci/readline.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/hci/readline.c b/src/hci/readline.c
index 36ba429e..a8cc455c 100644
--- a/src/hci/readline.c
+++ b/src/hci/readline.c
@@ -85,7 +85,7 @@ char * readline ( const char *prompt ) {
.cursor = 0,
};
int key;
- char *line = NULL;
+ char *line;
if ( prompt )
printf ( "%s", prompt );
@@ -97,17 +97,17 @@ char * readline ( const char *prompt ) {
switch ( key ) {
case 0x0d: /* Carriage return */
case 0x0a: /* Line feed */
+ putchar ( '\n' );
line = strdup ( buf );
- goto out;
+ if ( ! line )
+ printf ( "Out of memory\n" );
+ return line;
case 0x03: /* Ctrl-C */
- goto out;
+ putchar ( '\n' );
+ return NULL;
default:
/* Do nothing */
break;
}
}
-
- out:
- putchar ( '\n' );
- return line;
}