Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Rob Herring <robh@kernel.org>

+84 -32
+5
scripts/dtc/checks.c
··· 691 691 return; 692 692 693 693 for_each_property(node, prop) { 694 + if (streq(prop->name, "phandle") 695 + || streq(prop->name, "linux,phandle")) { 696 + continue; 697 + } 698 + 694 699 if (!prop->val.val || !get_node_by_path(dti->dt, prop->val.val)) { 695 700 FAIL_PROP(c, dti, node, prop, "aliases property is not a valid node (%s)", 696 701 prop->val.val);
+4
scripts/dtc/dtc-parser.y
··· 2 2 /* 3 3 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. 4 4 */ 5 + %locations 6 + 5 7 %{ 6 8 #include <stdio.h> 7 9 #include <inttypes.h> ··· 18 16 srcpos_error((loc), "Error", __VA_ARGS__); \ 19 17 treesource_error = true; \ 20 18 } while (0) 19 + 20 + #define YYERROR_CALL(msg) yyerror(msg) 21 21 22 22 extern struct dt_info *parser_output; 23 23 extern bool treesource_error;
+1 -1
scripts/dtc/fstree.c
··· 30 30 31 31 tmpname = join_path(dirname, de->d_name); 32 32 33 - if (lstat(tmpname, &st) < 0) 33 + if (stat(tmpname, &st) < 0) 34 34 die("stat(%s): %s\n", tmpname, strerror(errno)); 35 35 36 36 if (S_ISREG(st.st_mode)) {
+7 -2
scripts/dtc/libfdt/fdt.c
··· 15 15 * that the given buffer contains what appears to be a flattened 16 16 * device tree with sane information in its header. 17 17 */ 18 - int fdt_ro_probe_(const void *fdt) 18 + int32_t fdt_ro_probe_(const void *fdt) 19 19 { 20 + uint32_t totalsize = fdt_totalsize(fdt); 21 + 20 22 if (fdt_magic(fdt) == FDT_MAGIC) { 21 23 /* Complete tree */ 22 24 if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION) ··· 33 31 return -FDT_ERR_BADMAGIC; 34 32 } 35 33 36 - return 0; 34 + if (totalsize < INT32_MAX) 35 + return totalsize; 36 + else 37 + return -FDT_ERR_TRUNCATED; 37 38 } 38 39 39 40 static int check_off_(uint32_t hdrsize, uint32_t totalsize, uint32_t off)
+5 -3
scripts/dtc/libfdt/fdt_addresses.c
··· 14 14 static int fdt_cells(const void *fdt, int nodeoffset, const char *name) 15 15 { 16 16 const fdt32_t *c; 17 - int val; 17 + uint32_t val; 18 18 int len; 19 19 20 20 c = fdt_getprop(fdt, nodeoffset, name, &len); ··· 25 25 return -FDT_ERR_BADNCELLS; 26 26 27 27 val = fdt32_to_cpu(*c); 28 - if ((val <= 0) || (val > FDT_MAX_NCELLS)) 28 + if (val > FDT_MAX_NCELLS) 29 29 return -FDT_ERR_BADNCELLS; 30 30 31 - return val; 31 + return (int)val; 32 32 } 33 33 34 34 int fdt_address_cells(const void *fdt, int nodeoffset) ··· 36 36 int val; 37 37 38 38 val = fdt_cells(fdt, nodeoffset, "#address-cells"); 39 + if (val == 0) 40 + return -FDT_ERR_BADNCELLS; 39 41 if (val == -FDT_ERR_NOTFOUND) 40 42 return 2; 41 43 return val;
+19 -9
scripts/dtc/libfdt/fdt_overlay.c
··· 733 733 /* keep end marker to avoid strlen() */ 734 734 e = path + path_len; 735 735 736 - /* format: /<fragment-name>/__overlay__/<relative-subnode-path> */ 737 - 738 736 if (*path != '/') 739 737 return -FDT_ERR_BADVALUE; 740 738 741 739 /* get fragment name first */ 742 740 s = strchr(path + 1, '/'); 743 - if (!s) 744 - return -FDT_ERR_BADOVERLAY; 741 + if (!s) { 742 + /* Symbol refers to something that won't end 743 + * up in the target tree */ 744 + continue; 745 + } 745 746 746 747 frag_name = path + 1; 747 748 frag_name_len = s - path - 1; 748 749 749 750 /* verify format; safe since "s" lies in \0 terminated prop */ 750 751 len = sizeof("/__overlay__/") - 1; 751 - if ((e - s) < len || memcmp(s, "/__overlay__/", len)) 752 - return -FDT_ERR_BADOVERLAY; 753 - 754 - rel_path = s + len; 755 - rel_path_len = e - rel_path; 752 + if ((e - s) > len && (memcmp(s, "/__overlay__/", len) == 0)) { 753 + /* /<fragment-name>/__overlay__/<relative-subnode-path> */ 754 + rel_path = s + len; 755 + rel_path_len = e - rel_path - 1; 756 + } else if ((e - s) == len 757 + && (memcmp(s, "/__overlay__", len - 1) == 0)) { 758 + /* /<fragment-name>/__overlay__ */ 759 + rel_path = ""; 760 + rel_path_len = 0; 761 + } else { 762 + /* Symbol refers to something that won't end 763 + * up in the target tree */ 764 + continue; 765 + } 756 766 757 767 /* find the fragment index in which the symbol lies */ 758 768 ret = fdt_subnode_offset_namelen(fdto, 0, frag_name,
+6 -5
scripts/dtc/libfdt/fdt_ro.c
··· 33 33 34 34 const char *fdt_get_string(const void *fdt, int stroffset, int *lenp) 35 35 { 36 + int32_t totalsize = fdt_ro_probe_(fdt); 36 37 uint32_t absoffset = stroffset + fdt_off_dt_strings(fdt); 37 38 size_t len; 38 39 int err; 39 40 const char *s, *n; 40 41 41 - err = fdt_ro_probe_(fdt); 42 - if (err != 0) 42 + err = totalsize; 43 + if (totalsize < 0) 43 44 goto fail; 44 45 45 46 err = -FDT_ERR_BADOFFSET; 46 - if (absoffset >= fdt_totalsize(fdt)) 47 + if (absoffset >= totalsize) 47 48 goto fail; 48 - len = fdt_totalsize(fdt) - absoffset; 49 + len = totalsize - absoffset; 49 50 50 51 if (fdt_magic(fdt) == FDT_MAGIC) { 51 52 if (stroffset < 0) ··· 289 288 const char *nameptr; 290 289 int err; 291 290 292 - if (((err = fdt_ro_probe_(fdt)) != 0) 291 + if (((err = fdt_ro_probe_(fdt)) < 0) 293 292 || ((err = fdt_check_node_offset_(fdt, nodeoffset)) < 0)) 294 293 goto fail; 295 294
+2 -2
scripts/dtc/libfdt/libfdt.h
··· 136 136 137 137 static inline void fdt32_st(void *property, uint32_t value) 138 138 { 139 - uint8_t *bp = property; 139 + uint8_t *bp = (uint8_t *)property; 140 140 141 141 bp[0] = value >> 24; 142 142 bp[1] = (value >> 16) & 0xff; ··· 160 160 161 161 static inline void fdt64_st(void *property, uint64_t value) 162 162 { 163 - uint8_t *bp = property; 163 + uint8_t *bp = (uint8_t *)property; 164 164 165 165 bp[0] = value >> 56; 166 166 bp[1] = (value >> 48) & 0xff;
+6 -6
scripts/dtc/libfdt/libfdt_internal.h
··· 10 10 #define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) 11 11 #define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE)) 12 12 13 - int fdt_ro_probe_(const void *fdt); 14 - #define FDT_RO_PROBE(fdt) \ 15 - { \ 16 - int err_; \ 17 - if ((err_ = fdt_ro_probe_(fdt)) != 0) \ 18 - return err_; \ 13 + int32_t fdt_ro_probe_(const void *fdt); 14 + #define FDT_RO_PROBE(fdt) \ 15 + { \ 16 + int32_t totalsize_; \ 17 + if ((totalsize_ = fdt_ro_probe_(fdt)) < 0) \ 18 + return totalsize_; \ 19 19 } 20 20 21 21 int fdt_check_node_offset_(const void *fdt, int offset);
+1 -2
scripts/dtc/livetree.c
··· 526 526 p = strchr(path, '/'); 527 527 528 528 for_each_child(tree, child) { 529 - if (p && (strlen(child->name) == p-path) && 530 - strprefixeq(path, p - path, child->name)) 529 + if (p && strprefixeq(path, p - path, child->name)) 531 530 return get_node_by_path(child, p+1); 532 531 else if (!p && streq(path, child->name)) 533 532 return child;
+2 -1
scripts/dtc/util.c
··· 13 13 #include <stdarg.h> 14 14 #include <string.h> 15 15 #include <assert.h> 16 + #include <inttypes.h> 16 17 17 18 #include <errno.h> 18 19 #include <fcntl.h> ··· 394 393 395 394 printf(" = <"); 396 395 for (i = 0, len /= 4; i < len; i++) 397 - printf("0x%08x%s", fdt32_to_cpu(cell[i]), 396 + printf("0x%08" PRIx32 "%s", fdt32_to_cpu(cell[i]), 398 397 i < (len - 1) ? " " : ""); 399 398 printf(">"); 400 399 } else {
+4
scripts/dtc/util.h
··· 12 12 */ 13 13 14 14 #ifdef __GNUC__ 15 + #ifdef __clang__ 15 16 #define PRINTF(i, j) __attribute__((format (printf, i, j))) 17 + #else 18 + #define PRINTF(i, j) __attribute__((format (gnu_printf, i, j))) 19 + #endif 16 20 #define NORETURN __attribute__((noreturn)) 17 21 #else 18 22 #define PRINTF(i, j)
+1 -1
scripts/dtc/version_gen.h
··· 1 - #define DTC_VERSION "DTC 1.5.0-g702c1b6c" 1 + #define DTC_VERSION "DTC 1.5.0-gc40aeb60"
+21
scripts/dtc/yamltree.c
··· 138 138 (yaml_char_t *)YAML_SEQ_TAG, 1, YAML_FLOW_SEQUENCE_STYLE); 139 139 yaml_emitter_emit_or_die(emitter, &event); 140 140 141 + /* Ensure we have a type marker before any phandle */ 142 + for_each_marker(m) { 143 + int last_offset = 0; 144 + struct marker *type_m; 145 + 146 + if (m->type >= TYPE_UINT8) 147 + last_offset = m->offset; 148 + 149 + if (!(m->next && m->next->type == REF_PHANDLE && 150 + last_offset < m->next->offset)) 151 + continue; 152 + 153 + type_m = xmalloc(sizeof(*type_m)); 154 + type_m->offset = m->next->offset; 155 + type_m->type = TYPE_UINT32; 156 + type_m->ref = NULL; 157 + type_m->next = m->next; 158 + m->next = type_m; 159 + } 160 + 161 + m = prop->val.markers; 141 162 for_each_marker(m) { 142 163 int chunk_len; 143 164 char *data = &prop->val.val[m->offset];