mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
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>
This commit is contained in:
parent
672ac09ea0
commit
bad5b28049
25 changed files with 71 additions and 67 deletions
|
@ -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);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "tests.h"
|
||||
#include "testdata.h"
|
||||
|
||||
int notequal; /* = 0 */
|
||||
static int notequal; /* = 0 */
|
||||
|
||||
#define MISMATCH(fmt, ...) \
|
||||
do { \
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include "testdata.h"
|
||||
|
||||
struct {
|
||||
static struct {
|
||||
void *blob;
|
||||
const char *filename;
|
||||
} trees[] = {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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__); \
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) \
|
||||
|
|
|
@ -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 },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue