summaryrefslogtreecommitdiff
path: root/libfdt
diff options
context:
space:
mode:
Diffstat (limited to 'libfdt')
-rw-r--r--libfdt/fdt.c5
-rw-r--r--libfdt/fdt_ro.c7
-rw-r--r--libfdt/fdt_rw.c8
-rw-r--r--libfdt/libfdt_internal.h7
4 files changed, 10 insertions, 17 deletions
diff --git a/libfdt/fdt.c b/libfdt/fdt.c
index c61fb531b3c..bd91712378b 100644
--- a/libfdt/fdt.c
+++ b/libfdt/fdt.c
@@ -184,10 +184,7 @@ const char *_fdt_find_string(const char *strtab, int tabsize, const char *s)
int fdt_move(const void *fdt, void *buf, int bufsize)
{
- int err = fdt_check_header(fdt);
-
- if (err)
- return err;
+ CHECK_HEADER(fdt);
if (fdt_totalsize(fdt) > bufsize)
return -FDT_ERR_NOSPACE;
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index f08941a7ade..15d5f6b585c 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -55,13 +55,6 @@
#include "libfdt_internal.h"
-#define CHECK_HEADER(fdt) \
- { \
- int err; \
- if ((err = fdt_check_header(fdt)) != 0) \
- return err; \
- }
-
static int nodename_eq(const void *fdt, int offset,
const char *s, int len)
{
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index ac5019560fe..0df472bc5e0 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -69,10 +69,8 @@ static int _blocks_misordered(const void *fdt,
static int rw_check_header(void *fdt)
{
- int err;
+ CHECK_HEADER(fdt);
- if ((err = fdt_check_header(fdt)))
- return err;
if (fdt_version(fdt) < 17)
return -FDT_ERR_BADVERSION;
if (_blocks_misordered(fdt, sizeof(struct fdt_reserve_entry),
@@ -399,9 +397,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
int newsize;
void *tmp;
- err = fdt_check_header(fdt);
- if (err)
- return err;
+ CHECK_HEADER(fdt);
mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
* sizeof(struct fdt_reserve_entry);
diff --git a/libfdt/libfdt_internal.h b/libfdt/libfdt_internal.h
index 1e60936beb5..52e1b8d810b 100644
--- a/libfdt/libfdt_internal.h
+++ b/libfdt/libfdt_internal.h
@@ -58,6 +58,13 @@
#define memeq(p, q, n) (memcmp((p), (q), (n)) == 0)
#define streq(p, q) (strcmp((p), (q)) == 0)
+#define CHECK_HEADER(fdt) \
+ { \
+ int err; \
+ if ((err = fdt_check_header(fdt)) != 0) \
+ return err; \
+ }
+
uint32_t _fdt_next_tag(const void *fdt, int startoffset, int *nextoffset);
const char *_fdt_find_string(const char *strtab, int tabsize, const char *s);
int _fdt_node_end_offset(void *fdt, int nodeoffset);