arm, am335x, siemens: fix factoryset interpretation
a record could contain other records, so after an ">" (begin mark) there not always come an end mark "<", instead a ">" is possible. Take care of this. Signed-off-by: Heiko Schocher <hs@denx.de>
This commit is contained in:
@@ -86,6 +86,7 @@ int get_factory_record_val(unsigned char *eeprom_buf, int size, uchar *record,
|
|||||||
int i, nxt = 0;
|
int i, nxt = 0;
|
||||||
int c;
|
int c;
|
||||||
unsigned char end = 0xff;
|
unsigned char end = 0xff;
|
||||||
|
unsigned char tmp;
|
||||||
|
|
||||||
for (i = 0; fact_get_char(i) != end; i = nxt) {
|
for (i = 0; fact_get_char(i) != end; i = nxt) {
|
||||||
nxt = i + 1;
|
nxt = i + 1;
|
||||||
@@ -93,6 +94,7 @@ int get_factory_record_val(unsigned char *eeprom_buf, int size, uchar *record,
|
|||||||
int pos;
|
int pos;
|
||||||
int endpos;
|
int endpos;
|
||||||
int z;
|
int z;
|
||||||
|
int level = 0;
|
||||||
|
|
||||||
c = strncmp((char *)&eeprom_buf[i + 1], (char *)record,
|
c = strncmp((char *)&eeprom_buf[i + 1], (char *)record,
|
||||||
strlen((char *)record));
|
strlen((char *)record));
|
||||||
@@ -103,22 +105,30 @@ int get_factory_record_val(unsigned char *eeprom_buf, int size, uchar *record,
|
|||||||
/* search for "<" */
|
/* search for "<" */
|
||||||
c = -1;
|
c = -1;
|
||||||
for (z = pos; fact_get_char(z) != end; z++) {
|
for (z = pos; fact_get_char(z) != end; z++) {
|
||||||
if ((fact_get_char(z) == '<') ||
|
if (fact_get_char(z) == '<') {
|
||||||
(fact_get_char(z) == '>')) {
|
if (level == 0) {
|
||||||
endpos = z;
|
endpos = z;
|
||||||
nxt = endpos;
|
nxt = endpos;
|
||||||
c = 0;
|
c = 0;
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
level--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (fact_get_char(z) == '>')
|
||||||
|
level++;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
/* end found -> call get_factory_val */
|
/* end found -> call get_factory_val */
|
||||||
|
tmp = eeprom_buf[endpos];
|
||||||
eeprom_buf[endpos] = end;
|
eeprom_buf[endpos] = end;
|
||||||
ret = get_factory_val(&eeprom_buf[pos],
|
ret = get_factory_val(&eeprom_buf[pos],
|
||||||
size - pos, name, buf, len);
|
endpos - pos, name, buf, len);
|
||||||
/* fix buffer */
|
/* fix buffer */
|
||||||
eeprom_buf[endpos] = '<';
|
eeprom_buf[endpos] = tmp;
|
||||||
debug("%s: %s.%s = %s\n",
|
debug("%s: %s.%s = %s\n",
|
||||||
__func__, record, name, buf);
|
__func__, record, name, buf);
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user