Patchwork cbfstool default type for add command.

login
register
about
Submitter Kevin O'Connor
Date 2010-09-06 13:49:14
Message ID <20100906134914.GA8531@morn.localdomain>
Download mbox | patch
Permalink /patch/1869/
State New
Headers show

Comments

Kevin O'Connor - 2010-09-06 13:49:14
The "raw" type is a good default for the "add" command.  Allow the
user to add files without specifying a type ("raw" will be assumed).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
---
 util/cbfstool/cbfstool.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

Patch

diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index 7c22a65..311a3e8 100644
--- a/util/cbfstool/cbfstool.c
+++ b/util/cbfstool/cbfstool.c
@@ -70,15 +70,13 @@  static int cbfs_add(int argc, char **argv)
 	uint32_t base = 0;
 	void *cbfsfile = NULL;
 
-	if (argc < 6) {
-		printf("not enough arguments to 'add'.\n");
-		return 1;
+	uint32_t type = CBFS_COMPONENT_RAW;
+	if (argc > 5) {
+		if (intfiletype(argv[5]) != ((uint64_t) - 1))
+			type = intfiletype(argv[5]);
+		else
+			type = strtoul(argv[5], NULL, 0);
 	}
-	uint32_t type;
-	if (intfiletype(argv[5]) != ((uint64_t) - 1))
-		type = intfiletype(argv[5]);
-	else
-		type = strtoul(argv[5], NULL, 0);
 	if (argc > 6) {
 		base = strtoul(argv[6], NULL, 0);
 	}
@@ -332,7 +330,7 @@  void usage(void)
 	     " cbfstool FILE COMMAND [PARAMETERS]...\n\n" "OPTIONs:\n"
 	     "  -h		Display this help message\n\n"
 	     "COMMANDs:\n"
-	     " add FILE NAME TYPE [base address]    Add a component\n"
+	     " add FILE NAME [TYPE] [base address]  Add a component\n"
 	     " add-payload FILE NAME [COMP] [base]  Add a payload to the ROM\n"
 	     " add-stage FILE NAME [COMP] [base]    Add a stage to the ROM\n"
 	     " add-lzma FILE NAME [TYPE] [base]     Lzma compress and add\n"