Skip to contentSkip to conversation

kconfig: header inclusion cleanups

PATCH In review Boris Kolpackov 2 participants 9 messages Oct 29, 2020 – Nov 23, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover kconfig: header inclusion cleanups

Add missing and remove no longer necessary header inclusions.

Boris Kolpackov (2):
kconfig: make lkc.h self-sufficient #include-wise
kconfig: clean up header inclusion

 scripts/kconfig/conf.c     | 6 +++---
 scripts/kconfig/confdata.c | 4 +++-
 scripts/kconfig/lexer.l    | 1 -
 scripts/kconfig/lkc.h      | 4 ++++
 scripts/kconfig/symbol.c   | 3 ++-
 5 files changed, 12 insertions(+), 6 deletions(-)

--
2.29.0

#1 lore raw

PATCH 1/2 kconfig: make lkc.h self-sufficient #include-wise

---
 scripts/kconfig/lkc.h | 4 ++++
 1 file changed, 4 insertions(+)
scripts/kconfig/lkc.h +4 -0
index 8454649..3e2c70e 100644
@@ -6,6 +6,10 @@
 #ifndef LKC_H
 #define LKC_H
 
+#include <stdio.h>
+#include <assert.h>
+#include <stdlib.h>
+
 #include "expr.h"
 
 #ifdef __cplusplus
Signature · 1 line
2.29.0
#2 lore raw

Re: [PATCH 1/2] kconfig: make lkc.h self-sufficient #include-wise

Quoted 22 lines · Boris Kolpackov
---
 scripts/kconfig/lkc.h | 4 ++++
 1 file changed, 4 insertions(+)
scripts/kconfig/lkc.h +4 -1
index 8454649..3e2c70e 100644
@@ -6,6 +6,10 @@
 #ifndef LKC_H
 #define LKC_H
 
+#include <stdio.h>
+#include <assert.h>
+#include <stdlib.h>
+
 #include "expr.h"
 
 #ifdef __cplusplus
--
Quoted 2 lines

2.29.0

Applied to linux-kbuild.

Signature · 2 lines
Best Regards
Masahiro Yamada
#3 lore raw

PATCH 2/2 kconfig: clean up header inclusion

In reply to Boris Kolpackov

- Add missing includes.
- Remove no longer necessary includes.
- Separate non-portable header includes for easier porting.

---
 scripts/kconfig/conf.c     | 6 +++---
 scripts/kconfig/confdata.c | 4 +++-
 scripts/kconfig/lexer.l    | 1 -
 scripts/kconfig/symbol.c   | 3 ++-
 4 files changed, 8 insertions(+), 6 deletions(-)
scripts/kconfig/conf.c +3 -3
index f6e548b..74974df 100644
@@ -9,12 +9,12 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
-#include <unistd.h>
 #include <getopt.h>
-#include <sys/stat.h>
-#include <sys/time.h>
 #include <errno.h>
 
+#include <unistd.h>
+#include <sys/time.h>
+
 #include "lkc.h"
 
 static void conf(struct menu *menu);
scripts/kconfig/confdata.c +3 -1
index a39d93e..64344b9 100644
@@ -3,7 +3,7 @@
  * Copyright (C) 2002 Roman Zippel <[email protected]>
  */
 
-#include <sys/mman.h>
+#include <sys/types.h>
 #include <sys/stat.h>
 #include <ctype.h>
 #include <errno.h>
@@ -14,7 +14,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+
 #include <unistd.h>
+#include <sys/mman.h>
 
 #include "lkc.h"
 
scripts/kconfig/lexer.l +0 -1
index 240109f..9c22cb5 100644
@@ -12,7 +12,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
 #include "lkc.h"
 #include "parser.tab.h"
scripts/kconfig/symbol.c +2 -1
index ffa3ec6..0e0f1cc 100644
@@ -6,8 +6,9 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/types.h> // off_t
+
 #include <regex.h>
-#include <sys/utsname.h>
 
 #include "lkc.h"
 
Signature · 1 line
2.29.0
#4 lore raw

Re: [PATCH 2/2] kconfig: clean up header inclusion

Quoted 4 lines · Boris Kolpackov

- Add missing includes.
- Remove no longer necessary includes.
- Separate non-portable header includes for easier porting.

I think the definition of "non-portable" depends on how far we expand the supported system.

I guess you want to segregate <unistd.h> and <sys/mmap.h> because you do not have them on Windows, correct?

Quoted 82 lines
---
 scripts/kconfig/conf.c     | 6 +++---
 scripts/kconfig/confdata.c | 4 +++-
 scripts/kconfig/lexer.l    | 1 -
 scripts/kconfig/symbol.c   | 3 ++-
 4 files changed, 8 insertions(+), 6 deletions(-)
scripts/kconfig/conf.c +3 -3
index f6e548b..74974df 100644
@@ -9,12 +9,12 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
-#include <unistd.h>
 #include <getopt.h>
-#include <sys/stat.h>
-#include <sys/time.h>
 #include <errno.h>
 
+#include <unistd.h>
+#include <sys/time.h>
+
 #include "lkc.h"
 
 static void conf(struct menu *menu);
scripts/kconfig/confdata.c +3 -1
index a39d93e..64344b9 100644
@@ -3,7 +3,7 @@
  * Copyright (C) 2002 Roman Zippel <[email protected]>
  */
 
-#include <sys/mman.h>
+#include <sys/types.h>
 #include <sys/stat.h>
 #include <ctype.h>
 #include <errno.h>
@@ -14,7 +14,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+
 #include <unistd.h>
+#include <sys/mman.h>
 
 #include "lkc.h"
 
