Browse Source

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>
main
David Gibson 7 years ago
parent
commit
3b62fdaebf
  1. 32
      checks.c
  2. 6
      dtc.h
  3. 6
      fdtput.c
  4. 6
      srcpos.h
  5. 2
      tests/dumptrees.c
  6. 12
      tests/testdata.h
  7. 6
      tests/tests.h
  8. 6
      tests/trees.S
  9. 2
      tests/truncated_property.c
  10. 6
      util.h

32
checks.c

@ -53,24 +53,24 @@ struct check {
struct check **prereq; struct check **prereq;
}; };


#define CHECK_ENTRY(_nm, _fn, _d, _w, _e, ...) \ #define CHECK_ENTRY(nm_, fn_, d_, w_, e_, ...) \
static struct check *_nm##_prereqs[] = { __VA_ARGS__ }; \ static struct check *nm_##_prereqs[] = { __VA_ARGS__ }; \
static struct check _nm = { \ static struct check nm_ = { \
.name = #_nm, \ .name = #nm_, \
.fn = (_fn), \ .fn = (fn_), \
.data = (_d), \ .data = (d_), \
.warn = (_w), \ .warn = (w_), \
.error = (_e), \ .error = (e_), \
.status = UNCHECKED, \ .status = UNCHECKED, \
.num_prereqs = ARRAY_SIZE(_nm##_prereqs), \ .num_prereqs = ARRAY_SIZE(nm_##_prereqs), \
.prereq = _nm##_prereqs, \ .prereq = nm_##_prereqs, \
}; };
#define WARNING(_nm, _fn, _d, ...) \ #define WARNING(nm_, fn_, d_, ...) \
CHECK_ENTRY(_nm, _fn, _d, true, false, __VA_ARGS__) CHECK_ENTRY(nm_, fn_, d_, true, false, __VA_ARGS__)
#define ERROR(_nm, _fn, _d, ...) \ #define ERROR(nm_, fn_, d_, ...) \
CHECK_ENTRY(_nm, _fn, _d, false, true, __VA_ARGS__) CHECK_ENTRY(nm_, fn_, d_, false, true, __VA_ARGS__)
#define CHECK(_nm, _fn, _d, ...) \ #define CHECK(nm_, fn_, d_, ...) \
CHECK_ENTRY(_nm, _fn, _d, false, false, __VA_ARGS__) CHECK_ENTRY(nm_, fn_, d_, false, false, __VA_ARGS__)


static inline void PRINTF(3, 4) check_msg(struct check *c, struct dt_info *dti, static inline void PRINTF(3, 4) check_msg(struct check *c, struct dt_info *dti,
const char *fmt, ...) const char *fmt, ...)

6
dtc.h

@ -1,5 +1,5 @@
#ifndef _DTC_H #ifndef DTC_H
#define _DTC_H #define DTC_H


/* /*
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005. * (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); struct dt_info *dt_from_fs(const char *dirname);


#endif /* _DTC_H */ #endif /* DTC_H */

6
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)) #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; int new_sz = fdt_totalsize(fdt) + delta;
fdt = xrealloc(fdt, new_sz); 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 */ /* FDT_BEGIN_NODE, node name in off_struct and FDT_END_NODE */
delta = sizeof(struct fdt_node_header) + ALIGN(strlen(name) + 1) delta = sizeof(struct fdt_node_header) + ALIGN(strlen(name) + 1)
+ FDT_TAGSIZE; + FDT_TAGSIZE;
return _realloc_fdt(fdt, delta); return realloc_fdt(fdt, delta);
} }


static char *realloc_property(char *fdt, int nodeoffset, 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 */ /* actual value in off_struct */
delta += ALIGN(newlen) - ALIGN(oldlen); 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, static int store_key_value(char **blob, const char *node_name,

6
srcpos.h

@ -17,8 +17,8 @@
* USA * USA
*/ */


#ifndef _SRCPOS_H_ #ifndef SRCPOS_H
#define _SRCPOS_H_ #define SRCPOS_H


#include <stdio.h> #include <stdio.h>
#include <stdbool.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); extern void srcpos_set_line(char *f, int l);


#endif /* _SRCPOS_H_ */ #endif /* SRCPOS_H */

2
tests/dumptrees.c

@ -33,7 +33,7 @@ static struct {
void *blob; void *blob;
const char *filename; const char *filename;
} trees[] = { } trees[] = {
#define TREE(name) { &_##name, #name ".dtb" } #define TREE(name) { &name, #name ".dtb" }
TREE(test_tree1), TREE(test_tree1),
TREE(bad_node_char), TREE(bad_node_format), TREE(bad_prop_char), TREE(bad_node_char), TREE(bad_node_format), TREE(bad_prop_char),
TREE(ovf_size_strings), TREE(ovf_size_strings),

12
tests/testdata.h

@ -41,10 +41,10 @@
#define TEST_CHAR5 '\xff' #define TEST_CHAR5 '\xff'


#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
extern struct fdt_header _test_tree1; extern struct fdt_header test_tree1;
extern struct fdt_header _truncated_property; extern struct fdt_header truncated_property;
extern struct fdt_header _bad_node_char; extern struct fdt_header bad_node_char;
extern struct fdt_header _bad_node_format; extern struct fdt_header bad_node_format;
extern struct fdt_header _bad_prop_char; extern struct fdt_header bad_prop_char;
extern struct fdt_header _ovf_size_strings; extern struct fdt_header ovf_size_strings;
#endif /* ! __ASSEMBLY */ #endif /* ! __ASSEMBLY */

6
tests/tests.h

@ -1,5 +1,5 @@
#ifndef _TESTS_H #ifndef TESTS_H
#define _TESTS_H #define TESTS_H
/* /*
* libfdt - Flat Device Tree manipulation * libfdt - Flat Device Tree manipulation
* Testcase definitions * Testcase definitions
@ -126,4 +126,4 @@ void *open_blob_rw(void *blob);


#include "util.h" #include "util.h"


#endif /* _TESTS_H */ #endif /* TESTS_H */

6
tests/trees.S

@ -9,8 +9,7 @@


#define TREE_HDR(tree) \ #define TREE_HDR(tree) \
.balign 8 ; \ .balign 8 ; \
.globl _##tree ; \ .globl tree ; \
_##tree: \
tree: \ tree: \
FDTLONG(FDT_MAGIC) ; \ FDTLONG(FDT_MAGIC) ; \
FDTLONG(tree##_end - tree) ; \ FDTLONG(tree##_end - tree) ; \
@ -208,8 +207,7 @@ bad_prop_char_end:


/* overflow_size_strings */ /* overflow_size_strings */
.balign 8 .balign 8
.globl _ovf_size_strings .globl ovf_size_strings
_ovf_size_strings:
ovf_size_strings: ovf_size_strings:
FDTLONG(FDT_MAGIC) FDTLONG(FDT_MAGIC)
FDTLONG(ovf_size_strings_end - ovf_size_strings) FDTLONG(ovf_size_strings_end - ovf_size_strings)

2
tests/truncated_property.c

@ -30,7 +30,7 @@


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



6
util.h

@ -1,5 +1,5 @@
#ifndef _UTIL_H #ifndef UTIL_H
#define _UTIL_H #define UTIL_H


#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>
@ -263,4 +263,4 @@ void NORETURN util_usage(const char *errmsg, const char *synopsis,
case 'V': util_version(); \ case 'V': util_version(); \
case '?': usage("unknown option"); case '?': usage("unknown option");


#endif /* _UTIL_H */ #endif /* UTIL_H */

Loading…
Cancel
Save