summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2005-11-11 00:50:01 +0000
committerMarcel Holtmann <marcel@holtmann.org>2005-11-11 00:50:01 +0000
commit1a31ffaa3c1bca7a26448069bf2aa5007ae7f826 (patch)
tree65e987fc254f8626bdddc21919b504e2f6ba6f52
parenta61c4d6cd0882acb8d76f9a59f7847d7027ff539 (diff)
Fix PSR parsing on big endian
-rw-r--r--tools/csr.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/tools/csr.c b/tools/csr.c
index 10856749..b28289a5 100644
--- a/tools/csr.c
+++ b/tools/csr.c
@@ -2685,20 +2685,25 @@ static int parse_line(char *str)
{
uint8_t array[256];
uint16_t value, pskey, length = 0;
- char *tmp, *end;
+ char *off, *end;
pskey = strtol(str + 1, NULL, 16);
- tmp = strstr(str, "=") + 1;
+ off = strstr(str, "=") + 1;
+ if (!off)
+ return -EIO;
while (1) {
- value = strtol(tmp, &end, 16);
- if (value == 0 && tmp == end)
+ value = strtol(off, &end, 16);
+ if (value == 0 && off == end)
break;
array[length++] = value & 0xff;
array[length++] = value >> 8;
- tmp = end + 1;
+ if (*end == '\0')
+ break;
+
+ off = end + 1;
}
return psr_put(pskey, array, length);
@@ -2728,6 +2733,11 @@ int psr_read(const char *filename)
off = map;
while (1) {
+ if (*off == '\r' || *off == '\n') {
+ off++;
+ continue;
+ }
+
end = strpbrk(off, "\r\n");
if (!end)
break;