[PATCH 01/12] scripts/kwbimage: add a new function image_count_options()

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Tue May 14 18:32:14 EDT 2013


This function returns the number of configuration elements that match
a given type. Will be used to do some sanity checking of the number of
options.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
---
 scripts/kwbimage.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/scripts/kwbimage.c b/scripts/kwbimage.c
index 14b35e7..0d5dcac 100644
--- a/scripts/kwbimage.c
+++ b/scripts/kwbimage.c
@@ -259,6 +259,20 @@ image_find_option(struct image_cfg_element *image_cfg,
 	return NULL;
 }
 
+static unsigned int
+image_count_options(struct image_cfg_element *image_cfg,
+		    int cfgn, unsigned int optiontype)
+{
+	int i;
+	unsigned int count = 0;
+
+	for (i = 0; i < cfgn; i++)
+		if (image_cfg[i].type == optiontype)
+			count++;
+
+	return count;
+}
+
 /*
  * Compute a 8-bit checksum of a memory area. This algorithm follows
  * the requirements of the Marvell SoC BootROM specifications.
-- 
1.7.9.5




More information about the barebox mailing list