Browse Source

Fix assorted sparse warnings

This fixes a great many sparse warnings on the fdt and libfdt sources.
These are mostly due to incorrect mixing of endian annotated and native
integer types.

This includes fixing a couple of quasi-bugs where we had endian conversions
the wrong way around (this will have the right effect in practice, but is
certainly conceptually incorrect).

This doesn't make the whole tree sparse clean: there are many warnings in
bison and lex generated code, and there are a handful of other remaining
warnings that are (for now) more trouble than they're worth to fix (and
are not genuine bugs).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
main
David Gibson 8 years ago
parent
commit
bad5b28049
  1. 4
      checks.c
  2. 2
      convert-dtsv0-lexer.l
  3. 6
      data.c
  4. 5
      dtc.c
  5. 2
      fdtdump.c
  6. 2
      fdtget.c
  7. 2
      fdtput.c
  8. 23
      flattree.c
  9. 21
      libfdt/fdt_overlay.c
  10. 4
      livetree.c
  11. 2
      tests/char_literal.c
  12. 2
      tests/dtbs_equal_ordered.c
  13. 10
      tests/dtbs_equal_unordered.c
  14. 2
      tests/dumptrees.c
  15. 4
      tests/integer-expressions.c
  16. 2
      tests/node_offset_by_prop_value.c
  17. 2
      tests/nopulate.c
  18. 4
      tests/property_iterate.c
  19. 4
      tests/references.c
  20. 6
      tests/sized_cells.c
  21. 4
      tests/subnode_iterate.c
  22. 6
      tests/tests.h
  23. 6
      tests/value-labels.c
  24. 2
      treesource.c
  25. 9
      util.c

4
checks.c

@ -534,13 +534,13 @@ static void fixup_phandle_references(struct check *c, struct dt_info *dti,
FAIL(c, dti, "Reference to non-existent node or " FAIL(c, dti, "Reference to non-existent node or "
"label \"%s\"\n", m->ref); "label \"%s\"\n", m->ref);
else /* mark the entry as unresolved */ else /* mark the entry as unresolved */
*((cell_t *)(prop->val.val + m->offset)) = *((fdt32_t *)(prop->val.val + m->offset)) =
cpu_to_fdt32(0xffffffff); cpu_to_fdt32(0xffffffff);
continue; continue;
} }


phandle = get_node_phandle(dt, refnode); phandle = get_node_phandle(dt, refnode);
*((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle); *((fdt32_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle);
} }
} }
} }

2
convert-dtsv0-lexer.l

@ -49,7 +49,7 @@ static int saw_hyphen; /* = 0 */
static unsigned long long last_val; static unsigned long long last_val;
static char *last_name; /* = NULL */ static char *last_name; /* = NULL */


