aboutsummaryrefslogtreecommitdiff
path: root/libfdt/fdt_rw.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2007-10-25 14:29:38 +1000
committerJon Loeliger <jdl@freescale.com>2007-10-25 09:49:18 -0500
commit9b91134ba3043deb7689bcee06b78a596647c626 (patch)
tree4d1e6d25fca6e8780c0ca89bb37a6103445563a4 /libfdt/fdt_rw.c
parent57f99b7b3f8f21d4e685a50665951e9bcaad80b7 (diff)
downloaddtc-9b91134ba3043deb7689bcee06b78a596647c626.zip
dtc-9b91134ba3043deb7689bcee06b78a596647c626.tar.gz
dtc-9b91134ba3043deb7689bcee06b78a596647c626.tar.bz2
libfdt: Remove un-const-safe fdt_set_header macro
The fdt_set_header() macro casts an arbitrary pointer into (struct fdt_header *) to set fdt header fields. While we need to change the type, so that we can use this macro on the usual (void *) used to represent a device tree blob, the current macro also casts away any const on the input pointer, which loses an important check. This patch replaces the fdt_set_header() macro with a set of inline functions, one for each header field which do a similar thing, but which won't silently remove const from a given pointer. This approach is also more in keeping with the individual accessor macros we use for reading fdt header fields. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'libfdt/fdt_rw.c')
-rw-r--r--libfdt/fdt_rw.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index 485b39d..23547a5 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -109,8 +109,8 @@ static int _blob_splice_mem_rsv(void *fdt, struct fdt_reserve_entry *p,
err = _blob_splice(fdt, p, oldn * sizeof(*p), newn * sizeof(*p));
if (err)
return err;
- fdt_set_header(fdt, off_dt_struct, fdt_off_dt_struct(fdt) + delta);
- fdt_set_header(fdt, off_dt_strings, fdt_off_dt_strings(fdt) + delta);
+ fdt_set_off_dt_struct(fdt, fdt_off_dt_struct(fdt) + delta);
+ fdt_set_off_dt_strings(fdt, fdt_off_dt_strings(fdt) + delta);
return 0;
}
@@ -123,8 +123,8 @@ static int _blob_splice_struct(void *fdt, void *p,
if ((err = _blob_splice(fdt, p, oldlen, newlen)))
return err;
- fdt_set_header(fdt, size_dt_struct, fdt_size_dt_struct(fdt) + delta);
- fdt_set_header(fdt, off_dt_strings, fdt_off_dt_strings(fdt) + delta);
+ fdt_set_size_dt_struct(fdt, fdt_size_dt_struct(fdt) + delta);
+ fdt_set_off_dt_strings(fdt, fdt_off_dt_strings(fdt) + delta);
return 0;
}
@@ -136,7 +136,7 @@ static int _blob_splice_string(void *fdt, int newlen)
if ((err = _blob_splice(fdt, p, 0, newlen)))
return err;
- fdt_set_header(fdt, size_dt_strings, fdt_size_dt_strings(fdt) + newlen);
+ fdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) + newlen);
return 0;
}
@@ -349,7 +349,7 @@ int fdt_open_into(void *fdt, void *buf, int bufsize)
fdt = buf;
- fdt_set_header(fdt, totalsize, bufsize);
+ fdt_set_totalsize(fdt, bufsize);
/* FIXME: re-order if necessary */
@@ -369,6 +369,6 @@ int fdt_pack(void *fdt)
return err;
/* FIXME: pack components */
- fdt_set_header(fdt, totalsize, _blob_data_size(fdt));
+ fdt_set_totalsize(fdt, _blob_data_size(fdt));
return 0;
}