Skip to content

Commit

Permalink
scripts/dtc: Update to upstream version 9d3649bd3be245c9
Browse files Browse the repository at this point in the history
Sync dtc with upstream as of commit 9d3649bd3be2 (Add testcases for
fdt_path_offset_namelen()).

Signed-off-by: Rob Herring <[email protected]>
Cc: Grant Likely <[email protected]>
Cc: [email protected]
  • Loading branch information
robherring committed Apr 29, 2015
1 parent f1ec718 commit 4760597
Show file tree
Hide file tree
Showing 29 changed files with 1,745 additions and 1,535 deletions.
31 changes: 16 additions & 15 deletions scripts/dtc/checks.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct check {
void *data;
bool warn, error;
enum checkstatus status;
int inprogress;
bool inprogress;
int num_prereqs;
struct check **prereq;
};
Expand Down Expand Up @@ -113,6 +113,7 @@ static inline void check_msg(struct check *c, const char *fmt, ...)
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
}
va_end(ap);
}

#define FAIL(c, ...) \
Expand Down Expand Up @@ -141,21 +142,21 @@ static void check_nodes_props(struct check *c, struct node *dt, struct node *nod
check_nodes_props(c, dt, child);
}

static int run_check(struct check *c, struct node *dt)
static bool run_check(struct check *c, struct node *dt)
{
int error = 0;
bool error = false;
int i;

assert(!c->inprogress);

if (c->status != UNCHECKED)
goto out;

c->inprogress = 1;
c->inprogress = true;

for (i = 0; i < c->num_prereqs; i++) {
struct check *prq = c->prereq[i];
error |= run_check(prq, dt);
error = error || run_check(prq, dt);
if (prq->status != PASSED) {
c->status = PREREQ;
check_msg(c, "Failed prerequisite '%s'",
Expand All @@ -177,9 +178,9 @@ static int run_check(struct check *c, struct node *dt)
TRACE(c, "\tCompleted, status %d", c->status);

out:
c->inprogress = 0;
c->inprogress = false;
if ((c->status != PASSED) && (c->error))
error = 1;
error = true;
return error;
}

Expand Down Expand Up @@ -624,11 +625,11 @@ static void check_avoid_default_addr_size(struct check *c, struct node *dt,
if (!reg && !ranges)
return;

if ((node->parent->addr_cells == -1))
if (node->parent->addr_cells == -1)
FAIL(c, "Relying on default #address-cells value for %s",
node->fullpath);

if ((node->parent->size_cells == -1))
if (node->parent->size_cells == -1)
FAIL(c, "Relying on default #size-cells value for %s",
node->fullpath);
}
Expand Down Expand Up @@ -706,15 +707,15 @@ static void disable_warning_error(struct check *c, bool warn, bool error)
c->error = c->error && !error;
}

void parse_checks_option(bool warn, bool error, const char *optarg)
void parse_checks_option(bool warn, bool error, const char *arg)
{
int i;
const char *name = optarg;
const char *name = arg;
bool enable = true;

if ((strncmp(optarg, "no-", 3) == 0)
|| (strncmp(optarg, "no_", 3) == 0)) {
name = optarg + 3;
if ((strncmp(arg, "no-", 3) == 0)
|| (strncmp(arg, "no_", 3) == 0)) {
name = arg + 3;
enable = false;
}

Expand All @@ -733,7 +734,7 @@ void parse_checks_option(bool warn, bool error, const char *optarg)
die("Unrecognized check name \"%s\"\n", name);
}

void process_checks(int force, struct boot_info *bi)
void process_checks(bool force, struct boot_info *bi)
{
struct node *dt = bi->dt;
int i;
Expand Down
12 changes: 6 additions & 6 deletions scripts/dtc/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct data data_copy_escape_string(const char *s, int len)
struct data d;
char *q;

d = data_grow_for(empty_data, strlen(s)+1);
d = data_grow_for(empty_data, len + 1);

q = d.val;
while (i < len) {
Expand Down Expand Up @@ -250,20 +250,20 @@ struct data data_add_marker(struct data d, enum markertype type, char *ref)
return data_append_markers(d, m);
}

int data_is_one_string(struct data d)
bool data_is_one_string(struct data d)
{
int i;
int len = d.len;

if (len == 0)
return 0;
return false;

for (i = 0; i < len-1; i++)
if (d.val[i] == '\0')
return 0;
return false;

if (d.val[len-1] != '\0')
return 0;
return false;

return 1;
return true;
}
65 changes: 52 additions & 13 deletions scripts/dtc/dtc-lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

%option noyywrap nounput noinput never-interactive

%x INCLUDE
%x BYTESTRING
%x PROPNODENAME
%s V1
Expand All @@ -40,6 +39,7 @@ LINECOMMENT "//".*\n
#include "dtc-parser.tab.h"

YYLTYPE yylloc;
extern bool treesource_error;

/* CAUTION: this will stop working if we ever use yyless() or yyunput() */
#define YY_USER_ACTION \
Expand All @@ -61,7 +61,8 @@ static int dts_version = 1;
BEGIN(V1); \

static void push_input_file(const char *filename);
static int pop_input_file(void);
static bool pop_input_file(void);
static void lexical_error(const char *fmt, ...);
%}

%%
Expand All @@ -75,11 +76,11 @@ static int pop_input_file(void);
char *line, *tmp, *fn;
/* skip text before line # */
line = yytext;
while (!isdigit(*line))
while (!isdigit((unsigned char)*line))
line++;
/* skip digits in line # */
tmp = line;
while (!isspace(*tmp))
while (!isspace((unsigned char)*tmp))
tmp++;
/* "NULL"-terminate line # */
*tmp = '\0';
Expand Down Expand Up @@ -146,15 +147,42 @@ static int pop_input_file(void);
}

<V1>([0-9]+|0[xX][0-9a-fA-F]+)(U|L|UL|LL|ULL)? {
yylval.literal = xstrdup(yytext);
DPRINT("Literal: '%s'\n", yylval.literal);
char *e;
DPRINT("Integer Literal: '%s'\n", yytext);

errno = 0;
yylval.integer = strtoull(yytext, &e, 0);

assert(!(*e) || !e[strspn(e, "UL")]);

if (errno == ERANGE)
lexical_error("Integer literal '%s' out of range",
yytext);
else
/* ERANGE is the only strtoull error triggerable
* by strings matching the pattern */
assert(errno == 0);
return DT_LITERAL;
}

<*>{CHAR_LITERAL} {
yytext[yyleng-1] = '\0';
yylval.literal = xstrdup(yytext+1);
DPRINT("Character literal: %s\n", yylval.literal);
struct data d;
DPRINT("Character literal: %s\n", yytext);

d = data_copy_escape_string(yytext+1, yyleng-2);
if (d.len == 1) {
lexical_error("Empty character literal");
yylval.integer = 0;
return DT_CHAR_LITERAL;
}

yylval.integer = (unsigned char)d.val[0];

if (d.len > 2)
lexical_error("Character literal has %d"
" characters instead of 1",
d.len - 1);

return DT_CHAR_LITERAL;
}

Expand All @@ -164,7 +192,7 @@ static int pop_input_file(void);
return DT_REF;
}

<*>"&{/"{PATHCHAR}+\} { /* new-style path reference */
<*>"&{/"{PATHCHAR}*\} { /* new-style path reference */
yytext[yyleng-1] = '\0';
DPRINT("Ref: %s\n", yytext+2);
yylval.labelref = xstrdup(yytext+2);
Expand Down Expand Up @@ -238,13 +266,24 @@ static void push_input_file(const char *filename)
}


static int pop_input_file(void)
static bool pop_input_file(void)
{
if (srcfile_pop() == 0)
return 0;
return false;

yypop_buffer_state();
yyin = current_srcfile->f;

return 1;
return true;
}

static void lexical_error(const char *fmt, ...)
{
va_list ap;

va_start(ap, fmt);
srcpos_verror(&yylloc, "Lexical error", fmt, ap);
va_end(ap);

treesource_error = true;
}
Loading

0 comments on commit 4760597

Please sign in to comment.