All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@kernel.org>,
	Kyungsik Lee <kyungsik.lee@lge.com>,
	Michal Marek <mmarek@suse.cz>,
	linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
	x86@kernel.org, celinux-dev@lists.celinuxforum.org,
	linux-arm-kernel@lists.infradead.org, hyojun.im@lge.com,
	chan.jeong@lge.com, raphael.andy.lee@gmail.com,
	Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
	Russell King <rmk@arm.linux.org.uk>,
	Borislav Petkov <bp@alien8.de>,
	Florian Fainelli <florian@openwrt.org>,
	Yann Collet <yann.collet.73@gmail.com>,
	Chanho Min <chanho.min@lge.com>
Subject: Re: [PATCH -next 2/2] kbuild: fix for updated LZ4 tool with the new streaming format
Date: Thu, 18 Jul 2013 00:30:33 +0200	[thread overview]
Message-ID: <20130717223033.GF3385@free.fr> (raw)
In-Reply-To: <20130717211649.GA5619@merkur.ravnborg.org>

Sam, All,

Well, while I was fighting on this on my side... ;-)

On 2013-07-17 23:16 +0200, Sam Ravnborg spake thusly:
> > We could extend the symbol option part to retreive values from a binary.
> > Something like this:
> > 
> > config FOOBAR
> >         bool
> >         option exec="true"
> > 
> > FOOBAR would assume the value "y" if the command true has exit code == 0, otherwise "n".
> > And similar conversions for other types.
> > 
> > This only extendt Kconfig slightly - using an already present method to import
> > external values.
> > 
> > The drawback I see with this approach is that we may execute a lot of small programs
> > where the value is never used.
> 
> Following is a quick patch implmenting this idea.
> You need to run gperf manually to enable this.
> 
> "gperf -C scripts/kconfig/zconf.gperf > scripts/kconfig/zconf.hash.c"
> 
> I did not figure out how to use the built-in rules to generate this file :-(

make REGENERATE_PARSERS=y menuconfig

> I have tested this lightly - as we should discuss if this is a viable way forward.

Instead of extending the Kconfig language, I was thinking (as initially
suggested by Andrew) of generating a Kconfig file before all config
targets, and source that Kconfig file from $(TOPDIR)/Kconfig.

I'm not a fan od extending the Kconfig language in this way. It feels
weird to me. Especially when we have a way to solve this specific issue
with a script that generates the needed Kconfig symbols before any
config target is called.

At the very least we'd have to decide if this is available only for
booleans/tristates, or for any type? Your implementation seems to make
it valid for strings/ints, too.

> For now I used popen() - so return value of the executed program are ignored.

Yet, pclose returns the exit status of the command.

If option exec was to be valid only for booleans, we could use the exit
value rather than the output, which would seem more logical. It would be
however a bit moretriclky for tristates, though...

Maybe using output is the best, after all...

So, how do you expect we use that to check for an external tool?
Something like this?
    config HAVE_LZ4
        bool
        option exec="which lz4c >/dev/null 2>&1 && echo y"

    config KERNEL_LZ4
        bool "compress the kernel with lz4"
        depends on HAVE_LZ4

Ot did I miss something?

> diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
> index d550300..b7179a6 100644
> --- a/scripts/kconfig/symbol.c
> +++ b/scripts/kconfig/symbol.c
[--SNIP--]
> @@ -1379,3 +1381,56 @@ static void prop_add_env(const char *env)
>  	else
>  		menu_warn(current_entry, "environment variable %s undefined", env);
>  }
> +
> +static void exec_command(const char *command, struct symbol *sym)
> +{
> +	char buffer[2048];
> +	FILE *stream;
> +
> +	stream = popen(command, "r");
> +
> +	if (stream != NULL) {
> +		if (fgets(buffer, sizeof(buffer), stream) != NULL) {
> +			int i;
> +
> +			buffer[sizeof(buffer) - 1] = '\0';
> +
> +			/* Drop any trialing newlines */
> +			i = strlen(buffer);
> +			while (i > 0 && buffer[i - 1] == '\n') {
> +				buffer[i - 1] = '\0';
> +				i--;
> +			}
> +			/* Validate the output of the command */
> +			if (strlen(buffer) == 0) {
> +				menu_warn(current_entry,
> +				          "command '%s' - invalid (empty?) return value: \"%s\"",
> +				          command, buffer);
> +				return;

Missing pclose() before return.

[--SNIP--]

I'll give it a spin here. Thank you!

BTW, I still need your help on solving that one:
    randconfig does randomise choice entries, unless KCONFIG_ALLCONFIG
    is specified.
    http://marc.info/?l=linux-kernel&m=137209757414433&w=2

My two previous attempts failed due to introducing regressions, so they
were both reverted... :-(
Any suggestion? ;-)

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

WARNING: multiple messages have this Message-ID
From: yann.morin.1998@free.fr (Yann E. MORIN)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH -next 2/2] kbuild: fix for updated LZ4 tool with the new streaming format
Date: Thu, 18 Jul 2013 00:30:33 +0200	[thread overview]
Message-ID: <20130717223033.GF3385@free.fr> (raw)
In-Reply-To: <20130717211649.GA5619@merkur.ravnborg.org>

Sam, All,

Well, while I was fighting on this on my side... ;-)

On 2013-07-17 23:16 +0200, Sam Ravnborg spake thusly:
> > We could extend the symbol option part to retreive values from a binary.
> > Something like this:
> > 
> > config FOOBAR
> >         bool
> >         option exec="true"
> > 
> > FOOBAR would assume the value "y" if the command true has exit code == 0, otherwise "n".
> > And similar conversions for other types.
> > 
> > This only extendt Kconfig slightly - using an already present method to import
> > external values.
> > 
> > The drawback I see with this approach is that we may execute a lot of small programs
> > where the value is never used.
> 
> Following is a quick patch implmenting this idea.
> You need to run gperf manually to enable this.
> 
> "gperf -C scripts/kconfig/zconf.gperf > scripts/kconfig/zconf.hash.c"
> 
> I did not figure out how to use the built-in rules to generate this file :-(

make REGENERATE_PARSERS=y menuconfig

> I have tested this lightly - as we should discuss if this is a viable way forward.

Instead of extending the Kconfig language, I was thinking (as initially
suggested by Andrew) of generating a Kconfig file before all config
targets, and source that Kconfig file from $(TOPDIR)/Kconfig.

I'm not a fan od extending the Kconfig language in this way. It feels
weird to me. Especially when we have a way to solve this specific issue
with a script that generates the needed Kconfig symbols before any
config target is called.

At the very least we'd have to decide if this is available only for
booleans/tristates, or for any type? Your implementation seems to make
it valid for strings/ints, too.

> For now I used popen() - so return value of the executed program are ignored.

Yet, pclose returns the exit status of the command.

If option exec was to be valid only for booleans, we could use the exit
value rather than the output, which would seem more logical. It would be
however a bit moretriclky for tristates, though...

Maybe using output is the best, after all...

So, how do you expect we use that to check for an external tool?
Something like this?
    config HAVE_LZ4
        bool
        option exec="which lz4c >/dev/null 2>&1 && echo y"

    config KERNEL_LZ4
        bool "compress the kernel with lz4"
        depends on HAVE_LZ4

Ot did I miss something?

> diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
> index d550300..b7179a6 100644
> --- a/scripts/kconfig/symbol.c
> +++ b/scripts/kconfig/symbol.c
[--SNIP--]
> @@ -1379,3 +1381,56 @@ static void prop_add_env(const char *env)
>  	else
>  		menu_warn(current_entry, "environment variable %s undefined", env);
>  }
> +
> +static void exec_command(const char *command, struct symbol *sym)
> +{
> +	char buffer[2048];
> +	FILE *stream;
> +
> +	stream = popen(command, "r");
> +
> +	if (stream != NULL) {
> +		if (fgets(buffer, sizeof(buffer), stream) != NULL) {
> +			int i;
> +
> +			buffer[sizeof(buffer) - 1] = '\0';
> +
> +			/* Drop any trialing newlines */
> +			i = strlen(buffer);
> +			while (i > 0 && buffer[i - 1] == '\n') {
> +				buffer[i - 1] = '\0';
> +				i--;
> +			}
> +			/* Validate the output of the command */
> +			if (strlen(buffer) == 0) {
> +				menu_warn(current_entry,
> +				          "command '%s' - invalid (empty?) return value: \"%s\"",
> +				          command, buffer);
> +				return;

Missing pclose() before return.

[--SNIP--]

I'll give it a spin here. Thank you!

BTW, I still need your help on solving that one:
    randconfig does randomise choice entries, unless KCONFIG_ALLCONFIG
    is specified.
    http://marc.info/?l=linux-kernel&m=137209757414433&w=2

My two previous attempts failed due to introducing regressions, so they
were both reverted... :-(
Any suggestion? ;-)

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

  parent reply	other threads:[~2013-07-17 22:30 UTC|newest]

Thread overview: 110+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-06  8:42 [PATCH -next 1/2] arm: Remove enforced Os flag for LZ4 decompressor Kyungsik Lee
2013-05-06  8:42 ` Kyungsik Lee
2013-05-06  8:42 ` [PATCH -next 2/2] kbuild: fix for updated LZ4 tool with the new streaming format Kyungsik Lee
2013-05-06  8:42   ` Kyungsik Lee
2013-05-06  9:51   ` Borislav Petkov
2013-05-06  9:51     ` Borislav Petkov
2013-07-10  8:12     ` Geert Uytterhoeven
2013-07-10  8:12       ` Geert Uytterhoeven
2013-07-10  8:12       ` Geert Uytterhoeven
2013-07-10  9:36       ` Borislav Petkov
2013-07-10  9:36         ` Borislav Petkov
2013-07-10  9:36         ` Borislav Petkov
2013-07-10 18:28         ` Markus Trippelsdorf
2013-07-10 18:28           ` Markus Trippelsdorf
2013-07-10 18:28           ` Markus Trippelsdorf
2013-07-10 18:28           ` Markus Trippelsdorf
2013-07-10 20:01           ` Borislav Petkov
2013-07-10 20:01             ` Borislav Petkov
2013-07-10 20:01             ` Borislav Petkov
2013-07-10 20:01             ` Borislav Petkov
2013-07-11  4:34           ` Kyungsik Lee
2013-07-11  4:34             ` Kyungsik Lee
2013-07-11  4:34             ` Kyungsik Lee
2013-07-11  4:34             ` Kyungsik Lee
2013-07-11  9:46             ` [PATCH] .gitignore: ignore *.lz4 files Markus Trippelsdorf
2013-07-11  9:46               ` Markus Trippelsdorf
2013-07-11  9:46               ` Markus Trippelsdorf
2013-07-11  9:46               ` Markus Trippelsdorf
2013-07-12  7:56   ` [PATCH -next 2/2] kbuild: fix for updated LZ4 tool with the new streaming format Ingo Molnar
2013-07-12  7:56     ` Ingo Molnar
2013-07-12  8:01     ` Borislav Petkov
2013-07-12  8:01       ` Borislav Petkov
2013-07-12 10:13       ` Ingo Molnar
2013-07-12 10:13         ` Ingo Molnar
2013-07-12 10:23         ` Borislav Petkov
2013-07-12 10:23           ` Borislav Petkov
2013-07-12 11:18           ` Andrew Morton
2013-07-12 11:18             ` Andrew Morton
2013-07-12 12:06             ` Ingo Molnar
2013-07-12 12:06               ` Ingo Molnar
2013-07-12 12:13             ` Borislav Petkov
2013-07-12 12:13               ` Borislav Petkov
2013-07-12 12:34               ` Florian Fainelli
2013-07-12 12:34                 ` Florian Fainelli
2013-07-12 12:34                 ` Florian Fainelli
2013-07-12 12:46                 ` Borislav Petkov
2013-07-12 12:46                   ` Borislav Petkov
2013-07-12 12:46                   ` Borislav Petkov
2013-07-15 22:03     ` Andrew Morton
2013-07-15 22:03       ` Andrew Morton
2013-07-15 22:08       ` H. Peter Anvin
2013-07-15 22:08         ` H. Peter Anvin
2013-07-16  7:47         ` Andrew Morton
2013-07-16  7:47           ` Andrew Morton
2013-07-16  7:56           ` Andrew Morton
2013-07-16  7:56             ` Andrew Morton
2013-07-16  8:08             ` Yann E. MORIN
2013-07-16  8:08               ` Yann E. MORIN
2013-07-16  8:27               ` Andrew Morton
2013-07-16  8:27                 ` Andrew Morton
2013-07-16  9:05                 ` Borislav Petkov
2013-07-16  9:05                   ` Borislav Petkov
2013-07-16  9:12                   ` Yann E. MORIN
2013-07-16  9:12                     ` Yann E. MORIN
2013-07-16  9:22                     ` Borislav Petkov
2013-07-16  9:22                       ` Borislav Petkov
2013-07-16  9:32                       ` Yann E. MORIN
2013-07-16  9:32                         ` Yann E. MORIN
2013-07-16  9:38                         ` Borislav Petkov
2013-07-16  9:38                           ` Borislav Petkov
2013-07-16  9:45                           ` Yann E. MORIN
2013-07-16  9:45                             ` Yann E. MORIN
2013-07-16  9:59                             ` Borislav Petkov
2013-07-16  9:59                               ` Borislav Petkov
2013-07-16 10:04                               ` Florian Fainelli
2013-07-16 10:04                                 ` Florian Fainelli
2013-07-16 10:04                                 ` Florian Fainelli
2013-07-16 18:04               ` Sam Ravnborg
2013-07-16 18:04                 ` Sam Ravnborg
2013-07-17 21:16                 ` Sam Ravnborg
2013-07-17 21:16                   ` Sam Ravnborg
2013-07-17 21:44                   ` Borislav Petkov
2013-07-17 21:44                     ` Borislav Petkov
2013-07-17 22:30                   ` Yann E. MORIN [this message]
2013-07-17 22:30                     ` Yann E. MORIN
2013-07-17 23:22                     ` H. Peter Anvin
2013-07-17 23:22                       ` H. Peter Anvin
2013-07-18  8:02                       ` Geert Uytterhoeven
2013-07-18  8:02                         ` Geert Uytterhoeven
2013-07-18  8:02                         ` Geert Uytterhoeven
2013-07-18  7:22                     ` Geert Uytterhoeven
2013-07-18  7:22                       ` Geert Uytterhoeven
2013-07-18  7:22                       ` Geert Uytterhoeven
2013-07-18  7:34                       ` Andrew Morton
2013-07-18  7:34                         ` Andrew Morton
2013-07-18  7:34                         ` Andrew Morton
2013-07-18  7:47                         ` Yann E. MORIN
2013-07-18  7:47                           ` Yann E. MORIN
2013-07-18  7:47                           ` Yann E. MORIN
2013-07-18  7:52                           ` Andrew Morton
2013-07-18  7:52                             ` Andrew Morton
2013-07-18  7:52                             ` Andrew Morton
2013-07-18 20:47                     ` Sam Ravnborg
2013-07-18 20:47                       ` Sam Ravnborg
2013-07-16  9:13             ` Florian Fainelli
2013-07-16  9:13               ` Florian Fainelli
2013-07-16  9:13               ` Florian Fainelli
2013-07-16  9:25               ` Yann E. MORIN
2013-07-16  9:25                 ` Yann E. MORIN
2013-07-16  9:25                 ` Yann E. MORIN

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130717223033.GF3385@free.fr \
    --to=yann.morin.1998@free.fr \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=celinux-dev@lists.celinuxforum.org \
    --cc=chan.jeong@lge.com \
    --cc=chanho.min@lge.com \
    --cc=florian@openwrt.org \
    --cc=hpa@zytor.com \
    --cc=hyojun.im@lge.com \
    --cc=kyungsik.lee@lge.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@kernel.org \
    --cc=mmarek@suse.cz \
    --cc=raphael.andy.lee@gmail.com \
    --cc=rmk@arm.linux.org.uk \
    --cc=sam@ravnborg.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yann.collet.73@gmail.com \
    --subject='Re: [PATCH -next 2/2] kbuild: fix for updated LZ4 tool with the new streaming format' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.