Commit 0cec114e authored by Rob Herring's avatar Rob Herring

scripts/dtc: Update to upstream version v1.5.1-22-gc40aeb60b47a

This adds the following commits from upstream:

c40aeb60b47a travis.yml: Run tests on the non-x86 builders, too
9f86aff444f4 Add .cirrus.yml for FreeBSD build
34c82275bae6 Avoid gnu_printf attribute when using Clang
743000931bc9 tests: default to 'cc' if CC not set
adcd676491cc Add test-case for trailing zero
d9c55f855b65 Remove trailing zero from the overlay path
7a22132c79ec pylibfdt: Adjust for deprecated test methods
dbe80d577ee2 tests: add extension to sed -i for GNU/BSD sed compatibility
af57d440d887 libfdt: Correct prototype for fdt_ro_probe_()
6ce585ac153b Use correct inttypes.h format specifier
715028622547 support byacc in addition to bison
fdf3f6d897ab pylibfdt: Correct the type for fdt_property_stub()
430419c28100 tests: fix some python warnings
588a29ff2e4e util: use gnu_printf format attribute
bc876708ab1d fstree: replace lstat with stat
4c3c4ccb9916 dumptrees: pass outputdir as first argument
aa522da9fff6 tests: allow out-of-tree test run
0d0d0fa51b1f fdtoverlay: Return non-zero exit code if overlays can't be applied
4605eb047b38 Add .editorconfig
18d7b2f4ee45 yamltree: Ensure consistent bracketing of properties with phandles
67f790c1adcc libfdt.h: add explicit cast from void* to uint8_t* in fdt(32|64)_st
b111122ea5eb pylibfdt: use python3 shebang
60e0db3d65a1 Ignore phandle properties in /aliases
95ce19c14064 README: update for Python 3
5345db19f615 livetree: simplify condition in get_node_by_path
b8d6eca78210 libfdt: Allow #size-cells of 0
184f51099471 Makefile: Add EXTRA_CFLAGS variable
812b1956a076 libfdt: Tweak data handling to satisfy Coverity
5c715a44776a fdtoverlay: Ignore symbols in overlays which don't apply to the target tree
b99353474850 fdtoverlay: Allow adding labels to __overlay__ nodes in overlays
d6de81b81b68 pylibfdt: Add support for fdt_get_alias()
1c17714dbb3a pylibfdt: Correct the FdtSw example
ad57e4574a37 tests: Add a failed test case for 'fdtoverlay' with long target path
bbe3b36f542b fdtoverlay: Rework output allocation
6c2e61f08396 fdtoverlay: Improve error messages
297f5abb362e fdtoverlay: Check for truncated overlay blobs

