summaryrefslogtreecommitdiffstats
path: root/cpukit/dtc/libfdt
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@arm.com>2020-10-01 17:46:25 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-12-14 16:00:44 +0100
commit89e5744e02e34ca92bfb6cb218f081edfd9dd0b3 (patch)
tree426ede4acfcc5c7b99c9582ec91957439174da9d /cpukit/dtc/libfdt
parentlibfdt: fdt_node_offset_by_phandle(): Fix comparison warning (diff)
downloadrtems-89e5744e02e34ca92bfb6cb218f081edfd9dd0b3.tar.bz2
libfdt: fdt_add_string_(): Fix comparison warning
With -Wsign-compare, compilers warn about a mismatching signedness in a comparison in fdt_add_string_(). Make all variables unsigned, and express the negative offset trick via subtractions in the code. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Message-Id: <20201001164630.4980-2-andre.przywara@arm.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'cpukit/dtc/libfdt')
-rw-r--r--cpukit/dtc/libfdt/fdt_sw.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/cpukit/dtc/libfdt/fdt_sw.c b/cpukit/dtc/libfdt/fdt_sw.c
index 8de18fd4f9..354f46674b 100644
--- a/cpukit/dtc/libfdt/fdt_sw.c
+++ b/cpukit/dtc/libfdt/fdt_sw.c
@@ -250,18 +250,18 @@ int fdt_end_node(void *fdt)
static int fdt_add_string_(void *fdt, const char *s)
{
char *strtab = (char *)fdt + fdt_totalsize(fdt);
- int strtabsize = fdt_size_dt_strings(fdt);
- int len = strlen(s) + 1;
- int struct_top, offset;
+ unsigned int strtabsize = fdt_size_dt_strings(fdt);
+ unsigned int len = strlen(s) + 1;
+ unsigned int struct_top, offset;
- offset = -strtabsize - len;
+ offset = strtabsize + len;
struct_top = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);
- if (fdt_totalsize(fdt) + offset < struct_top)
+ if (fdt_totalsize(fdt) - offset < struct_top)
return 0; /* no more room :( */
- memcpy(strtab + offset, s, len);
+ memcpy(strtab - offset, s, len);
fdt_set_size_dt_strings(fdt, strtabsize + len);
- return offset;
+ return -offset;
}
/* Must only be used to roll back in case of error */