mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] blspec: skip entries that are not blspec entries
@ 2019-09-20 12:44 Michael Tretter
  2019-09-23  6:50 ` Sascha Hauer
  2019-09-23 18:30 ` Ahmad Fatoum
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Tretter @ 2019-09-20 12:44 UTC (permalink / raw)
  To: barebox; +Cc: Thomas Hämmerle, Michael Tretter

The list of boot entries can contain items that are not blspec entries.
For example, the bootchooser also adds an item to this list. Therefore,
blspec cannot unconditionally interpret entries as blspec entries.

The error is reproduced by listing the boot entries with the bootchooser
and a rootfs with blspec entries, e.g.:

	boot -l bootchooser /mnt/nfs

Check if a bootentry is a blspec entry by testing if the boot function
is blspec_boot.

Reported-by: Thomas Hämmerle <Thomas.Haemmerle@wolfvision.net>
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
 common/blspec.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/common/blspec.c b/common/blspec.c
index 66e5033e35..3b148e2ab4 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -228,6 +228,14 @@ static struct blspec_entry *blspec_entry_open(struct bootentries *bootentries,
 	return entry;
 }
 
+/*
+ * is_blspec_entry - check if a bootentry is a blspec entry
+ */
+static inline bool is_blspec_entry(struct bootentry *entry)
+{
+	return entry.boot == blspec_boot;
+}
+
 /*
  * blspec_have_entry - check if we already have an entry with
  *                     a certain path
@@ -238,6 +246,8 @@ static int blspec_have_entry(struct bootentries *bootentries, const char *path)
 	struct blspec_entry *e;
 
 	list_for_each_entry(be, &bootentries->entries, list) {
+		if (!is_blspec_entry(be))
+			continue;
 		e = container_of(be, struct blspec_entry, entry);
 		if (e->configpath && !strcmp(e->configpath, path))
 			return 1;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] blspec: skip entries that are not blspec entries
  2019-09-20 12:44 [PATCH] blspec: skip entries that are not blspec entries Michael Tretter
@ 2019-09-23  6:50 ` Sascha Hauer
  2019-09-23 18:30 ` Ahmad Fatoum
  1 sibling, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2019-09-23  6:50 UTC (permalink / raw)
  To: Michael Tretter; +Cc: barebox, Thomas Hämmerle

On Fri, Sep 20, 2019 at 02:44:33PM +0200, Michael Tretter wrote:
> The list of boot entries can contain items that are not blspec entries.
> For example, the bootchooser also adds an item to this list. Therefore,
> blspec cannot unconditionally interpret entries as blspec entries.
> 
> The error is reproduced by listing the boot entries with the bootchooser
> and a rootfs with blspec entries, e.g.:
> 
> 	boot -l bootchooser /mnt/nfs
> 
> Check if a bootentry is a blspec entry by testing if the boot function
> is blspec_boot.
> 
> Reported-by: Thomas Hämmerle <Thomas.Haemmerle@wolfvision.net>
> Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
> ---

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] blspec: skip entries that are not blspec entries
  2019-09-20 12:44 [PATCH] blspec: skip entries that are not blspec entries Michael Tretter
  2019-09-23  6:50 ` Sascha Hauer
@ 2019-09-23 18:30 ` Ahmad Fatoum
  2019-09-24  7:55   ` Michael Tretter
  1 sibling, 1 reply; 4+ messages in thread
From: Ahmad Fatoum @ 2019-09-23 18:30 UTC (permalink / raw)
  To: barebox, Michael Tretter

On 9/20/19 2:44 PM, Michael Tretter wrote:
> The list of boot entries can contain items that are not blspec entries.
> For example, the bootchooser also adds an item to this list. Therefore,
> blspec cannot unconditionally interpret entries as blspec entries.
> 
> The error is reproduced by listing the boot entries with the bootchooser
> and a rootfs with blspec entries, e.g.:
> 
> 	boot -l bootchooser /mnt/nfs
> 
> Check if a bootentry is a blspec entry by testing if the boot function
> is blspec_boot.
> 
> Reported-by: Thomas Hämmerle <Thomas.Haemmerle@wolfvision.net>
> Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
> ---
>  common/blspec.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/common/blspec.c b/common/blspec.c
> index 66e5033e35..3b148e2ab4 100644
> --- a/common/blspec.c
> +++ b/common/blspec.c
> @@ -228,6 +228,14 @@ static struct blspec_entry *blspec_entry_open(struct bootentries *bootentries,
>  	return entry;
>  }
>  
> +/*
> + * is_blspec_entry - check if a bootentry is a blspec entry
> + */
> +static inline bool is_blspec_entry(struct bootentry *entry)
> +{
> +	return entry.boot == blspec_boot;

entry is a pointer. This doesn't compile:

./common/blspec.c:314:14: error: 'entry' is a pointer; did you mean to use '->'?
  314 |  return entry.boot == blspec_boot;

> +}
> +
>  /*
>   * blspec_have_entry - check if we already have an entry with
>   *                     a certain path
> @@ -238,6 +246,8 @@ static int blspec_have_entry(struct bootentries *bootentries, const char *path)
>  	struct blspec_entry *e;
>  
>  	list_for_each_entry(be, &bootentries->entries, list) {
> +		if (!is_blspec_entry(be))
> +			continue;
>  		e = container_of(be, struct blspec_entry, entry);
>  		if (e->configpath && !strcmp(e->configpath, path))
>  			return 1;
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] blspec: skip entries that are not blspec entries
  2019-09-23 18:30 ` Ahmad Fatoum
@ 2019-09-24  7:55   ` Michael Tretter
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Tretter @ 2019-09-24  7:55 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

On Mon, 23 Sep 2019 20:30:35 +0200, Ahmad Fatoum wrote:
> On 9/20/19 2:44 PM, Michael Tretter wrote:
> > The list of boot entries can contain items that are not blspec entries.
> > For example, the bootchooser also adds an item to this list. Therefore,
> > blspec cannot unconditionally interpret entries as blspec entries.
> > 
> > The error is reproduced by listing the boot entries with the bootchooser
> > and a rootfs with blspec entries, e.g.:
> > 
> > 	boot -l bootchooser /mnt/nfs
> > 
> > Check if a bootentry is a blspec entry by testing if the boot function
> > is blspec_boot.
> > 
> > Reported-by: Thomas Hämmerle <Thomas.Haemmerle@wolfvision.net>
> > Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
> > ---
> >  common/blspec.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/common/blspec.c b/common/blspec.c
> > index 66e5033e35..3b148e2ab4 100644
> > --- a/common/blspec.c
> > +++ b/common/blspec.c
> > @@ -228,6 +228,14 @@ static struct blspec_entry *blspec_entry_open(struct bootentries *bootentries,
> >  	return entry;
> >  }
> >  
> > +/*
> > + * is_blspec_entry - check if a bootentry is a blspec entry
> > + */
> > +static inline bool is_blspec_entry(struct bootentry *entry)
> > +{
> > +	return entry.boot == blspec_boot;  
> 
> entry is a pointer. This doesn't compile:
> 
> ./common/blspec.c:314:14: error: 'entry' is a pointer; did you mean to use '->'?
>   314 |  return entry.boot == blspec_boot;

I am confused. I thought that I compiled and tested the patch. I will
send a v2 and try to find the problem in my process.

Michael

> 
> > +}
> > +
> >  /*
> >   * blspec_have_entry - check if we already have an entry with
> >   *                     a certain path
> > @@ -238,6 +246,8 @@ static int blspec_have_entry(struct bootentries *bootentries, const char *path)
> >  	struct blspec_entry *e;
> >  
> >  	list_for_each_entry(be, &bootentries->entries, list) {
> > +		if (!is_blspec_entry(be))
> > +			continue;
> >  		e = container_of(be, struct blspec_entry, entry);
> >  		if (e->configpath && !strcmp(e->configpath, path))
> >  			return 1;
> >   
> 

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2019-09-24  7:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-20 12:44 [PATCH] blspec: skip entries that are not blspec entries Michael Tretter
2019-09-23  6:50 ` Sascha Hauer
2019-09-23 18:30 ` Ahmad Fatoum
2019-09-24  7:55   ` Michael Tretter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox