summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2017-10-18 16:59:43 +1100
committerDavid Gibson <david@gibson.dropbear.id.au>2017-10-26 09:25:14 +0200
commit3b62fdaebfe577566ff2387eb1c55344a7f55982 (patch)
tree8b7ff2c661b7b8de1735072afa1ff8deaccedc46
parent2d45d1c5c65e9b3cd020fac624ed9bf6c2855a91 (diff)
downloaddevice-tree-compiler-3b62fdaebfe577566ff2387eb1c55344a7f55982.tar.gz
Remove leading underscores from identifiers
In a number of places, dtc and associated tools and test code use leading _ characters on identifiers to flag them as "internal", an idiom taken from the Linux kernel. This is a bad idea in a userspace program, because identifiers with a leading _ are reserved for the C library / system. In some cases, the extra _ served no real purpose, so simply drop it. In others move to the end of the identifier, which is a convention we're free to use for our own purposes. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--checks.c32
-rw-r--r--dtc.h6
-rw-r--r--fdtput.c6
-rw-r--r--srcpos.h6
-rw-r--r--tests/dumptrees.c2
-rw-r--r--tests/testdata.h12
-rw-r--r--tests/tests.h6
-rw-r--r--tests/trees.S6
-rw-r--r--tests/truncated_property.c2
-rw-r--r--util.h6
10 files changed, 41 insertions, 43 deletions
diff --git a/checks.c b/checks.c
index e661384..770af32 100644
--- a/checks.c
+++ b/checks.c
@@ -53,24 +53,24 @@ struct check {
struct check **prereq;
};
-#define CHECK_ENTRY(_nm, _fn, _d, _w, _e, ...) \
- static struct check *_nm##_prereqs[] = { __VA_ARGS__ }; \
- static struct check _nm = { \
- .name = #_nm, \
- .fn = (_fn), \
- .data = (_d), \
- .warn = (_w), \
- .error = (_e), \
+#define CHECK_ENTRY(nm_, fn_, d_, w_, e_, ...) \
+ static struct check *nm_##_prereqs[] = { __VA_ARGS__ }; \
+ static struct check nm_ = { \
+ .name = #nm_, \
+ .fn = (fn_), \
+ .data = (d_), \
+ .warn = (w_), \
+ .error = (e_), \
.status = UNCHECKED, \
- .num_prereqs = ARRAY_SIZE(_nm##_prereqs), \
- .prereq = _nm##_prereqs, \
+ .num_prereqs = ARRAY_SIZE(nm_##_prereqs), \
+ .prereq = nm_##_prereqs, \
};
-#define WARNING(_nm, _fn, _d, ...) \
- CHECK_ENTRY(_nm, _fn, _d, true, false, __VA_ARGS__)
-#define ERROR(_nm, _fn, _d, ...) \
- CHECK_ENTRY(_nm, _fn, _d, false, true, __VA_ARGS__)
-#define CHECK(_nm, _fn, _d, ...) \
- CHECK_ENTRY(_nm, _fn, _d, false, false, __VA_ARGS__)
+#define WARNING(nm_, fn_, d_, ...) \
+ CHECK_ENTRY(nm_, fn_, d_, true, false, __VA_ARGS__)
+#define ERROR(nm_, fn_, d_, ...) \
+ CHECK_ENTRY(nm_, fn_, d_, false, true, __VA_ARGS__)
+#define CHECK(nm_, fn_, d_, ...) \
+ CHECK_ENTRY(nm_, fn_, d_, false, false, __VA_ARGS__)
static inline void PRINTF(3, 4) check_msg(struct check *c, struct dt_info *dti,
const char *fmt, ...)
diff --git a/dtc.h b/dtc.h
index 35cf926..760f9e3 100644
--- a/dtc.h
+++ b/dtc.h
@@ -1,5 +1,5 @@
-#ifndef _DTC_H
-#define _DTC_H
+#ifndef DTC_H
+#define DTC_H
/*
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
@@ -289,4 +289,4 @@ struct dt_info *dt_from_source(const char *f);
struct dt_info *dt_from_fs(const char *dirname);
-#endif /* _DTC_H */
+#endif /* DTC_H */
diff --git a/fdtput.c b/fdtput.c
index 8d8e934..72a0058 100644
--- a/fdtput.c
+++ b/fdtput.c
@@ -130,7 +130,7 @@ static int encode_value(struct display_info *disp, char **arg, int arg_count,
#define ALIGN(x) (((x) + (FDT_TAGSIZE) - 1) & ~((FDT_TAGSIZE) - 1))
-static char *_realloc_fdt(char *fdt, int delta)
+static char *realloc_fdt(char *fdt, int delta)
{
int new_sz = fdt_totalsize(fdt) + delta;
fdt = xrealloc(fdt, new_sz);
@@ -144,7 +144,7 @@ static char *realloc_node(char *fdt, const char *name)
/* FDT_BEGIN_NODE, node name in off_struct and FDT_END_NODE */
delta = sizeof(struct fdt_node_header) + ALIGN(strlen(name) + 1)
+ FDT_TAGSIZE;
- return _realloc_fdt(fdt, delta);
+ return realloc_fdt(fdt, delta);
}
static char *realloc_property(char *fdt, int nodeoffset,
@@ -161,7 +161,7 @@ static char *realloc_property(char *fdt, int nodeoffset,
/* actual value in off_struct */
delta += ALIGN(newlen) - ALIGN(oldlen);
- return _realloc_fdt(fdt, delta);
+ return realloc_fdt(fdt, delta);
}
static int store_key_value(char **blob, const char *node_name,
diff --git a/srcpos.h b/srcpos.h
index 7caca82..9ded12a 100644
--- a/srcpos.h
+++ b/srcpos.h
@@ -17,8 +17,8 @@
* USA
*/
-#ifndef _SRCPOS_H_
-#define _SRCPOS_H_
+#ifndef SRCPOS_H
+#define SRCPOS_H
#include <stdio.h>
#include <stdbool.h>
@@ -114,4 +114,4 @@ extern void PRINTF(3, 4) srcpos_error(struct srcpos *pos, const char *prefix,
extern void srcpos_set_line(char *f, int l);
-#endif /* _SRCPOS_H_ */
+#endif /* SRCPOS_H */
diff --git a/tests/dumptrees.c b/tests/dumptrees.c
index 0728811..87d1c3d 100644
--- a/tests/dumptrees.c
+++ b/tests/dumptrees.c
@@ -33,7 +33,7 @@ static struct {
void *blob;
const char *filename;
} trees[] = {
-#define TREE(name) { &_##name, #name ".dtb" }
+#define TREE(name) { &name, #name ".dtb" }
TREE(test_tree1),
TREE(bad_node_char), TREE(bad_node_format), TREE(bad_prop_char),
TREE(ovf_size_strings),
diff --git a/tests/testdata.h b/tests/testdata.h
index f6bbe1d..c30f0c8 100644
--- a/tests/testdata.h
+++ b/tests/testdata.h
@@ -41,10 +41,10 @@
#define TEST_CHAR5 '\xff'
#ifndef __ASSEMBLY__
-extern struct fdt_header _test_tree1;
-extern struct fdt_header _truncated_property;
-extern struct fdt_header _bad_node_char;
-extern struct fdt_header _bad_node_format;
-extern struct fdt_header _bad_prop_char;
-extern struct fdt_header _ovf_size_strings;
+extern struct fdt_header test_tree1;
+extern struct fdt_header truncated_property;
+extern struct fdt_header bad_node_char;
+extern struct fdt_header bad_node_format;
+extern struct fdt_header bad_prop_char;
+extern struct fdt_header ovf_size_strings;
#endif /* ! __ASSEMBLY */
diff --git a/tests/tests.h b/tests/tests.h
index c0e4d3c..df38b77 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -1,5 +1,5 @@
-#ifndef _TESTS_H
-#define _TESTS_H
+#ifndef TESTS_H
+#define TESTS_H
/*
* libfdt - Flat Device Tree manipulation
* Testcase definitions
@@ -126,4 +126,4 @@ void *open_blob_rw(void *blob);
#include "util.h"
-#endif /* _TESTS_H */
+#endif /* TESTS_H */
diff --git a/tests/trees.S b/tests/trees.S
index 9859914..6898cf9 100644
--- a/tests/trees.S
+++ b/tests/trees.S
@@ -9,8 +9,7 @@
#define TREE_HDR(tree) \
.balign 8 ; \
- .globl _##tree ; \
-_##tree: \
+ .globl tree ; \
tree: \
FDTLONG(FDT_MAGIC) ; \
FDTLONG(tree##_end - tree) ; \
@@ -208,8 +207,7 @@ bad_prop_char_end:
/* overflow_size_strings */
.balign 8
- .globl _ovf_size_strings
-_ovf_size_strings:
+ .globl ovf_size_strings
ovf_size_strings:
FDTLONG(FDT_MAGIC)
FDTLONG(ovf_size_strings_end - ovf_size_strings)
diff --git a/tests/truncated_property.c b/tests/truncated_property.c
index f820d99..71619bb 100644
--- a/tests/truncated_property.c
+++ b/tests/truncated_property.c
@@ -30,7 +30,7 @@
int main(int argc, char *argv[])
{
- void *fdt = &_truncated_property;
+ void *fdt = &truncated_property;
const void *prop;
int len;
diff --git a/util.h b/util.h
index ea62715..66fba8e 100644
--- a/util.h
+++ b/util.h
@@ -1,5 +1,5 @@
-#ifndef _UTIL_H
-#define _UTIL_H
+#ifndef UTIL_H
+#define UTIL_H
#include <stdarg.h>
#include <stdbool.h>
@@ -263,4 +263,4 @@ void NORETURN util_usage(const char *errmsg, const char *synopsis,
case 'V': util_version(); \
case '?': usage("unknown option");
-#endif /* _UTIL_H */
+#endif /* UTIL_H */