Commit b416803e authored by NiteHawk's avatar NiteHawk
Browse files

Merge pull request #49 from n1tehawk/20160518_fexc-fixes

fexc fixes
parents aff86a5e 7a0a7012
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "list.h" #include "list.h"
#define GPIO_BANK_MAX 13 /* N */ #define GPIO_BANK_MAX 14 /* N, (zero-based) index 13 */
/** head of the data tree */ /** head of the data tree */
struct script { struct script {
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "common.h" #include "common.h"
#include <ctype.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
...@@ -240,6 +241,13 @@ static int decompile_section(void *bin, size_t bin_size, ...@@ -240,6 +241,13 @@ static int decompile_section(void *bin, size_t bin_size,
type = (entry->pattern >> 16) & 0xffff; type = (entry->pattern >> 16) & 0xffff;
words = (entry->pattern >> 0) & 0xffff; words = (entry->pattern >> 0) & 0xffff;
for (char *p = entry->name; *p; p++)
if (!(isalnum(*p) || *p == '_')) {
pr_info("Warning: Malformed entry key \"%s\"\n",
entry->name);
break;
}
switch(type) { switch(type) {
case SCRIPT_VALUE_TYPE_SINGLE_WORD: { case SCRIPT_VALUE_TYPE_SINGLE_WORD: {
uint32_t *v = data; uint32_t *v = data;
...@@ -269,9 +277,12 @@ static int decompile_section(void *bin, size_t bin_size, ...@@ -269,9 +277,12 @@ static int decompile_section(void *bin, size_t bin_size,
} else if (gpio->port == 0xffff) { } else if (gpio->port == 0xffff) {
; /* port:power */ ; /* port:power */
} else if (gpio->port < 1 || gpio->port > GPIO_BANK_MAX) { } else if (gpio->port < 1 || gpio->port > GPIO_BANK_MAX) {
pr_err("%s: %s.%s: unknown GPIO port bank %c (%u)\n", pr_err("%s: %s.%s: unknown GPIO port bank ",
filename, section->name, entry->name, filename, section->name, entry->name);
'A'+gpio->port, gpio->port); char c = 'A' + gpio->port - 1;
if (c >= 'A' && c <= 'Z')
pr_err("%c ", c);
pr_err("(%u)\n", gpio->port);
goto failure; goto failure;
} }
v[0] = gpio->mul_sel; v[0] = gpio->mul_sel;
...@@ -315,7 +326,7 @@ int script_decompile_bin(void *bin, size_t bin_size, ...@@ -315,7 +326,7 @@ int script_decompile_bin(void *bin, size_t bin_size,
unsigned int i; unsigned int i;
struct script_bin_head *head = bin; struct script_bin_head *head = bin;
if ((head->version[0] > SCRIPT_BIN_VERSION_LIMIT) || if (((head->version[0] & 0x3FFF) > SCRIPT_BIN_VERSION_LIMIT) ||
(head->version[1] > SCRIPT_BIN_VERSION_LIMIT) || (head->version[1] > SCRIPT_BIN_VERSION_LIMIT) ||
(head->version[2] > SCRIPT_BIN_VERSION_LIMIT)) { (head->version[2] > SCRIPT_BIN_VERSION_LIMIT)) {
pr_err("Malformed data: version %u.%u.%u.\n", pr_err("Malformed data: version %u.%u.%u.\n",
...@@ -330,7 +341,7 @@ int script_decompile_bin(void *bin, size_t bin_size, ...@@ -330,7 +341,7 @@ int script_decompile_bin(void *bin, size_t bin_size,
} }
pr_info("%s: version: %u.%u.%u\n", filename, pr_info("%s: version: %u.%u.%u\n", filename,
head->version[0], head->version[1], head->version[2]); head->version[0] & 0x3FFF, head->version[1], head->version[2]);
pr_info("%s: size: %zu (%u sections)\n", filename, pr_info("%s: size: %zu (%u sections)\n", filename,
bin_size, head->sections); bin_size, head->sections);
......
...@@ -202,7 +202,13 @@ int script_parse_fex(FILE *in, const char *filename, struct script *script) ...@@ -202,7 +202,13 @@ int script_parse_fex(FILE *in, const char *filename, struct script *script)
if (pe == s || *s == ';' || *s == '#') if (pe == s || *s == ';' || *s == '#')
continue; /* empty */ continue; /* empty */
else if (*s == '[') { if (*s == ':') {
/* see https://github.com/linux-sunxi/sunxi-boards/issues/50 */
errf("Warning: %s:%zu: invalid line, suspecting typo/malformed comment.\n",
filename, line);
continue; /* ignore this line */
}
if (*s == '[') {
/* section */ /* section */
char *p = ++s; char *p = ++s;
while (isalnum(*p) || *p == '_') while (isalnum(*p) || *p == '_')
...@@ -344,6 +350,8 @@ int script_parse_fex(FILE *in, const char *filename, struct script *script) ...@@ -344,6 +350,8 @@ int script_parse_fex(FILE *in, const char *filename, struct script *script)
} else { } else {
goto invalid_char_at_p; goto invalid_char_at_p;
} }
errf("E: %s:%zu: parse error at %zu.\n",
filename, line, p-buffer+1);
goto parse_error; goto parse_error;
invalid_char_at_p: invalid_char_at_p:
errf("E: %s:%zu: invalid character at %zu.\n", errf("E: %s:%zu: invalid character at %zu.\n",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment