diff mbox series

[v2] kconfig: fix failing to generate auto.conf

Message ID 20220211092736.7623-1-3090101217@zju.edu.cn (mailing list archive)
State New, archived
Headers show
Series [v2] kconfig: fix failing to generate auto.conf | expand

Commit Message

Jing Leng Feb. 11, 2022, 9:27 a.m. UTC
From: Jing Leng <jleng@ambarella.com>

When the KCONFIG_AUTOCONFIG is specified (e.g. export \
KCONFIG_AUTOCONFIG=output/config/auto.conf), the directory of
include/config/ will not be created, so kconfig can't create deps
files in it and auto.conf can't be generated.

Signed-off-by: Jing Leng <jleng@ambarella.com>
---
 scripts/kconfig/confdata.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Masahiro Yamada Feb. 12, 2022, 4:15 p.m. UTC | #1
On Fri, Feb 11, 2022 at 6:29 PM <3090101217@zju.edu.cn> wrote:
>
> From: Jing Leng <jleng@ambarella.com>
>
> When the KCONFIG_AUTOCONFIG is specified (e.g. export \
> KCONFIG_AUTOCONFIG=output/config/auto.conf), the directory of
> include/config/ will not be created, so kconfig can't create deps
> files in it and auto.conf can't be generated.
>
> Signed-off-by: Jing Leng <jleng@ambarella.com>

Applied to linux-kbuild/fixes.
Thanks.


> ---
>  scripts/kconfig/confdata.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> index 59717be31210..974a079e8901 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -994,14 +994,19 @@ static int conf_write_autoconf_cmd(const char *autoconf_name)
>
>  static int conf_touch_deps(void)
>  {
> -       const char *name;
> +       const char *name, *tmp;
>         struct symbol *sym;
>         int res, i;
>
> -       strcpy(depfile_path, "include/config/");
> -       depfile_prefix_len = strlen(depfile_path);
> -
>         name = conf_get_autoconfig_name();
> +       tmp = strrchr(name, '/');
> +       depfile_prefix_len = tmp ? (tmp - name) + 1 : 0;
> +       if (depfile_prefix_len + 1 > sizeof(depfile_path))
> +               return -1;
> +
> +       strncpy(depfile_path, name, depfile_prefix_len);
> +       depfile_path[depfile_prefix_len] = 0;
> +
>         conf_read_simple(name, S_DEF_AUTO);
>         sym_calc_value(modules_sym);
>
> --
> 2.17.1
>
diff mbox series

Patch

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 59717be31210..974a079e8901 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -994,14 +994,19 @@  static int conf_write_autoconf_cmd(const char *autoconf_name)
 
 static int conf_touch_deps(void)
 {
-	const char *name;
+	const char *name, *tmp;
 	struct symbol *sym;
 	int res, i;
 
-	strcpy(depfile_path, "include/config/");
-	depfile_prefix_len = strlen(depfile_path);
-
 	name = conf_get_autoconfig_name();
+	tmp = strrchr(name, '/');
+	depfile_prefix_len = tmp ? (tmp - name) + 1 : 0;
+	if (depfile_prefix_len + 1 > sizeof(depfile_path))
+		return -1;
+
+	strncpy(depfile_path, name, depfile_prefix_len);
+	depfile_path[depfile_prefix_len] = 0;
+
 	conf_read_simple(name, S_DEF_AUTO);
 	sym_calc_value(modules_sym);