Cc: Frank Rowand <frowand.list@gmail.com>
Cc: clang-built-linux@googlegroups.com
Signed-off-by: default avatarRob Herring <robh@kernel.org>
parent 6ffdc742
...@@ -691,6 +691,11 @@ static void check_alias_paths(struct check *c, struct dt_info *dti, ...@@ -691,6 +691,11 @@ static void check_alias_paths(struct check *c, struct dt_info *dti,
return; return;
for_each_property(node, prop) { for_each_property(node, prop) {
if (streq(prop->name, "phandle")
|| streq(prop->name, "linux,phandle")) {
continue;
}
if (!prop->val.val || !get_node_by_path(dti->dt, prop->val.val)) { if (!prop->val.val || !get_node_by_path(dti->dt, prop->val.val)) {
FAIL_PROP(c, dti, node, prop, "aliases property is not a valid node (%s)", FAIL_PROP(c, dti, node, prop, "aliases property is not a valid node (%s)",
prop->val.val); prop->val.val);
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
/* /*
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
*/ */
%locations
%{ %{
#include <stdio.h> #include <stdio.h>
#include <inttypes.h> #include <inttypes.h>
...@@ -17,6 +19,8 @@ extern void yyerror(char const *s); ...@@ -17,6 +19,8 @@ extern void yyerror(char const *s);
treesource_error = true; \ treesource_error = true; \
} while (0) } while (0)
#define YYERROR_CALL(msg) yyerror(msg)
extern struct dt_info *parser_output; extern struct dt_info *parser_output;
extern bool treesource_error; extern bool treesource_error;
%} %}
......
...@@ -30,7 +30,7 @@ static struct node *read_fstree(const char *dirname) ...@@ -30,7 +30,7 @@ static struct node *read_fstree(const char *dirname)
tmpname = join_path(dirname, de->d_name); tmpname = join_path(dirname, de->d_name);
if (lstat(tmpname, &st) < 0) if (stat(tmpname, &st) < 0)
die("stat(%s): %s\n", tmpname, strerror(errno)); die("stat(%s): %s\n", tmpname, strerror(errno));
if (S_ISREG(st.st_mode)) { if (S_ISREG(st.st_mode)) {
......
...@@ -15,8 +15,10 @@ ...@@ -15,8 +15,10 @@
* that the given buffer contains what appears to be a flattened * that the given buffer contains what appears to be a flattened
* device tree with sane information in its header. * device tree with sane information in its header.
*/ */
int fdt_ro_probe_(const void *fdt) int32_t fdt_ro_probe_(const void *fdt)
{ {
uint32_t totalsize = fdt_totalsize(fdt);
if (fdt_magic(fdt) == FDT_MAGIC) { if (fdt_magic(fdt) == FDT_MAGIC) {
/* Complete tree */ /* Complete tree */
if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION) if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION)
...@@ -31,7 +33,10 @@ int fdt_ro_probe_(const void *fdt) ...@@ -31,7 +33,10 @@ int fdt_ro_probe_(const void *fdt)
return -FDT_ERR_BADMAGIC; return -FDT_ERR_BADMAGIC;
} }
return 0; if (totalsize < INT32_MAX)
return totalsize;
else
return -FDT_ERR_TRUNCATED;
} }
static int check_off_(uint32_t hdrsize, uint32_t totalsize, uint32_t off) static int check_off_(uint32_t hdrsize, uint32_t totalsize, uint32_t off)
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
static int fdt_cells(const void *fdt, int nodeoffset, const char *name) static int fdt_cells(const void *fdt, int nodeoffset, const char *name)
{ {
const fdt32_t *c; const fdt32_t *c;
int val; uint32_t val;
int len; int len;
c = fdt_getprop(fdt, nodeoffset, name, &len); c = fdt_getprop(fdt, nodeoffset, name, &len);
...@@ -25,10 +25,10 @@ static int fdt_cells(const void *fdt, int nodeoffset, const char *name) ...@@ -25,10 +25,10 @@ static int fdt_cells(const void *fdt, int nodeoffset, const char *name)
return -FDT_ERR_BADNCELLS; return -FDT_ERR_BADNCELLS;
val = fdt32_to_cpu(*c); val = fdt32_to_cpu(*c);
if ((val <= 0) || (val > FDT_MAX_NCELLS)) if (val > FDT_MAX_NCELLS)
return -FDT_ERR_BADNCELLS; return -FDT_ERR_BADNCELLS;
return val; return (int)val;
} }
int fdt_address_cells(const void *fdt, int nodeoffset) int fdt_address_cells(const void *fdt, int nodeoffset)
...@@ -36,6 +36,8 @@ int fdt_address_cells(const void *fdt, int nodeoffset) ...@@ -36,6 +36,8 @@ int fdt_address_cells(const void *fdt, int nodeoffset)
int val; int val;
val = fdt_cells(fdt, nodeoffset, "#address-cells"); val = fdt_cells(fdt, nodeoffset, "#address-cells");
if (val == 0)
return -FDT_ERR_BADNCELLS;
if (val == -FDT_ERR_NOTFOUND) if (val == -FDT_ERR_NOTFOUND)
return 2; return 2;
return val; return val;
......
...@@ -733,26 +733,36 @@ static int overlay_symbol_update(void *fdt, void *fdto) ...@@ -733,26 +733,36 @@ static int overlay_symbol_update(void *fdt, void *fdto)
/* keep end marker to avoid strlen() */ /* keep end marker to avoid strlen() */
e = path + path_len; e = path + path_len;
/* format: /<fragment-name>/__overlay__/<relative-subnode-path> */
if (*path != '/') if (*path != '/')
return -FDT_ERR_BADVALUE; return -FDT_ERR_BADVALUE;
/* get fragment name first */ /* get fragment name first */
s = strchr(path + 1, '/'); s = strchr(path + 1, '/');
if (!s) if (!s) {
return -FDT_ERR_BADOVERLAY; /* Symbol refers to something that won't end
* up in the target tree */
continue;
}
frag_name = path + 1; frag_name = path + 1;
frag_name_len = s - path - 1; frag_name_len = s - path - 1;
/* verify format; safe since "s" lies in \0 terminated prop */ /* verify format; safe since "s" lies in \0 terminated prop */
len = sizeof("/__overlay__/") - 1; len = sizeof("/__overlay__/") - 1;
if ((e - s) < len || memcmp(s, "/__overlay__/", len)) if ((e - s) > len && (memcmp(s, "/__overlay__/", len) == 0)) {
return -FDT_ERR_BADOVERLAY; /* /<fragment-name>/__overlay__/<relative-subnode-path> */
rel_path = s + len; rel_path = s + len;
rel_path_len = e - rel_path; rel_path_len = e - rel_path - 1;
} else if ((e - s) == len
&& (memcmp(s, "/__overlay__", len - 1) == 0)) {
/* /<fragment-name>/__overlay__ */
rel_path = "";
rel_path_len = 0;
} else {
/* Symbol refers to something that won't end
* up in the target tree */
continue;
}
/* find the fragment index in which the symbol lies */ /* find the fragment index in which the symbol lies */
ret = fdt_subnode_offset_namelen(fdto, 0, frag_name, ret = fdt_subnode_offset_namelen(fdto, 0, frag_name,
......
...@@ -33,19 +33,20 @@ static int fdt_nodename_eq_(const void *fdt, int offset, ...@@ -33,19 +33,20 @@ static int fdt_nodename_eq_(const void *fdt, int offset,
const char *fdt_get_string(const void *fdt, int stroffset, int *lenp) const char *fdt_get_string(const void *fdt, int stroffset, int *lenp)
{ {
int32_t totalsize = fdt_ro_probe_(fdt);
uint32_t absoffset = stroffset + fdt_off_dt_strings(fdt); uint32_t absoffset = stroffset + fdt_off_dt_strings(fdt);
size_t len; size_t len;
int err; int err;
const char *s, *n; const char *s, *n;
err = fdt_ro_probe_(fdt); err = totalsize;
if (err != 0) if (totalsize < 0)
goto fail; goto fail;
err = -FDT_ERR_BADOFFSET; err = -FDT_ERR_BADOFFSET;
if (absoffset >= fdt_totalsize(fdt)) if (absoffset >= totalsize)
goto fail; goto fail;
len = fdt_totalsize(fdt) - absoffset; len = totalsize - absoffset;
if (fdt_magic(fdt) == FDT_MAGIC) { if (fdt_magic(fdt) == FDT_MAGIC) {
if (stroffset < 0) if (stroffset < 0)
...@@ -288,7 +289,7 @@ const char *fdt_get_name(const void *fdt, int nodeoffset, int *len) ...@@ -288,7 +289,7 @@ const char *fdt_get_name(const void *fdt, int nodeoffset, int *len)
const char *nameptr; const char *nameptr;
int err; int err;
if (((err = fdt_ro_probe_(fdt)) != 0) if (((err = fdt_ro_probe_(fdt)) < 0)
|| ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0)) || ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0))
goto fail; goto fail;
......
...@@ -136,7 +136,7 @@ static inline uint32_t fdt32_ld(const fdt32_t *p) ...@@ -136,7 +136,7 @@ static inline uint32_t fdt32_ld(const fdt32_t *p)
static inline void fdt32_st(void *property, uint32_t value) static inline void fdt32_st(void *property, uint32_t value)
{ {
uint8_t *bp = property; uint8_t *bp = (uint8_t *)property;
bp[0] = value >> 24; bp[0] = value >> 24;
bp[1] = (value >> 16) & 0xff; bp[1] = (value >> 16) & 0xff;
...@@ -160,7 +160,7 @@ static inline uint64_t fdt64_ld(const fdt64_t *p) ...@@ -160,7 +160,7 @@ static inline uint64_t fdt64_ld(const fdt64_t *p)
static inline void fdt64_st(void *property, uint64_t value) static inline void fdt64_st(void *property, uint64_t value)
{ {
uint8_t *bp = property; uint8_t *bp = (uint8_t *)property;
bp[0] = value >> 56; bp[0] = value >> 56;
bp[1] = (value >> 48) & 0xff; bp[1] = (value >> 48) & 0xff;
......
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
#define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) #define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
#define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE)) #define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))
int fdt_ro_probe_(const void *fdt); int32_t fdt_ro_probe_(const void *fdt);
#define FDT_RO_PROBE(fdt) \ #define FDT_RO_PROBE(fdt) \
{ \ { \
int err_; \ int32_t totalsize_; \
if ((err_ = fdt_ro_probe_(fdt)) != 0) \ if ((totalsize_ = fdt_ro_probe_(fdt)) < 0) \
return err_; \ return totalsize_; \
} }
int fdt_check_node_offset_(const void *fdt, int offset); int fdt_check_node_offset_(const void *fdt, int offset);
......
...@@ -526,8 +526,7 @@ struct node *get_node_by_path(struct node *tree, const char *path) ...@@ -526,8 +526,7 @@ struct node *get_node_by_path(struct node *tree, const char *path)
p = strchr(path, '/'); p = strchr(path, '/');
for_each_child(tree, child) { for_each_child(tree, child) {
if (p && (strlen(child->name) == p-path) && if (p && strprefixeq(path, p - path, child->name))
strprefixeq(path, p - path, child->name))
return get_node_by_path(child, p+1); return get_node_by_path(child, p+1);
else if (!p && streq(path, child->name)) else if (!p && streq(path, child->name))
return child; return child;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <inttypes.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
...@@ -393,7 +394,7 @@ void utilfdt_print_data(const char *data, int len) ...@@ -393,7 +394,7 @@ void utilfdt_print_data(const char *data, int len)
printf(" = <"); printf(" = <");
for (i = 0, len /= 4; i < len; i++) for (i = 0, len /= 4; i < len; i++)
printf("0x%08x%s", fdt32_to_cpu(cell[i]), printf("0x%08" PRIx32 "%s", fdt32_to_cpu(cell[i]),
i < (len - 1) ? " " : ""); i < (len - 1) ? " " : "");
printf(">"); printf(">");
} else { } else {
......
...@@ -12,7 +12,11 @@ ...@@ -12,7 +12,11 @@
*/ */
#ifdef __GNUC__ #ifdef __GNUC__
#ifdef __clang__
#define PRINTF(i, j) __attribute__((format (printf, i, j))) #define PRINTF(i, j) __attribute__((format (printf, i, j)))
#else
#define PRINTF(i, j) __attribute__((format (gnu_printf, i, j)))
#endif
#define NORETURN __attribute__((noreturn)) #define NORETURN __attribute__((noreturn))
#else #else
#define PRINTF(i, j) #define PRINTF(i, j)
......
#define DTC_VERSION "DTC 1.5.0-g702c1b6c" #define DTC_VERSION "DTC 1.5.0-gc40aeb60"
...@@ -138,6 +138,27 @@ static void yaml_propval(yaml_emitter_t *emitter, struct property *prop) ...@@ -138,6 +138,27 @@ static void yaml_propval(yaml_emitter_t *emitter, struct property *prop)
(yaml_char_t *)YAML_SEQ_TAG, 1, YAML_FLOW_SEQUENCE_STYLE); (yaml_char_t *)YAML_SEQ_TAG, 1, YAML_FLOW_SEQUENCE_STYLE);
yaml_emitter_emit_or_die(emitter, &event); yaml_emitter_emit_or_die(emitter, &event);
/* Ensure we have a type marker before any phandle */
for_each_marker(m) {
int last_offset = 0;
struct marker *type_m;
if (m->type >= TYPE_UINT8)
last_offset = m->offset;
if (!(m->next && m->next->type == REF_PHANDLE &&
last_offset < m->next->offset))
continue;
type_m = xmalloc(sizeof(*type_m));
type_m->offset = m->next->offset;
type_m->type = TYPE_UINT32;
type_m->ref = NULL;
type_m->next = m->next;
m->next = type_m;
}
m = prop->val.markers;
for_each_marker(m) { for_each_marker(m) {
int chunk_len; int chunk_len;
char *data = &prop->val.val[m->offset]; char *data = &prop->val.val[m->offset];
......
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