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>
This commit is contained in:
David Gibson 2017-10-18 16:59:43 +11:00
parent 2d45d1c5c6
commit 3b62fdaebf
10 changed files with 41 additions and 43 deletions

View file

@ -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),

View file

@ -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 */

View file

@ -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 */

View file

@ -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)

View file

@ -30,7 +30,7 @@
int main(int argc, char *argv[])
{
void *fdt = &_truncated_property;
void *fdt = &truncated_property;
const void *prop;
int len;