scripts/kconfig/lexer.l +0 -1
index 240109f..9c22cb5 100644
@@ -12,7 +12,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
 #include "lkc.h"
 #include "parser.tab.h"
scripts/kconfig/symbol.c +2 -2
index ffa3ec6..0e0f1cc 100644
@@ -6,8 +6,9 @@
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/types.h> // off_t
+
 #include <regex.h>
-#include <sys/utsname.h>
 
 #include "lkc.h"
 
--

2.29.0

Signature · 2 lines
Best Regards
Masahiro Yamada
#5 lore raw

Re: [PATCH 2/2] kconfig: clean up header inclusion

Quoted 7 lines · Masahiro Yamada
Quoted 4 lines · Boris Kolpackov

- Add missing includes.
- Remove no longer necessary includes.
- Separate non-portable header includes for easier porting.

Quoted 5 lines

I think the definition of "non-portable" depends on how far we expand the supported system.

I guess you want to segregate <unistd.h> and <sys/mmap.h> because you do not have them on Windows, correct?

Correct. I have a set of patches that make kconfig portable to Windows. I assume there is no interest in these patches here so I will be maintaining them out of tree (but let me know if my assumption is wrong and I will happily submit them). Splitting the header inclusions into two blocks make these patches a bit cleaner and more resilient to changes.

Let me know if you would like me to change the patch to (1) clarify the non-portable part or (2) get rid of the split.

#6 lore raw

Re: [PATCH 2/2] kconfig: clean up header inclusion

Quoted 23 lines · Boris Kolpackov
Quoted 7 lines · Masahiro Yamada
Quoted 4 lines · Boris Kolpackov

- Add missing includes.
- Remove no longer necessary includes.
- Separate non-portable header includes for easier porting.

Quoted 5 lines

I think the definition of "non-portable" depends on how far we expand the supported system.

I guess you want to segregate <unistd.h> and <sys/mmap.h> because you do not have them on Windows, correct?

Correct. I have a set of patches that make kconfig portable to Windows. I assume there is no interest in these patches here so I will be maintaining them out of tree (but let me know if my assumption is wrong and I will happily submit them). Splitting the header inclusions into two blocks make these patches a bit cleaner and more resilient to changes.

Quoted 2 lines

Let me know if you would like me to change the patch to (1) clarify the non-portable part or (2) get rid of the split.

If you send v2 with the first two items:

- Add missing includes.
- Remove no longer necessary includes.

I will accept it.

I am not interested in the last one because
running kconfig on Windows
is not officially supported.

Signature · 2 lines
Best Regards
Masahiro Yamada
#7 lore raw

PATCH v2 2/2 kconfig: clean up header inclusion

- Add missing includes.
- Remove no longer necessary includes.
---

v2: Don't re-arrange includes.

 scripts/kconfig/conf.c     | 1 -
 scripts/kconfig/confdata.c | 1 +
 scripts/kconfig/lexer.l    | 1 -
 scripts/kconfig/symbol.c   | 2 +-
 4 files changed, 2 insertions(+), 3 deletions(-)
scripts/kconfig/conf.c +0 -1
index f6e548b..db03e2f 100644
@@ -11,7 +11,6 @@
 #include <time.h>
 #include <unistd.h>
 #include <getopt.h>
-#include <sys/stat.h>
 #include <sys/time.h>
 #include <errno.h>
 
scripts/kconfig/confdata.c +1 -0
index a39d93e..2568dbe 100644
@@ -5,6 +5,7 @@
 
 #include <sys/mman.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
scripts/kconfig/lexer.l +0 -1
index 240109f..9c22cb5 100644
@@ -12,7 +12,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
 #include "lkc.h"
 #include "parser.tab.h"
scripts/kconfig/symbol.c +1 -1
index ffa3ec6..fe38e6f 100644
@@ -3,11 +3,11 @@
  * Copyright (C) 2002 Roman Zippel <[email protected]>
  */
 
+#include <sys/types.h>
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
 #include <regex.h>
-#include <sys/utsname.h>
 
 #include "lkc.h"
 
Signature · 1 line
2.29.0
#8 lore raw

Re: [PATCH v2 2/2] kconfig: clean up header inclusion

Quoted 4 lines · Boris Kolpackov

- Add missing includes.
- Remove no longer necessary includes.
---

Applied to linux-kbuild. Thanks.

Quoted 64 lines

v2: Don't re-arrange includes.

 scripts/kconfig/conf.c     | 1 -
 scripts/kconfig/confdata.c | 1 +
 scripts/kconfig/lexer.l    | 1 -
 scripts/kconfig/symbol.c   | 2 +-
 4 files changed, 2 insertions(+), 3 deletions(-)
scripts/kconfig/conf.c +0 -1
index f6e548b..db03e2f 100644
@@ -11,7 +11,6 @@
 #include <time.h>
 #include <unistd.h>
 #include <getopt.h>
-#include <sys/stat.h>
 #include <sys/time.h>
 #include <errno.h>
 
scripts/kconfig/confdata.c +1 -0
index a39d93e..2568dbe 100644
@@ -5,6 +5,7 @@
 
 #include <sys/mman.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
scripts/kconfig/lexer.l +0 -1
index 240109f..9c22cb5 100644
@@ -12,7 +12,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
 #include "lkc.h"
 #include "parser.tab.h"
scripts/kconfig/symbol.c +1 -2
index ffa3ec6..fe38e6f 100644
@@ -3,11 +3,11 @@
  * Copyright (C) 2002 Roman Zippel <[email protected]>
  */
 
+#include <sys/types.h>
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
 #include <regex.h>
-#include <sys/utsname.h>
 
 #include "lkc.h"
 
--

2.29.0

Signature · 2 lines
Best Regards
Masahiro Yamada