Browse Source

dtc: Fix signedness comparisons warnings: change types

With -Wsign-compare, compilers warn about a mismatching signedness in
comparisons in various parts of dtc.

Many variables are using signed types unnecessarily, as we never use
negative value in them.
Change their types to be unsigned, to prevent issues with comparisons.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Message-Id: <20201012161948.23994-7-andre.przywara@arm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
main
Andre Przywara 4 years ago committed by David Gibson
parent
commit
e1147b159e
  1. 4
      data.c
  2. 8
      dtc.h
  3. 8
      flattree.c
  4. 2
      livetree.c
  5. 6
      yamltree.c

4
data.c

@ -21,10 +21,10 @@ void data_free(struct data d)
free(d.val); free(d.val);
} }


struct data data_grow_for(struct data d, int xlen) struct data data_grow_for(struct data d, unsigned int xlen)
{ {
struct data nd; struct data nd;
int newsize; unsigned int newsize;


if (xlen == 0) if (xlen == 0)
return d; return d;

8
dtc.h

@ -105,13 +105,13 @@ extern const char *markername(enum markertype markertype);


struct marker { struct marker {
enum markertype type; enum markertype type;
int offset; unsigned int offset;
char *ref; char *ref;
struct marker *next; struct marker *next;
}; };


struct data { struct data {
int len; unsigned int len;
char *val; char *val;
struct marker *markers; struct marker *markers;
}; };
@ -129,7 +129,7 @@ size_t type_marker_length(struct marker *m);


void data_free(struct data d); void data_free(struct data d);


struct data data_grow_for(struct data d, int xlen); struct data data_grow_for(struct data d, unsigned int xlen);


struct data data_copy_mem(const char *mem, int len); struct data data_copy_mem(const char *mem, int len);
struct data data_copy_escape_string(const char *s, int len); struct data data_copy_escape_string(const char *s, int len);
@ -253,7 +253,7 @@ void append_to_property(struct node *node,
const char *get_unitname(struct node *node); const char *get_unitname(struct node *node);
struct property *get_property(struct node *node, const char *propname); struct property *get_property(struct node *node, const char *propname);
cell_t propval_cell(struct property *prop); cell_t propval_cell(struct property *prop);
cell_t propval_cell_n(struct property *prop, int n); cell_t propval_cell_n(struct property *prop, unsigned int n);
struct property *get_property_by_label(struct node *tree, const char *label, struct property *get_property_by_label(struct node *tree, const char *label,
struct node **node); struct node **node);
struct marker *get_marker_label(struct node *tree, const char *label, struct marker *get_marker_label(struct node *tree, const char *label,

8
flattree.c

@ -149,7 +149,7 @@ static void asm_emit_align(void *e, int a)
static void asm_emit_data(void *e, struct data d) static void asm_emit_data(void *e, struct data d)
{ {
FILE *f = e; FILE *f = e;
int off = 0; unsigned int off = 0;
struct marker *m = d.markers; struct marker *m = d.markers;


for_each_marker_of_type(m, LABEL) for_each_marker_of_type(m, LABEL)
@ -219,7 +219,7 @@ static struct emitter asm_emitter = {


static int stringtable_insert(struct data *d, const char *str) static int stringtable_insert(struct data *d, const char *str)
{ {
int i; unsigned int i;


/* FIXME: do this more efficiently? */ /* FIXME: do this more efficiently? */


@ -345,7 +345,7 @@ static void make_fdt_header(struct fdt_header *fdt,
void dt_to_blob(FILE *f, struct dt_info *dti, int version) void dt_to_blob(FILE *f, struct dt_info *dti, int version)
{ {
struct version_info *vi = NULL; struct version_info *vi = NULL;
int i; unsigned int i;
struct data blob = empty_data; struct data blob = empty_data;
struct data reservebuf = empty_data; struct data reservebuf = empty_data;
struct data dtbuf = empty_data; struct data dtbuf = empty_data;
@ -446,7 +446,7 @@ static void dump_stringtable_asm(FILE *f, struct data strbuf)
void dt_to_asm(FILE *f, struct dt_info *dti, int version) void dt_to_asm(FILE *f, struct dt_info *dti, int version)
{ {
struct version_info *vi = NULL; struct version_info *vi = NULL;
int i; unsigned int i;
struct data strbuf = empty_data; struct data strbuf = empty_data;
struct reserve_info *re; struct reserve_info *re;
const char *symprefix = "dt"; const char *symprefix = "dt";

2
livetree.c

@ -438,7 +438,7 @@ cell_t propval_cell(struct property *prop)
return fdt32_to_cpu(*((fdt32_t *)prop->val.val)); return fdt32_to_cpu(*((fdt32_t *)prop->val.val));
} }


cell_t propval_cell_n(struct property *prop, int n) cell_t propval_cell_n(struct property *prop, unsigned int n)
{ {
assert(prop->val.len / sizeof(cell_t) >= n); assert(prop->val.len / sizeof(cell_t) >= n);
return fdt32_to_cpu(*((fdt32_t *)prop->val.val + n)); return fdt32_to_cpu(*((fdt32_t *)prop->val.val + n));

6
yamltree.c

@ -29,11 +29,11 @@ char *yaml_error_name[] = {
(emitter)->problem, __func__, __LINE__); \ (emitter)->problem, __func__, __LINE__); \
}) })


static void yaml_propval_int(yaml_emitter_t *emitter, struct marker *markers, char *data, int len, int width) static void yaml_propval_int(yaml_emitter_t *emitter, struct marker *markers, char *data, unsigned int len, int width)
{ {
yaml_event_t event; yaml_event_t event;
void *tag; void *tag;
int off, start_offset = markers->offset; unsigned int off, start_offset = markers->offset;


switch(width) { switch(width) {
case 1: tag = "!u8"; break; case 1: tag = "!u8"; break;
@ -112,7 +112,7 @@ static void yaml_propval_string(yaml_emitter_t *emitter, char *str, int len)
static void yaml_propval(yaml_emitter_t *emitter, struct property *prop) static void yaml_propval(yaml_emitter_t *emitter, struct property *prop)
{ {
yaml_event_t event; yaml_event_t event;
int len = prop->val.len; unsigned int len = prop->val.len;
struct marker *m = prop->val.markers; struct marker *m = prop->val.markers;


/* Emit the property name */ /* Emit the property name */

Loading…
Cancel
Save