Browse Source

[image] Clear the command line rather than setting an empty command line

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
2dd23e1ee9
1 changed files with 6 additions and 3 deletions
  1. 6
    3
      src/hci/commands/image_cmd.c

+ 6
- 3
src/hci/commands/image_cmd.c View File

45
  */
45
  */
46
 static int imgfill_cmdline ( struct image *image, unsigned int nargs, 
46
 static int imgfill_cmdline ( struct image *image, unsigned int nargs, 
47
 			     char **args ) {
47
 			     char **args ) {
48
-	size_t len;
48
+	size_t len = 0;
49
 	unsigned int i;
49
 	unsigned int i;
50
 
50
 
51
+	/* Clear command line if no arguments given */
52
+	if ( ! nargs )
53
+		return image_set_cmdline ( image, NULL );
54
+
51
 	/* Determine total length of command line */
55
 	/* Determine total length of command line */
52
-	len = 1; /* NUL */
53
 	for ( i = 0 ; i < nargs ; i++ )
56
 	for ( i = 0 ; i < nargs ; i++ )
54
-		len += ( 1 /* possible space */ + strlen ( args[i] ) );
57
+		len += ( strlen ( args[i] ) + 1 /* space or NUL */ );
55
 
58
 
56
 	{
59
 	{
57
 		char buf[len];
60
 		char buf[len];

Loading…
Cancel
Save