linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bootconfig: Fix missing return check of xbc_node_compose_key function
@ 2021-08-31  3:32 Julio Faracco
  2021-08-31  7:40 ` Masami Hiramatsu
  0 siblings, 1 reply; 3+ messages in thread
From: Julio Faracco @ 2021-08-31  3:32 UTC (permalink / raw)
  To: mhiramat; +Cc: rostedt, mingo, linux-kernel

The function `xbc_show_list should` handle the keys during the
composition. Even the errors returned by the compose function. Instead
of removing the `ret` variable, it should save the value and show the
exact error. This missing variable is causing a compilation issue also.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
---
 tools/bootconfig/main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
index f45fa992e01d..fd67496a947f 100644
--- a/tools/bootconfig/main.c
+++ b/tools/bootconfig/main.c
@@ -111,9 +111,11 @@ static void xbc_show_list(void)
 	char key[XBC_KEYLEN_MAX];
 	struct xbc_node *leaf;
 	const char *val;
+	int ret;
 
 	xbc_for_each_key_value(leaf, val) {
-		if (xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX) < 0) {
+		ret = xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX);
+		if (ret < 0) {
 			fprintf(stderr, "Failed to compose key %d\n", ret);
 			break;
 		}
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] bootconfig: Fix missing return check of xbc_node_compose_key function
  2021-08-31  3:32 [PATCH] bootconfig: Fix missing return check of xbc_node_compose_key function Julio Faracco
@ 2021-08-31  7:40 ` Masami Hiramatsu
  2021-08-31  8:04   ` Masami Hiramatsu
  0 siblings, 1 reply; 3+ messages in thread
From: Masami Hiramatsu @ 2021-08-31  7:40 UTC (permalink / raw)
  To: Julio Faracco; +Cc: rostedt, mingo, linux-kernel

On Tue, 31 Aug 2021 00:32:56 -0300
Julio Faracco <jcfaracco@gmail.com> wrote:

> The function `xbc_show_list should` handle the keys during the
> composition. Even the errors returned by the compose function. Instead
> of removing the `ret` variable, it should save the value and show the
> exact error. This missing variable is causing a compilation issue also.
> 

Oops, good catch! Hmm, I missed some intermediate patch for some commit.
Let me check.

Thanks,

> Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
> ---
>  tools/bootconfig/main.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
> index f45fa992e01d..fd67496a947f 100644
> --- a/tools/bootconfig/main.c
> +++ b/tools/bootconfig/main.c
> @@ -111,9 +111,11 @@ static void xbc_show_list(void)
>  	char key[XBC_KEYLEN_MAX];
>  	struct xbc_node *leaf;
>  	const char *val;
> +	int ret;
>  
>  	xbc_for_each_key_value(leaf, val) {
> -		if (xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX) < 0) {
> +		ret = xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX);
> +		if (ret < 0) {
>  			fprintf(stderr, "Failed to compose key %d\n", ret);
>  			break;
>  		}
> -- 
> 2.31.1
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] bootconfig: Fix missing return check of xbc_node_compose_key function
  2021-08-31  7:40 ` Masami Hiramatsu
@ 2021-08-31  8:04   ` Masami Hiramatsu
  0 siblings, 0 replies; 3+ messages in thread
From: Masami Hiramatsu @ 2021-08-31  8:04 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: Julio Faracco, rostedt, mingo, linux-kernel

Hi,

On Tue, 31 Aug 2021 16:40:46 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> On Tue, 31 Aug 2021 00:32:56 -0300
> Julio Faracco <jcfaracco@gmail.com> wrote:
> 
> > The function `xbc_show_list should` handle the keys during the
> > composition. Even the errors returned by the compose function. Instead
> > of removing the `ret` variable, it should save the value and show the
> > exact error. This missing variable is causing a compilation issue also.
> > 
> 
> Oops, good catch! Hmm, I missed some intermediate patch for some commit.
> Let me check.

OK, I found this is a bug introduced when mergeing the patch.

This bug has been introduced by
[1] commit e5efaeb8a8f5 ("bootconfig: Support mixing a value and subkeys under a key")

However the original post of the patch (Linked from the above commit)

https://lkml.kernel.org/r/162262194685.264090.7738574774030567419.stgit@devnote2

seems correct, because 'ret' local variable exists in xbc_show_list().
However, this 'ret' has been removed in Apr, by 

[2] commit 30d103f2d460 ("tools/bootconfig: Simplify expression")

So I think it is merge timing issue... When I wrote [1], [2] was not
on my working tree (I forgot it, sorry). But when we merge [1], 
[2] was Steve's tree, and caused this issue.

Anyway, thank you for reporting!

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Fixes: e5efaeb8a8f5 ("bootconfig: Support mixing a value and subkeys under a key")
Cc: stable@vgar.kernel.org

Thank you!

> 
> > Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
> > ---
> >  tools/bootconfig/main.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c
> > index f45fa992e01d..fd67496a947f 100644
> > --- a/tools/bootconfig/main.c
> > +++ b/tools/bootconfig/main.c
> > @@ -111,9 +111,11 @@ static void xbc_show_list(void)
> >  	char key[XBC_KEYLEN_MAX];
> >  	struct xbc_node *leaf;
> >  	const char *val;
> > +	int ret;
> >  
> >  	xbc_for_each_key_value(leaf, val) {
> > -		if (xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX) < 0) {
> > +		ret = xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX);
> > +		if (ret < 0) {
> >  			fprintf(stderr, "Failed to compose key %d\n", ret);
> >  			break;
> >  		}
> > -- 
> > 2.31.1
> > 
> 
> 
> -- 
> Masami Hiramatsu <mhiramat@kernel.org>


-- 
Masami Hiramatsu <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-31  8:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31  3:32 [PATCH] bootconfig: Fix missing return check of xbc_node_compose_key function Julio Faracco
2021-08-31  7:40 ` Masami Hiramatsu
2021-08-31  8:04   ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).