summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Haverkamp <haver@vnet.ibm.com>2006-12-11 14:34:23 +0100
committerFrank Haverkamp <haver@vnet.ibm.com>2006-12-11 14:34:23 +0100
commit084fb764956460b5e67865b6072ea9cc4a2b5af9 (patch)
treee0c8e152fc49f9b1530f7ce913ff405479f3dd4d
parent2798420f85492334c893554f5e69e9f92b4199ef (diff)
[MTD] UBI Utils: Fix wrong handling of table containing strings
-rw-r--r--ubi-utils/src/pfi.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/ubi-utils/src/pfi.c b/ubi-utils/src/pfi.c
index c8d5ee4..7b57559 100644
--- a/ubi-utils/src/pfi.c
+++ b/ubi-utils/src/pfi.c
@@ -113,7 +113,9 @@ static const int key_descriptors_max[] = {
sizeof(key_desc_v1)/sizeof(struct key_descriptor), /* version 1 */
};
-static const char* modes[] = {"raw", "ubi", NULL}; /* order isn't arbitrary! */
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
+static const char* modes[] = {"raw", "ubi"}; /* order isn't arbitrary! */
/* latest version contains all possible keys */
static const struct key_descriptor *key_desc = key_desc_v1;
@@ -131,16 +133,11 @@ static const struct key_descriptor *key_desc = key_desc_v1;
static int
get_mode_no(const char* mode)
{
- const char* ptr = modes[0];
- int i = 0;
- while (ptr != NULL) {
- if(strcmp(ptr, mode) == 0) {
- return i;
- }
- ptr++;
- i++;
- }
+ int i;
+ for (i = 0; i < (int)ARRAY_SIZE(modes); i++)
+ if (strcmp(mode, modes[i]) == 0)
+ return i;
return -1;
}