[PATCH 2/5] blspec: sort entries according to specification

Ahmad Fatoum a.fatoum at barebox.org
Mon Feb 23 03:08:42 PST 2026


Hello Sascha,

On 2/23/26 12:06 PM, Sascha Hauer wrote:
> On Mon, Feb 09, 2026 at 10:08:52AM +0100, Ahmad Fatoum wrote:

>> +static int blspec_compare(struct list_head *list_a, struct list_head *list_b)
>> +{
>> +	struct bootentry *be_a = container_of(list_a, struct bootentry, list);
>> +	struct bootentry *be_b = container_of(list_b, struct bootentry, list);
>> +	struct blspec_entry *a, *b;
>> +	const char *a_version, *b_version;
>> +	int r;
>> +
>> +	/* The boot entry providers are called one by one and passed an empty
>> +	 * list that's aggregated later, so we should only be encountering
>> +	 * bootloader spec entries here.
>> +	 */
>> +	DEBUG_ASSERT(is_blspec_entry(be_a) && is_blspec_entry(be_b));

[sni[]

>> +
>> +#ifdef DEBUG
>> +#define DEBUG_ASSERT(expr)	BUG_ON(!(expr))
>> +#else
>> +#define DEBUG_ASSERT(expr)	((void)(expr))
>> +#endif
> 
> Is this change intentional here?

Yes, DEBUG_ASSERT is used within this patch.

Cheers,
Ahmad

> 
> Sascha
> 
>> +
>>  #endif
>> diff --git a/include/boot.h b/include/boot.h
>> index e6309b65a0c3..fdc108b7a21d 100644
>> --- a/include/boot.h
>> +++ b/include/boot.h
>> @@ -24,6 +24,8 @@ struct bootentry {
>>  };
>>  
>>  int bootentries_add_entry(struct bootentries *entries, struct bootentry *entry);
>> +void bootentries_add_entry_sorted(struct bootentries *entries, struct bootentry *entry,
>> +				  int (*compare)(struct list_head *, struct list_head *));
>>  
>>  struct bootentry_provider {
>>  	const char *name;
>> -- 
>> 2.47.3
>>
>>
>>
> 




More information about the barebox mailing list