diff options
author | Rob Herring <robh@kernel.org> | 2018-11-28 19:37:35 -0500 |
---|---|---|
committer | Rob Herring <robh@kernel.org> | 2018-11-28 19:37:35 -0500 |
commit | c2e7075ca83036317cee4a564729eb82a5433169 (patch) | |
tree | 3172d34d5620eaa9066c0934410b4eeb33d37269 /scripts/dtc/util.c | |
parent | e8b1dee21420f871e300d46342f2c98a2e08158d (diff) |
scripts/dtc: Update to upstream version v1.4.7-57-gf267e674d145
This adds the following commits from upstream:
f267e674d145 checks: Fix crash with multiple source annotations
3616b9a811b6 checks: Use source position information for check failures
2bdbd07a1223 checks: Make each message output atomic
a1eff70c02cf util: Add xa{v}sprintf_append functions
82a52ce4573b libfdt: Add a test for fdt_getprop_by_offset()
607b8586b383 PEP8 / Flake8 cleanups for setup.py
f9c0a425b648 Remove broken objdir / srcdir support
5182b5e6f28c pylibfdt: Use common PREFIX variable
d45bf1f5f2a6 Refine make tests_clean target
99284c4db9cb Refine pylibfdt_clean target
a4629cfaedfb Refine libfdt_clean target
08380fc43aa2 tests: Use modern octal literals for Python
8113c00b99d3 pylibfdt: Allow switch to Python 3 via environment variable PYTHON
11738cf01f15 libfdt: Don't use memcpy to handle unaligned reads on ARM
86a288a73670 checks: Restructure check_msg to decrease indentation
5667e7ef9a9a annotations: add the annotation functionality
8e20ccf52f90 annotations: add positions
ca930e20bb54 tests: Don't lose errors from make checkm
43366bb4eeee tests: Property count valgrind errors in wrapped tests
5062516fb8cb srcpos: Remove srcpos_empty
a3143fafbf83 Revert "annotations: add positions"
403cc79f06a1 checks: Update SPI bus check for 'spi-slave'
baa1d2cf7894 annotations: add positions
ff2ad38f6a5a Merge remote-tracking branch 'origin/pr/18'
aa7254d9cb17 libfdt: return correct value if #size-cells property is not present
49903aed7783 use ptrdiff_t modifier for printing pointer differences
da2b691ccf68 treesource: Fix dts output for phandles in middle of a sequence of ints
8f8b77a0d62d tests: Wrap check_align() calls with base_run_test()
522d81d572f2 Fix dts output with a REF_PATH marker
e45198c98359 Added test cases for target references
0fcffda15e9f Merge nodes with local target label references
1e4a0928f3b3 pylibfdt: Don't have setup.py depend on where it's invoked from
ca399b14956f pylibfdt: Eliminate run_setup make function
98972f1b3e33 pylibfdt: Improved version extraction
7ba2be6cda5f pylibfdt: Don't silence setup.py when V=1
7691f9d39301 pylibfdt: Make SETUP make variable
855b9963def9 pylibfdt: Simpler CFLAGS handling
47cafbeeb977 pylibfdt: Link extension module with libfdt rather than rebuilding
dd695d6afb19 pylibfdt: Correctly set build output directory
59327523d0d8 pylibfdt: We don't need include files from the base directory
e84742aa7b93 checks: fix simple-bus compatible matching
8c59a97ce096 Fix missing labels when emitting dts format
d448f9a5fd94 Revert dts output formatting changes of spaces around brackets
Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'scripts/dtc/util.c')
-rw-r--r-- | scripts/dtc/util.c | 60 |
1 files changed, 39 insertions, 21 deletions
diff --git a/scripts/dtc/util.c b/scripts/dtc/util.c index a69b7a13463d..9c6fb5f286ae 100644 --- a/scripts/dtc/util.c +++ b/scripts/dtc/util.c | |||
@@ -46,36 +46,54 @@ char *xstrdup(const char *s) | |||
46 | return d; | 46 | return d; |
47 | } | 47 | } |
48 | 48 | ||
49 | /* based in part from (3) vsnprintf */ | 49 | int xavsprintf_append(char **strp, const char *fmt, va_list ap) |
50 | int xasprintf(char **strp, const char *fmt, ...) | ||
51 | { | 50 | { |
52 | int n, size = 128; /* start with 128 bytes */ | 51 | int n, size = 0; /* start with 128 bytes */ |
53 | char *p; | 52 | char *p; |
54 | va_list ap; | 53 | va_list ap_copy; |
55 | 54 | ||
56 | /* initial pointer is NULL making the fist realloc to be malloc */ | 55 | p = *strp; |
57 | p = NULL; | 56 | if (p) |
58 | while (1) { | 57 | size = strlen(p); |
59 | p = xrealloc(p, size); | ||
60 | 58 | ||
61 | /* Try to print in the allocated space. */ | 59 | va_copy(ap_copy, ap); |
62 | va_start(ap, fmt); | 60 | n = vsnprintf(NULL, 0, fmt, ap_copy) + 1; |
63 | n = vsnprintf(p, size, fmt, ap); | 61 | va_end(ap_copy); |
64 | va_end(ap); | 62 | |
63 | p = xrealloc(p, size + n); | ||
64 | |||
65 | n = vsnprintf(p + size, n, fmt, ap); | ||
65 | 66 | ||
66 | /* If that worked, return the string. */ | ||
67 | if (n > -1 && n < size) | ||
68 | break; | ||
69 | /* Else try again with more space. */ | ||
70 | if (n > -1) /* glibc 2.1 */ | ||
71 | size = n + 1; /* precisely what is needed */ | ||
72 | else /* glibc 2.0 */ | ||
73 | size *= 2; /* twice the old size */ | ||
74 | } | ||
75 | *strp = p; | 67 | *strp = p; |
76 | return strlen(p); | 68 | return strlen(p); |
77 | } | 69 | } |
78 | 70 | ||
71 | int xasprintf_append(char **strp, const char *fmt, ...) | ||
72 | { | ||
73 | int n; | ||
74 | va_list ap; | ||
75 | |||
76 | va_start(ap, fmt); | ||
77 | n = xavsprintf_append(strp, fmt, ap); | ||
78 | va_end(ap); | ||
79 | |||
80 | return n; | ||
81 | } | ||
82 | |||
83 | int xasprintf(char **strp, const char *fmt, ...) | ||
84 | { | ||
85 | int n; | ||
86 | va_list ap; | ||
87 | |||
88 | *strp = NULL; | ||
89 | |||
90 | va_start(ap, fmt); | ||
91 | n = xavsprintf_append(strp, fmt, ap); | ||
92 | va_end(ap); | ||
93 | |||
94 | return n; | ||
95 | } | ||
96 | |||
79 | char *join_path(const char *path, const char *name) | 97 | char *join_path(const char *path, const char *name) |
80 | { | 98 | { |
81 | int lenp = strlen(path); | 99 | int lenp = strlen(path); |