Browse Source

[settings] Eliminate call to storef_named_setting() in choose_exec()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
7010b10491
1 changed files with 12 additions and 5 deletions
  1. 12
    5
      src/hci/commands/menu_cmd.c

+ 12
- 5
src/hci/commands/menu_cmd.c View File

228
  */
228
  */
229
 static int choose_exec ( int argc, char **argv ) {
229
 static int choose_exec ( int argc, char **argv ) {
230
 	struct choose_options opts;
230
 	struct choose_options opts;
231
+	struct named_setting setting;
231
 	struct menu *menu;
232
 	struct menu *menu;
232
 	struct menu_item *item;
233
 	struct menu_item *item;
233
-	const char *setting;
234
 	int rc;
234
 	int rc;
235
 
235
 
236
 	/* Parse options */
236
 	/* Parse options */
238
 		goto err_parse_options;
238
 		goto err_parse_options;
239
 
239
 
240
 	/* Parse setting name */
240
 	/* Parse setting name */
241
-	setting = argv[optind];
241
+	if ( ( rc = parse_autovivified_setting ( argv[optind],
242
+						 &setting ) ) != 0 )
243
+		goto err_parse_setting;
242
 
244
 
243
 	/* Identify menu */
245
 	/* Identify menu */
244
 	if ( ( rc = parse_menu ( opts.menu, &menu ) ) != 0 )
246
 	if ( ( rc = parse_menu ( opts.menu, &menu ) ) != 0 )
248
 	if ( ( rc = show_menu ( menu, opts.timeout, opts.select, &item ) ) != 0)
250
 	if ( ( rc = show_menu ( menu, opts.timeout, opts.select, &item ) ) != 0)
249
 		goto err_show_menu;
251
 		goto err_show_menu;
250
 
252
 
253
+	/* Apply default type if necessary */
254
+	if ( ! setting.setting.type )
255
+		setting.setting.type = &setting_type_string;
256
+
251
 	/* Store setting */
257
 	/* Store setting */
252
-	if ( ( rc = storef_named_setting ( setting, &setting_type_string,
253
-					   item->label ) ) != 0 ) {
258
+	if ( ( rc = storef_setting ( setting.settings, &setting.setting,
259
+				     item->label ) ) != 0 ) {
254
 		printf ( "Could not store \"%s\": %s\n",
260
 		printf ( "Could not store \"%s\": %s\n",
255
-			 setting, strerror ( rc ) );
261
+			 setting.setting.name, strerror ( rc ) );
256
 		goto err_store;
262
 		goto err_store;
257
 	}
263
 	}
258
 
264
 
265
 	if ( ! opts.keep )
271
 	if ( ! opts.keep )
266
 		destroy_menu ( menu );
272
 		destroy_menu ( menu );
267
  err_parse_menu:
273
  err_parse_menu:
274
+ err_parse_setting:
268
  err_parse_options:
275
  err_parse_options:
269
 	return rc;
276
 	return rc;
270
 }
277
 }

Loading…
Cancel
Save