diff mbox series

[3/7] tools: include necessary headers explicitly

Message ID 1515490492-29434-3-git-send-email-yamada.masahiro@socionext.com
State Superseded
Headers show
Series [1/7] libfdt: migrate fdt_rw.c to a wrapper of scripts/dtc/libfdt/fdt_rw.c | expand

Commit Message

Masahiro Yamada Jan. 9, 2018, 9:34 a.m. UTC
Several host-tools use "bool" type without including <stdbool.h>.
This relies on the crappy header inclusion chain.

tools/Makefile has the following line:

  HOST_EXTRACFLAGS += -include $(srctree)/include/libfdt_env.h \

All host-tools are forced to include libfdt_env.h even if they are
totally unrelated to FDT.  Then, <stdbool.h> is indirectly included
as follows:

     include/libfdt_env.h
  -> include/linux/types.h
  -> <stdbool.h>

I am fixing this horrible crap.  In advance, I need to add necessary
include directives explicitly.  tools/fdtgrep.c needs more; <fctl.h>
for open() and <errno.h> for errno.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 tools/fdtgrep.c         | 3 +++
 tools/gen_ethaddr_crc.c | 1 +
 tools/ifdtool.c         | 1 +
 tools/imagetool.h       | 1 +
 tools/mips-relocs.c     | 1 +
 5 files changed, 7 insertions(+)

Comments

Joe Hershberger Jan. 9, 2018, 5:23 p.m. UTC | #1
On Tue, Jan 9, 2018 at 3:34 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> Several host-tools use "bool" type without including <stdbool.h>.
> This relies on the crappy header inclusion chain.
>
> tools/Makefile has the following line:
>
>   HOST_EXTRACFLAGS += -include $(srctree)/include/libfdt_env.h \
>
> All host-tools are forced to include libfdt_env.h even if they are
> totally unrelated to FDT.  Then, <stdbool.h> is indirectly included
> as follows:
>
>      include/libfdt_env.h
>   -> include/linux/types.h
>   -> <stdbool.h>
>
> I am fixing this horrible crap.  In advance, I need to add necessary
> include directives explicitly.  tools/fdtgrep.c needs more; <fctl.h>
> for open() and <errno.h> for errno.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
Simon Glass Jan. 16, 2018, 2:50 p.m. UTC | #2
On 9 January 2018 at 01:34, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> Several host-tools use "bool" type without including <stdbool.h>.
> This relies on the crappy header inclusion chain.
>
> tools/Makefile has the following line:
>
>   HOST_EXTRACFLAGS += -include $(srctree)/include/libfdt_env.h \
>
> All host-tools are forced to include libfdt_env.h even if they are
> totally unrelated to FDT.  Then, <stdbool.h> is indirectly included
> as follows:
>
>      include/libfdt_env.h
>   -> include/linux/types.h
>   -> <stdbool.h>
>
> I am fixing this horrible crap.  In advance, I need to add necessary
> include directives explicitly.  tools/fdtgrep.c needs more; <fctl.h>
> for open() and <errno.h> for errno.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  tools/fdtgrep.c         | 3 +++
>  tools/gen_ethaddr_crc.c | 1 +
>  tools/ifdtool.c         | 1 +
>  tools/imagetool.h       | 1 +
>  tools/mips-relocs.c     | 1 +
>  5 files changed, 7 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/tools/fdtgrep.c b/tools/fdtgrep.c
index 7af77b7..8d33205 100644
--- a/tools/fdtgrep.c
+++ b/tools/fdtgrep.c
@@ -10,7 +10,10 @@ 
 
 #include <assert.h>
 #include <ctype.h>
+#include <errno.h>
 #include <getopt.h>
+#include <fcntl.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tools/gen_ethaddr_crc.c b/tools/gen_ethaddr_crc.c
index fe9896d..8cf86f4 100644
--- a/tools/gen_ethaddr_crc.c
+++ b/tools/gen_ethaddr_crc.c
@@ -6,6 +6,7 @@ 
  */
 
 #include <ctype.h>
+#include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/tools/ifdtool.c b/tools/ifdtool.c
index 195b153..729991e 100644
--- a/tools/ifdtool.c
+++ b/tools/ifdtool.c
@@ -12,6 +12,7 @@ 
 #include <assert.h>
 #include <fcntl.h>
 #include <getopt.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/tools/imagetool.h b/tools/imagetool.h
index a8d5054..e67de9b 100644
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -12,6 +12,7 @@ 
 #include "os_support.h"
 #include <errno.h>
 #include <fcntl.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/tools/mips-relocs.c b/tools/mips-relocs.c
index 8be69d3..27d4730 100644
--- a/tools/mips-relocs.c
+++ b/tools/mips-relocs.c
@@ -11,6 +11,7 @@ 
 #include <errno.h>
 #include <fcntl.h>
 #include <limits.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/mman.h>