[5/6] kconfig: require an exact match for "is not set" to disable CONFIG option

Message ID 20231118075912.1303509-5-masahiroy@kernel.org
State New
Headers
Series [1/6] kconfig: require a space after '#' for valid input |

Commit Message

Masahiro Yamada Nov. 18, 2023, 7:59 a.m. UTC
  Currently, any string starting "is not set" disables a CONFIG option.

For example, "# CONFIG_FOO is not settled down" is accepted as valid
input, functioning the same as "# CONFIG_FOO is not set". It is a
long-standing oddity.

Check the line against the exact pattern "is not set".

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/kconfig/confdata.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Randy Dunlap Nov. 18, 2023, 4:30 p.m. UTC | #1
Hi,

On 11/17/23 23:59, Masahiro Yamada wrote:
> Currently, any string starting "is not set" disables a CONFIG option.
> 
> For example, "# CONFIG_FOO is not settled down" is accepted as valid
> input, functioning the same as "# CONFIG_FOO is not set". It is a
> long-standing oddity.
> 
> Check the line against the exact pattern "is not set".
> 

Just to confirm (I hope), using:
CONFIG_FOO=n

will also still work to disable that config option?

Thanks.

> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  scripts/kconfig/confdata.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> index 795ac6c9378f..958be12cd621 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -454,7 +454,7 @@ int conf_read_simple(const char *name, int def)
>  			if (!p)
>  				continue;
>  			*p++ = 0;
> -			if (strncmp(p, "is not set", 10))
> +			if (strcmp(p, "is not set"))
>  				continue;
>  
>  			val = "n";
  
Masahiro Yamada Nov. 19, 2023, 10:02 a.m. UTC | #2
On Sun, Nov 19, 2023 at 1:30 AM Randy Dunlap <rdunlap@infradead.org> wrote:
>
> Hi,
>
> On 11/17/23 23:59, Masahiro Yamada wrote:
> > Currently, any string starting "is not set" disables a CONFIG option.
> >
> > For example, "# CONFIG_FOO is not settled down" is accepted as valid
> > input, functioning the same as "# CONFIG_FOO is not set". It is a
> > long-standing oddity.
> >
> > Check the line against the exact pattern "is not set".
> >
>
> Just to confirm (I hope), using:
> CONFIG_FOO=n
>
> will also still work to disable that config option?



Yes.  =n is still supported.


The code diff is
strncmp() -> strcmp().






> Thanks.
>
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> >  scripts/kconfig/confdata.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> > index 795ac6c9378f..958be12cd621 100644
> > --- a/scripts/kconfig/confdata.c
> > +++ b/scripts/kconfig/confdata.c
> > @@ -454,7 +454,7 @@ int conf_read_simple(const char *name, int def)
> >                       if (!p)
> >                               continue;
> >                       *p++ = 0;
> > -                     if (strncmp(p, "is not set", 10))
> > +                     if (strcmp(p, "is not set"))
> >                               continue;
> >
> >                       val = "n";
>
> --
> ~Randy
  

Patch

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 795ac6c9378f..958be12cd621 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -454,7 +454,7 @@  int conf_read_simple(const char *name, int def)
 			if (!p)
 				continue;
 			*p++ = 0;
-			if (strncmp(p, "is not set", 10))
+			if (strcmp(p, "is not set"))
 				continue;
 
 			val = "n";