treewide: Clean up #includes

clang-tidy (as invoked by Zed editor) complains about various not-directly
used #includes.  Clean those up, though it does mean changing style a bit
(no longer using dtc.h to #include anything that any .c file might need).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
main
David Gibson 2026-11-11 17:29:43 +11:00
parent 2ecd679909
commit 79ad3e321f
38 changed files with 47 additions and 16 deletions

View File

@ -2,6 +2,7 @@
/*
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2007.
*/
#include <ctype.h>

#include "dtc.h"
#include "srcpos.h"

2
data.c
View File

@ -2,8 +2,10 @@
/*
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
*/
#include <errno.h>

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

void data_free(struct data d)
{

View File

@ -19,6 +19,8 @@ COMMENT "/*"([^*]|\*+[^*/])*\*+"/"
LINECOMMENT "//".*\n

%{
#include <ctype.h>

#include "dtc.h"
#include "srcpos.h"
#include "dtc-parser.tab.h"

View File

@ -5,6 +5,7 @@
%locations

%{
#include <errno.h>
#include <stdio.h>
#include <inttypes.h>


1
dtc.c
View File

@ -3,6 +3,7 @@
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
*/

#include <errno.h>
#include <sys/stat.h>

#include "dtc.h"

4
dtc.h
View File

@ -13,16 +13,12 @@
#include <stdbool.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <unistd.h>
#include <inttypes.h>

#include <libfdt_env.h>
#include <fdt.h>

#include "util.h"

#ifdef DEBUG
#define debug(...) printf(__VA_ARGS__)
#else

View File

@ -8,7 +8,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>

#include <libfdt.h>

View File

@ -2,6 +2,7 @@
/*
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
*/
#include <errno.h>

#include "dtc.h"
#include "srcpos.h"

View File

@ -3,11 +3,13 @@
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
*/

#include "dtc.h"

#include <dirent.h>
#include <errno.h>
#include <sys/stat.h>

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

static struct node *read_fstree(const char *dirname)
{
DIR *d;

View File

@ -7,6 +7,7 @@
#define _GNU_SOURCE
#endif

#include <errno.h>
#include <stdio.h>

#include "dtc.h"

View File

@ -15,6 +15,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

#define SPACE 65536


View File

@ -15,6 +15,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

#define SPACE 65536


View File

@ -15,6 +15,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

#define SPACE 65536


View File

@ -13,6 +13,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

int main(int argc, char *argv[])
{

View File

@ -14,6 +14,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

static int expect_bad; /* = 0 */


View File

@ -10,6 +10,7 @@
#include <libfdt.h>

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

static void *dtdup(void *dt)
{

View File

@ -10,6 +10,7 @@
#include <libfdt.h>

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

#define CHECK(code) \
{ \

View File

@ -15,6 +15,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

#define CHECK(code) \
{ \

View File

@ -13,6 +13,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

#define POISON ('\xff')


View File

@ -14,6 +14,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

#define CHUNKSIZE 1024


View File

@ -15,6 +15,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

int main(int argc, char *argv[])
{

View File

@ -15,6 +15,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

static int nopulate_struct(char *buf, const char *fdt)
{

View File

@ -15,6 +15,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

int main(int argc, char *argv[])
{

View File

@ -11,6 +11,7 @@
#include <libfdt.h>

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

#define CHECK(code) \
{ \

View File

@ -11,6 +11,7 @@
#include <libfdt.h>

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

#define CHECK(code, expected) \
{ \

View File

@ -15,6 +15,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

/* This is not derived programmatically. May require adjustment to changes. */
#define SPACE 285

View File

@ -15,6 +15,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

#define SPACE 65536


View File

@ -15,6 +15,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

#define SPACE 65536
#define NEW_STRING "here is quite a long test string, blah blah blah"
@ -78,6 +79,6 @@ int main(int argc, char *argv[])
FAIL("Failed to set \"prop-u64\" to 0x%016llx: %s",
TEST_VALUE64_1, fdt_strerror(err));
check_getprop_64(fdt, 0, "prop-u64", TEST_VALUE64_1);

PASS();
}

View File

@ -16,6 +16,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

int main(int argc, char *argv[])
{

View File

@ -15,6 +15,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

#define SPACE 65536


View File

@ -15,6 +15,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

#define SPACE 65536

@ -48,7 +49,7 @@ static void realloc_fdt(void **fdt, size_t *size, bool created)
fdt_strerror(err));
} else {
FAIL("Ran out of space");
}
}
return;

case REALLOC:
@ -128,7 +129,7 @@ int main(int argc, char *argv[])
size = strtoul(argv[1], &endp, 0);
if (*endp == '\0')
alloc_mode = FIXED;
else
else
CONFIG("Bad allocation mode \"%s\" specified",
argv[1]);
}

View File

@ -116,6 +116,4 @@ void *load_blob_arg(int argc, char *argv[]);
void save_blob(const char *filename, void *blob);
void *open_blob_rw(const void *blob);

#include "util.h"

#endif /* TESTS_H */

View File

@ -19,6 +19,8 @@
#include <unistd.h>
#include <fcntl.h>

#include "util.h"

#ifdef NO_VALGRIND
static inline void VALGRIND_MAKE_MEM_UNDEFINED(void *p, size_t len)
{

View File

@ -17,8 +17,8 @@
#include <libfdt_env.h>
#include <fdt.h>

#include "tests.h"
#include "testdata.h"
#include "util.h"

/*
* Buffer with write cursor. Emit helpers write at the cursor, advance it, and

View File

@ -14,6 +14,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

#define SPACE 65536


View File

@ -17,6 +17,7 @@

#include "tests.h"
#include "testdata.h"
#include "util.h"

#define SPACE 65536

@ -57,7 +58,7 @@ int main(int argc, char *argv[])
if (err != -FDT_ERR_TRUNCATED)
FAIL("fdt_del_mem_rsv() returned %d instead of -FDT_ERR_TRUNCATED",
err);

buf = xmalloc(SPACE);
err = fdt_open_into(fdt, buf, SPACE);
if (err != -FDT_ERR_TRUNCATED)

View File

@ -2,6 +2,7 @@
/*
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
*/
#include <ctype.h>

#include "dtc.h"
#include "srcpos.h"

View File

@ -5,10 +5,11 @@
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
*/

#include <stdlib.h>
#include <ctype.h>
#include <yaml.h>

#include "dtc.h"
#include "srcpos.h"
#include "util.h"

const char *yaml_error_name[] = {
[YAML_NO_ERROR] = "no error",