diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2017-03-06 12:08:53 +1100 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2017-03-06 12:08:53 +1100 |
commit | bad5b28049e5e0562a8ad91797fb77953a53fa20 (patch) | |
tree | d58515b0213f4d1ce2d4012dd19070dc629f5c3d /tests | |
parent | 672ac09ea04d998dfddfdef3070a8af8d480182b (diff) | |
download | dtc-bad5b28049e5e0562a8ad91797fb77953a53fa20.zip dtc-bad5b28049e5e0562a8ad91797fb77953a53fa20.tar.gz dtc-bad5b28049e5e0562a8ad91797fb77953a53fa20.tar.bz2 |
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>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/char_literal.c | 2 | ||||
-rw-r--r-- | tests/dtbs_equal_ordered.c | 2 | ||||
-rw-r--r-- | tests/dtbs_equal_unordered.c | 10 | ||||
-rw-r--r-- | tests/dumptrees.c | 2 | ||||
-rw-r--r-- | tests/integer-expressions.c | 4 | ||||
-rw-r--r-- | tests/node_offset_by_prop_value.c | 2 | ||||
-rw-r--r-- | tests/nopulate.c | 2 | ||||
-rw-r--r-- | tests/property_iterate.c | 4 | ||||
-rw-r--r-- | tests/references.c | 4 | ||||
-rw-r--r-- | tests/sized_cells.c | 6 | ||||
-rw-r--r-- | tests/subnode_iterate.c | 4 | ||||
-rw-r--r-- | tests/tests.h | 6 | ||||
-rw-r--r-- | tests/value-labels.c | 6 |
13 files changed, 27 insertions, 27 deletions
diff --git a/tests/char_literal.c b/tests/char_literal.c index d7a4773..da1f964 100644 --- a/tests/char_literal.c +++ b/tests/char_literal.c @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) { void *fdt; - uint32_t expected_cells[5]; + fdt32_t expected_cells[5]; expected_cells[0] = cpu_to_fdt32((unsigned char)TEST_CHAR1); expected_cells[1] = cpu_to_fdt32((unsigned char)TEST_CHAR2); diff --git a/tests/dtbs_equal_ordered.c b/tests/dtbs_equal_ordered.c index 12495de..98bf0e7 100644 --- a/tests/dtbs_equal_ordered.c +++ b/tests/dtbs_equal_ordered.c @@ -28,7 +28,7 @@ #include "tests.h" #include "testdata.h" -int notequal; /* = 0 */ +static int notequal; /* = 0 */ #define MISMATCH(fmt, ...) \ do { \ diff --git a/tests/dtbs_equal_unordered.c b/tests/dtbs_equal_unordered.c index 20b4356..baf2ae7 100644 --- a/tests/dtbs_equal_unordered.c +++ b/tests/dtbs_equal_unordered.c @@ -29,7 +29,7 @@ #include "tests.h" #include "testdata.h" -int notequal; /* = 0 */ +static int notequal; /* = 0 */ #define MISMATCH(fmt, ...) \ 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 *re2 = p2; - if (re1->address < re2->address) + if (fdt64_to_cpu(re1->address) < fdt64_to_cpu(re2->address)) return -1; - else if (re1->address > re2->address) + else if (fdt64_to_cpu(re1->address) > fdt64_to_cpu(re2->address)) return 1; - if (re1->size < re2->size) + if (fdt64_to_cpu(re1->size) < fdt64_to_cpu(re2->size)) return -1; - else if (re1->size > re2->size) + else if (fdt64_to_cpu(re1->size) > fdt64_to_cpu(re2->size)) return 1; return 0; diff --git a/tests/dumptrees.c b/tests/dumptrees.c index a49dbfa..0728811 100644 --- a/tests/dumptrees.c +++ b/tests/dumptrees.c @@ -29,7 +29,7 @@ #include "testdata.h" -struct { +static struct { void *blob; const char *filename; } trees[] = { diff --git a/tests/integer-expressions.c b/tests/integer-expressions.c index 57e2ff6..ed1f967 100644 --- a/tests/integer-expressions.c +++ b/tests/integer-expressions.c @@ -30,7 +30,7 @@ #include "tests.h" #include "testdata.h" -struct test_expr { +static struct test_expr { const char *expr; uint32_t result; } expr_table[] = { @@ -70,7 +70,7 @@ struct test_expr { int main(int argc, char *argv[]) { void *fdt; - const uint32_t *res; + const fdt32_t *res; int reslen; int i; diff --git a/tests/node_offset_by_prop_value.c b/tests/node_offset_by_prop_value.c index 9212a4e..286f1e7 100644 --- a/tests/node_offset_by_prop_value.c +++ b/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, ...) \ { \ - uint32_t val = cpu_to_fdt32(propval); \ + fdt32_t val = cpu_to_fdt32(propval); \ check_search((fdt), (propname), &val, sizeof(val), \ ##__VA_ARGS__); \ } diff --git a/tests/nopulate.c b/tests/nopulate.c index cd79872..94ce8ad 100644 --- a/tests/nopulate.c +++ b/tests/nopulate.c @@ -45,7 +45,7 @@ static int nopulate_struct(char *buf, const char *fdt) nextoffset - offset); p += nextoffset - offset; - *((uint32_t *)p) = cpu_to_fdt32(FDT_NOP); + *((fdt32_t *)p) = cpu_to_fdt32(FDT_NOP); p += FDT_TAGSIZE; } while (tag != FDT_END); diff --git a/tests/property_iterate.c b/tests/property_iterate.c index 0f3959c..b5cedbe 100644 --- a/tests/property_iterate.c +++ b/tests/property_iterate.c @@ -33,7 +33,7 @@ static void test_node(void *fdt, int parent_offset) { - fdt32_t properties; + uint32_t properties; const fdt32_t *prop; int offset, property; int count; @@ -48,7 +48,7 @@ static void test_node(void *fdt, int parent_offset) FAIL("Missing/invalid test-properties property at '%s'", fdt_get_name(fdt, parent_offset, NULL)); } - properties = cpu_to_fdt32(*prop); + properties = fdt32_to_cpu(*prop); count = 0; offset = fdt_first_subnode(fdt, parent_offset); diff --git a/tests/references.c b/tests/references.c index 46662fc..cab70f6 100644 --- a/tests/references.c +++ b/tests/references.c @@ -29,7 +29,7 @@ static void check_ref(const void *fdt, int node, uint32_t checkref) { - const uint32_t *p; + const fdt32_t *p; uint32_t ref; 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) { - const uint32_t *p; + const fdt32_t *p; uint32_t ref; int len; diff --git a/tests/sized_cells.c b/tests/sized_cells.c index 94da03b..0b2b8dc 100644 --- a/tests/sized_cells.c +++ b/tests/sized_cells.c @@ -54,9 +54,9 @@ int main(int argc, char *argv[]) TEST_CHAR4, TEST_CHAR5, TEST_VALUE_1 >> 24}; - uint16_t expected_16[6]; - uint32_t expected_32[6]; - uint64_t expected_64[6]; + fdt16_t expected_16[6]; + fdt32_t expected_32[6]; + fdt64_t expected_64[6]; int i; for (i = 0; i < 5; ++i) { diff --git a/tests/subnode_iterate.c b/tests/subnode_iterate.c index 0fb5c90..7be5706 100644 --- a/tests/subnode_iterate.c +++ b/tests/subnode_iterate.c @@ -33,7 +33,7 @@ static void test_node(void *fdt, int parent_offset) { - fdt32_t subnodes; + uint32_t subnodes; const fdt32_t *prop; int offset; int count; @@ -45,7 +45,7 @@ static void test_node(void *fdt, int parent_offset) FAIL("Missing/invalid subnodes property at '%s'", fdt_get_name(fdt, parent_offset, NULL)); } - subnodes = cpu_to_fdt32(*prop); + subnodes = fdt32_to_cpu(*prop); count = 0; fdt_for_each_subnode(offset, fdt, parent_offset) diff --git a/tests/tests.h b/tests/tests.h index 56a843c..c0e4d3c 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -99,7 +99,7 @@ void check_property(void *fdt, int nodeoffset, const char *name, int len, const void *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); \ }) @@ -108,12 +108,12 @@ const void *check_getprop(void *fdt, int nodeoffset, const char *name, int len, const void *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); \ }) #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); \ }) #define check_getprop_string(fdt, nodeoffset, name, s) \ diff --git a/tests/value-labels.c b/tests/value-labels.c index dcf2059..8aced74 100644 --- a/tests/value-labels.c +++ b/tests/value-labels.c @@ -36,13 +36,13 @@ struct val_label { int propoff; }; -struct val_label labels1[] = { +static struct val_label labels1[] = { { "start1", 0 }, { "mid1", 2 }, { "end1", -1 }, }; -struct val_label labels2[] = { +static struct val_label labels2[] = { { "start2", 0 }, { "innerstart2", 0 }, { "innermid2", 4 }, @@ -50,7 +50,7 @@ struct val_label labels2[] = { { "end2", -1 }, }; -struct val_label labels3[] = { +static struct val_label labels3[] = { { "start3", 0 }, { "innerstart3", 0 }, { "innermid3", 1 }, |