const struct { static const struct {
const char *pattern; const char *pattern;
int obase, width; int obase, width;
} guess_table[] = { } guess_table[] = {

6
data.c

@ -171,9 +171,9 @@ struct data data_merge(struct data d1, struct data d2)
struct data data_append_integer(struct data d, uint64_t value, int bits) struct data data_append_integer(struct data d, uint64_t value, int bits)
{ {
uint8_t value_8; uint8_t value_8;
uint16_t value_16; fdt16_t value_16;
uint32_t value_32; fdt32_t value_32;
uint64_t value_64; fdt64_t value_64;


switch (bits) { switch (bits) {
case 8: case 8:

5
dtc.c

@ -138,7 +138,7 @@ static const char *guess_type_by_name(const char *fname, const char *fallback)
static const char *guess_input_format(const char *fname, const char *fallback) static const char *guess_input_format(const char *fname, const char *fallback)
{ {
struct stat statbuf; struct stat statbuf;
uint32_t magic; fdt32_t magic;
FILE *f; FILE *f;


if (stat(fname, &statbuf) != 0) if (stat(fname, &statbuf) != 0)
@ -159,8 +159,7 @@ static const char *guess_input_format(const char *fname, const char *fallback)
} }
fclose(f); fclose(f);


magic = fdt32_to_cpu(magic); if (fdt32_to_cpu(magic) == FDT_MAGIC)
if (magic == FDT_MAGIC)
return "dtb"; return "dtb";


return guess_type_by_name(fname, fallback); return guess_type_by_name(fname, fallback);

2
fdtdump.c

@ -20,7 +20,7 @@


#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) #define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a)))) #define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a))))
#define GET_CELL(p) (p += 4, *((const uint32_t *)(p-4))) #define GET_CELL(p) (p += 4, *((const fdt32_t *)(p-4)))


static const char *tagname(uint32_t tag) static const char *tagname(uint32_t tag)
{ {

2
fdtget.c

@ -105,7 +105,7 @@ static int show_data(struct display_info *disp, const char *data, int len)
for (i = 0; i < len; i += size, p += size) { for (i = 0; i < len; i += size, p += size) {
if (i) if (i)
printf(" "); printf(" ");
value = size == 4 ? fdt32_to_cpu(*(const uint32_t *)p) : value = size == 4 ? fdt32_to_cpu(*(const fdt32_t *)p) :
size == 2 ? (*p << 8) | p[1] : *p; size == 2 ? (*p << 8) | p[1] : *p;
printf(fmt, value); printf(fmt, value);
} }

2
fdtput.c

@ -107,7 +107,7 @@ static int encode_value(struct display_info *disp, char **arg, int arg_count,
if (disp->verbose) if (disp->verbose)
fprintf(stderr, "\tstring: '%s'\n", ptr); fprintf(stderr, "\tstring: '%s'\n", ptr);
} else { } else {
int *iptr = (int *)ptr; fdt32_t *iptr = (fdt32_t *)ptr;
sscanf(*arg, fmt, &ival); sscanf(*arg, fmt, &ival);
if (len == 4) if (len == 4)
*iptr = cpu_to_fdt32(ival); *iptr = cpu_to_fdt32(ival);

23
flattree.c

@ -179,7 +179,7 @@ static void asm_emit_data(void *e, struct data d)
emit_offset_label(f, m->ref, m->offset); emit_offset_label(f, m->ref, m->offset);


while ((d.len - off) >= sizeof(uint32_t)) { while ((d.len - off) >= sizeof(uint32_t)) {
asm_emit_cell(e, fdt32_to_cpu(*((uint32_t *)(d.val+off)))); asm_emit_cell(e, fdt32_to_cpu(*((fdt32_t *)(d.val+off))));
off += sizeof(uint32_t); off += sizeof(uint32_t);
} }


@ -608,7 +608,7 @@ static void flat_read_chunk(struct inbuf *inb, void *p, int len)


static uint32_t flat_read_word(struct inbuf *inb) static uint32_t flat_read_word(struct inbuf *inb)
{ {
uint32_t val; fdt32_t val;


assert(((inb->ptr - inb->base) % sizeof(val)) == 0); assert(((inb->ptr - inb->base) % sizeof(val)) == 0);


@ -717,13 +717,15 @@ static struct reserve_info *flat_read_mem_reserve(struct inbuf *inb)
* First pass, count entries. * First pass, count entries.
*/ */
while (1) { while (1) {
uint64_t address, size;

flat_read_chunk(inb, &re, sizeof(re)); flat_read_chunk(inb, &re, sizeof(re));
re.address = fdt64_to_cpu(re.address); address = fdt64_to_cpu(re.address);
re.size = fdt64_to_cpu(re.size); size = fdt64_to_cpu(re.size);
if (re.size == 0) if (size == 0)
break; break;


new = build_reserve_entry(re.address, re.size); new = build_reserve_entry(address, size);
reservelist = add_reserve_entry(reservelist, new); reservelist = add_reserve_entry(reservelist, new);
} }


@ -816,6 +818,7 @@ static struct node *unflatten_tree(struct inbuf *dtbuf,
struct dt_info *dt_from_blob(const char *fname) struct dt_info *dt_from_blob(const char *fname)
{ {
FILE *f; FILE *f;
fdt32_t magic_buf, totalsize_buf;
uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys; uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys;
uint32_t off_dt, off_str, off_mem_rsvmap; uint32_t off_dt, off_str, off_mem_rsvmap;
int rc; int rc;
@ -832,7 +835,7 @@ struct dt_info *dt_from_blob(const char *fname)


f = srcfile_relative_open(fname, NULL); f = srcfile_relative_open(fname, NULL);


rc = fread(&magic, sizeof(magic), 1, f); rc = fread(&magic_buf, sizeof(magic_buf), 1, f);
if (ferror(f)) if (ferror(f))
die("Error reading DT blob magic number: %s\n", die("Error reading DT blob magic number: %s\n",
strerror(errno)); strerror(errno));
@ -843,11 +846,11 @@ struct dt_info *dt_from_blob(const char *fname)
die("Mysterious short read reading magic number\n"); die("Mysterious short read reading magic number\n");
} }


magic = fdt32_to_cpu(magic); magic = fdt32_to_cpu(magic_buf);
if (magic != FDT_MAGIC) if (magic != FDT_MAGIC)
die("Blob has incorrect magic number\n"); die("Blob has incorrect magic number\n");


rc = fread(&totalsize, sizeof(totalsize), 1, f); rc = fread(&totalsize_buf, sizeof(totalsize_buf), 1, f);
if (ferror(f)) if (ferror(f))
die("Error reading DT blob size: %s\n", strerror(errno)); die("Error reading DT blob size: %s\n", strerror(errno));
if (rc < 1) { if (rc < 1) {
@ -857,7 +860,7 @@ struct dt_info *dt_from_blob(const char *fname)
die("Mysterious short read reading blob size\n"); die("Mysterious short read reading blob size\n");
} }


totalsize = fdt32_to_cpu(totalsize); totalsize = fdt32_to_cpu(totalsize_buf);
if (totalsize < FDT_V1_SIZE) if (totalsize < FDT_V1_SIZE)
die("DT blob size (%d) is too small\n", totalsize); die("DT blob size (%d) is too small\n", totalsize);



21
libfdt/fdt_overlay.c

@ -21,14 +21,14 @@
*/ */
static uint32_t overlay_get_target_phandle(const void *fdto, int fragment) static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
{ {
const uint32_t *val; const fdt32_t *val;
int len; int len;


val = fdt_getprop(fdto, fragment, "target", &len); val = fdt_getprop(fdto, fragment, "target", &len);
if (!val) if (!val)
return 0; return 0;


if ((len != sizeof(*val)) || (*val == (uint32_t)-1)) if ((len != sizeof(*val)) || (fdt32_to_cpu(*val) == (uint32_t)-1))
return (uint32_t)-1; return (uint32_t)-1;


return fdt32_to_cpu(*val); return fdt32_to_cpu(*val);
@ -99,7 +99,7 @@ static int overlay_get_target(const void *fdt, const void *fdto,
static int overlay_phandle_add_offset(void *fdt, int node, static int overlay_phandle_add_offset(void *fdt, int node,
const char *name, uint32_t delta) const char *name, uint32_t delta)
{ {
const uint32_t *val; const fdt32_t *val;
uint32_t adj_val; uint32_t adj_val;
int len; int len;


@ -210,7 +210,7 @@ static int overlay_update_local_node_references(void *fdto,
int ret; int ret;


fdt_for_each_property_offset(fixup_prop, fdto, fixup_node) { fdt_for_each_property_offset(fixup_prop, fdto, fixup_node) {
const uint32_t *fixup_val; const fdt32_t *fixup_val;
const char *tree_val; const char *tree_val;
const char *name; const char *name;
int fixup_len; int fixup_len;
@ -234,7 +234,8 @@ static int overlay_update_local_node_references(void *fdto,
} }


for (i = 0; i < (fixup_len / sizeof(uint32_t)); i++) { for (i = 0; i < (fixup_len / sizeof(uint32_t)); i++) {
uint32_t adj_val, poffset; fdt32_t adj_val;
uint32_t poffset;


poffset = fdt32_to_cpu(fixup_val[i]); poffset = fdt32_to_cpu(fixup_val[i]);


@ -246,9 +247,7 @@ static int overlay_update_local_node_references(void *fdto,
*/ */
memcpy(&adj_val, tree_val + poffset, sizeof(adj_val)); memcpy(&adj_val, tree_val + poffset, sizeof(adj_val));


adj_val = fdt32_to_cpu(adj_val); adj_val = cpu_to_fdt32(fdt32_to_cpu(adj_val) + delta);
adj_val += delta;
adj_val = cpu_to_fdt32(adj_val);


ret = fdt_setprop_inplace_namelen_partial(fdto, ret = fdt_setprop_inplace_namelen_partial(fdto,
tree_node, tree_node,
@ -356,6 +355,7 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
{ {
const char *symbol_path; const char *symbol_path;
uint32_t phandle; uint32_t phandle;
fdt32_t phandle_prop;
int symbol_off, fixup_off; int symbol_off, fixup_off;
int prop_len; int prop_len;


@ -381,10 +381,11 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
if (fixup_off < 0) if (fixup_off < 0)
return fixup_off; return fixup_off;


phandle = cpu_to_fdt32(phandle); phandle_prop = cpu_to_fdt32(phandle);
return fdt_setprop_inplace_namelen_partial(fdto, fixup_off, return fdt_setprop_inplace_namelen_partial(fdto, fixup_off,
name, name_len, poffset, name, name_len, poffset,
&phandle, sizeof(phandle)); &phandle_prop,
sizeof(phandle_prop));
}; };


/** /**

4
livetree.c

@ -393,7 +393,7 @@ struct property *get_property(struct node *node, const char *propname)
cell_t propval_cell(struct property *prop) cell_t propval_cell(struct property *prop)
{ {
assert(prop->val.len == sizeof(cell_t)); assert(prop->val.len == sizeof(cell_t));
return fdt32_to_cpu(*((cell_t *)prop->val.val)); return fdt32_to_cpu(*((fdt32_t *)prop->val.val));
} }


struct property *get_property_by_label(struct node *tree, const char *label, struct property *get_property_by_label(struct node *tree, const char *label,
@ -902,7 +902,7 @@ static void add_local_fixup_entry(struct dt_info *dti,
struct node *refnode) struct node *refnode)
{ {
struct node *wn, *nwn; /* local fixup node, walk node, new */ struct node *wn, *nwn; /* local fixup node, walk node, new */
uint32_t value_32; fdt32_t value_32;
char **compp; char **compp;
int i, depth; int i, depth;



2
tests/char_literal.c

@ -31,7 +31,7 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
void *fdt; void *fdt;
uint32_t expected_cells[5]; fdt32_t expected_cells[5];


expected_cells[0] = cpu_to_fdt32((unsigned char)TEST_CHAR1); expected_cells[0] = cpu_to_fdt32((unsigned char)TEST_CHAR1);
expected_cells[1] = cpu_to_fdt32((unsigned char)TEST_CHAR2); expected_cells[1] = cpu_to_fdt32((unsigned char)TEST_CHAR2);

2
tests/dtbs_equal_ordered.c

@ -28,7 +28,7 @@
#include "tests.h" #include "tests.h"
#include "testdata.h" #include "testdata.h"


int notequal; /* = 0 */ static int notequal; /* = 0 */


#define MISMATCH(fmt, ...) \ #define MISMATCH(fmt, ...) \
do { \ do { \

10
tests/dtbs_equal_unordered.c

@ -29,7 +29,7 @@
#include "tests.h" #include "tests.h"
#include "testdata.h" #include "testdata.h"


int notequal; /* = 0 */ static int notequal; /* = 0 */


#define MISMATCH(fmt, ...) \ #define MISMATCH(fmt, ...) \
do { \ do { \
@ -59,14 +59,14 @@ static int mem_rsv_cmp(const void *p1, const void *p2)
const struct fdt_reserve_entry *re1 = p1; const struct fdt_reserve_entry *re1 = p1;
const struct fdt_reserve_entry *re2 = p2; const struct fdt_reserve_entry *re2 = p2;


if (re1->address < re2->address) if (fdt64_to_cpu(re1->address) < fdt64_to_cpu(re2->address))
return -1; return -1;
else if (re1->address > re2->address) else if (fdt64_to_cpu(re1->address) > fdt64_to_cpu(re2->address))
return 1; return 1;


if (re1->size < re2->size) if (fdt64_to_cpu(re1->size) < fdt64_to_cpu(re2->size))
return -1; return -1;
else if (re1->size > re2->size) else if (fdt64_to_cpu(re1->size) > fdt64_to_cpu(re2->size))
return 1; return 1;


return 0; return 0;

2
tests/dumptrees.c

@ -29,7 +29,7 @@


#include "testdata.h" #include "testdata.h"


struct { static struct {
void *blob; void *blob;
const char *filename; const char *filename;
} trees[] = { } trees[] = {

4
tests/integer-expressions.c

@ -30,7 +30,7 @@
#include "tests.h" #include "tests.h"
#include "testdata.h" #include "testdata.h"


struct test_expr { static struct test_expr {
const char *expr; const char *expr;
uint32_t result; uint32_t result;
} expr_table[] = { } expr_table[] = {
@ -70,7 +70,7 @@ struct test_expr {
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
void *fdt; void *fdt;
const uint32_t *res; const fdt32_t *res;
int reslen; int reslen;
int i; int i;



2
tests/node_offset_by_prop_value.c

@ -69,7 +69,7 @@ static void check_search_str(void *fdt, const char *propname,


#define check_search_cell(fdt, propname, propval, ...) \ #define check_search_cell(fdt, propname, propval, ...) \
{ \ { \
uint32_t val = cpu_to_fdt32(propval); \ fdt32_t val = cpu_to_fdt32(propval); \
check_search((fdt), (propname), &val, sizeof(val), \ check_search((fdt), (propname), &val, sizeof(val), \
##__VA_ARGS__); \ ##__VA_ARGS__); \
} }

2
tests/nopulate.c

@ -45,7 +45,7 @@ static int nopulate_struct(char *buf, const char *fdt)
nextoffset - offset); nextoffset - offset);
p += nextoffset - offset; p += nextoffset - offset;


*((uint32_t *)p) = cpu_to_fdt32(FDT_NOP); *((fdt32_t *)p) = cpu_to_fdt32(FDT_NOP);
p += FDT_TAGSIZE; p += FDT_TAGSIZE;


} while (tag != FDT_END); } while (tag != FDT_END);

4
tests/property_iterate.c

@ -33,7 +33,7 @@


static void test_node(void *fdt, int parent_offset) static void test_node(void *fdt, int parent_offset)
{ {
fdt32_t properties; uint32_t properties;
const fdt32_t *prop; const fdt32_t *prop;
int offset, property; int offset, property;
int count; int count;
@ -48,7 +48,7 @@ static void test_node(void *fdt, int parent_offset)
FAIL("Missing/invalid test-properties property at '%s'", FAIL("Missing/invalid test-properties property at '%s'",
fdt_get_name(fdt, parent_offset, NULL)); fdt_get_name(fdt, parent_offset, NULL));
} }
properties = cpu_to_fdt32(*prop); properties = fdt32_to_cpu(*prop);


count = 0; count = 0;
offset = fdt_first_subnode(fdt, parent_offset); offset = fdt_first_subnode(fdt, parent_offset);

4
tests/references.c

@ -29,7 +29,7 @@


static void check_ref(const void *fdt, int node, uint32_t checkref) static void check_ref(const void *fdt, int node, uint32_t checkref)
{ {
const uint32_t *p; const fdt32_t *p;
uint32_t ref; uint32_t ref;
int len; int len;


@ -58,7 +58,7 @@ static void check_ref(const void *fdt, int node, uint32_t checkref)


static void check_rref(const void *fdt) static void check_rref(const void *fdt)
{ {
const uint32_t *p; const fdt32_t *p;
uint32_t ref; uint32_t ref;
int len; int len;



6
tests/sized_cells.c

@ -54,9 +54,9 @@ int main(int argc, char *argv[])
TEST_CHAR4, TEST_CHAR4,
TEST_CHAR5, TEST_CHAR5,
TEST_VALUE_1 >> 24}; TEST_VALUE_1 >> 24};
uint16_t expected_16[6]; fdt16_t expected_16[6];
uint32_t expected_32[6]; fdt32_t expected_32[6];
uint64_t expected_64[6]; fdt64_t expected_64[6];
int i; int i;


for (i = 0; i < 5; ++i) { for (i = 0; i < 5; ++i) {

4
tests/subnode_iterate.c

@ -33,7 +33,7 @@


static void test_node(void *fdt, int parent_offset) static void test_node(void *fdt, int parent_offset)
{ {
fdt32_t subnodes; uint32_t subnodes;
const fdt32_t *prop; const fdt32_t *prop;
int offset; int offset;
int count; int count;
@ -45,7 +45,7 @@ static void test_node(void *fdt, int parent_offset)
FAIL("Missing/invalid subnodes property at '%s'", FAIL("Missing/invalid subnodes property at '%s'",
fdt_get_name(fdt, parent_offset, NULL)); fdt_get_name(fdt, parent_offset, NULL));
} }
subnodes = cpu_to_fdt32(*prop); subnodes = fdt32_to_cpu(*prop);


count = 0; count = 0;
fdt_for_each_subnode(offset, fdt, parent_offset) fdt_for_each_subnode(offset, fdt, parent_offset)

6
tests/tests.h

@ -99,7 +99,7 @@ void check_property(void *fdt, int nodeoffset, const char *name,
int len, const void *val); int len, const void *val);
#define check_property_cell(fdt, nodeoffset, name, val) \ #define check_property_cell(fdt, nodeoffset, name, val) \
({ \ ({ \
uint32_t x = cpu_to_fdt32(val); \ fdt32_t x = cpu_to_fdt32(val); \
check_property(fdt, nodeoffset, name, sizeof(x), &x); \ check_property(fdt, nodeoffset, name, sizeof(x), &x); \
}) })


@ -108,12 +108,12 @@ const void *check_getprop(void *fdt, int nodeoffset, const char *name,
int len, const void *val); int len, const void *val);
#define check_getprop_cell(fdt, nodeoffset, name, val) \ #define check_getprop_cell(fdt, nodeoffset, name, val) \
({ \ ({ \
uint32_t x = cpu_to_fdt32(val); \ fdt32_t x = cpu_to_fdt32(val); \
check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \ check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \
}) })
#define check_getprop_64(fdt, nodeoffset, name, val) \ #define check_getprop_64(fdt, nodeoffset, name, val) \
({ \ ({ \
uint64_t x = cpu_to_fdt64(val); \ fdt64_t x = cpu_to_fdt64(val); \
check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \ check_getprop(fdt, nodeoffset, name, sizeof(x), &x); \
}) })
#define check_getprop_string(fdt, nodeoffset, name, s) \ #define check_getprop_string(fdt, nodeoffset, name, s) \

6
tests/value-labels.c

@ -36,13 +36,13 @@ struct val_label {
int propoff; int propoff;
}; };


struct val_label labels1[] = { static struct val_label labels1[] = {
{ "start1", 0 }, { "start1", 0 },
{ "mid1", 2 }, { "mid1", 2 },
{ "end1", -1 }, { "end1", -1 },
}; };


struct val_label labels2[] = { static struct val_label labels2[] = {
{ "start2", 0 }, { "start2", 0 },
{ "innerstart2", 0 }, { "innerstart2", 0 },
{ "innermid2", 4 }, { "innermid2", 4 },
@ -50,7 +50,7 @@ struct val_label labels2[] = {
{ "end2", -1 }, { "end2", -1 },
}; };


struct val_label labels3[] = { static struct val_label labels3[] = {
{ "start3", 0 }, { "start3", 0 },
{ "innerstart3", 0 }, { "innerstart3", 0 },
{ "innermid3", 1 }, { "innermid3", 1 },

2
treesource.c

@ -137,7 +137,7 @@ static void write_propval_string(FILE *f, struct data val)
static void write_propval_cells(FILE *f, struct data val) static void write_propval_cells(FILE *f, struct data val)
{ {
void *propend = val.val + val.len; void *propend = val.val + val.len;
cell_t *cp = (cell_t *)val.val; fdt32_t *cp = (fdt32_t *)val.val;
struct marker *m = val.markers; struct marker *m = val.markers;


fprintf(f, "<"); fprintf(f, "<");

9
util.c

@ -396,7 +396,7 @@ void utilfdt_print_data(const char *data, int len)
} while (s < data + len); } while (s < data + len);


} else if ((len % 4) == 0) { } else if ((len % 4) == 0) {
const uint32_t *cell = (const uint32_t *)data; const fdt32_t *cell = (const fdt32_t *)data;


printf(" = <"); printf(" = <");
for (i = 0, len /= 4; i < len; i++) for (i = 0, len /= 4; i < len; i++)
@ -412,14 +412,15 @@ void utilfdt_print_data(const char *data, int len)
} }
} }


void util_version(void) void NORETURN util_version(void)
{ {
printf("Version: %s\n", DTC_VERSION); printf("Version: %s\n", DTC_VERSION);
exit(0); exit(0);
} }


void util_usage(const char *errmsg, const char *synopsis, void NORETURN util_usage(const char *errmsg, const char *synopsis,
const char *short_opts, struct option const long_opts[], const char *short_opts,
struct option const long_opts[],
const char * const opts_help[]) const char * const opts_help[])
{ {
FILE *fp = errmsg ? stderr : stdout; FILE *fp = errmsg ? stderr : stdout;

Loading…
Cancel
Save