diff mbox series

[2/2] kconfig: clean up header inclusion

Message ID 20201029155152.2467-3-boris@codesynthesis.com (mailing list archive)
State New, archived
Headers show
Series kconfig: header inclusion cleanups | expand

Commit Message

Boris Kolpackov Oct. 29, 2020, 3:51 p.m. UTC
- Add missing includes.
- Remove no longer necessary includes.
- Separate non-portable header includes for easier porting.

Signed-off-by: Boris Kolpackov <boris@codesynthesis.com>
---
 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(-)

Comments

Masahiro Yamada Nov. 2, 2020, 4:27 a.m. UTC | #1
On Fri, Oct 30, 2020 at 12:52 AM Boris Kolpackov
<boris@codesynthesis.com> wrote:
>
> - 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?


>
> Signed-off-by: Boris Kolpackov <boris@codesynthesis.com>
> ---
>  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(-)
>
> diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
> index f6e548b..74974df 100644
> --- a/scripts/kconfig/conf.c
> +++ b/scripts/kconfig/conf.c
> @@ -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);
> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> index a39d93e..64344b9 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -3,7 +3,7 @@
>   * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
>   */
>
> -#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"
>
> diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l
> index 240109f..9c22cb5 100644
> --- a/scripts/kconfig/lexer.l
> +++ b/scripts/kconfig/lexer.l
> @@ -12,7 +12,6 @@
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
> -#include <unistd.h>
>
>  #include "lkc.h"
>  #include "parser.tab.h"
> diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
> index ffa3ec6..0e0f1cc 100644
> --- a/scripts/kconfig/symbol.c
> +++ b/scripts/kconfig/symbol.c
> @@ -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
>
Boris Kolpackov Nov. 2, 2020, 2:32 p.m. UTC | #2
Masahiro Yamada <masahiroy@kernel.org> writes:

> On Fri, Oct 30, 2020 at 12:52 AM Boris Kolpackov
> <boris@codesynthesis.com> wrote:
> >
> > - 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?

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.
Masahiro Yamada Nov. 23, 2020, 5:19 a.m. UTC | #3
On Mon, Nov 2, 2020 at 11:32 PM Boris Kolpackov <boris@codesynthesis.com> wrote:
>
> Masahiro Yamada <masahiroy@kernel.org> writes:
>
> > On Fri, Oct 30, 2020 at 12:52 AM Boris Kolpackov
> > <boris@codesynthesis.com> wrote:
> > >
> > > - 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?
>
> 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.



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.
diff mbox series

Patch

diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index f6e548b..74974df 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -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);
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index a39d93e..64344b9 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -3,7 +3,7 @@ 
  * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
  */
 
-#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"
 
diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l
index 240109f..9c22cb5 100644
--- a/scripts/kconfig/lexer.l
+++ b/scripts/kconfig/lexer.l
@@ -12,7 +12,6 @@ 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
 #include "lkc.h"
 #include "parser.tab.h"
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index ffa3ec6..0e0f1cc 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -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"