[PATCH 1/2 v2] smbios: Simplify reporting of unknown values

Ilias Apalodimas ilias.apalodimas at linaro.org
Wed Dec 6 12:35:44 CET 2023


[...]

>
>>
>> >                 str = "Unknown";
>> >
>> >         for (;;) {
>> > @@ -151,8 +151,7 @@ static int smbios_add_prop_si(struct smbios_ctx *ctx, const char *prop,
>> >                 const char *str;
>> >
>> >                 str = ofnode_read_string(ctx->node, prop);
>> > -               if (str)
>> > -                       return smbios_add_string(ctx, str);
>> > +               return smbios_add_string(ctx, str);
>> >         }
>> >
>> >         return 0;
>> > @@ -231,7 +230,7 @@ static int smbios_write_type0(ulong *current, int handle,
>> >         t->vendor = smbios_add_string(ctx, "U-Boot");
>> >
>> >         t->bios_ver = smbios_add_prop(ctx, "version");
>> > -       if (!t->bios_ver)
>> > +       if (!strcmp(ctx->last_str, "Unknown"))
>>
>> That is really ugly...checking the ctx value looking for a side effect.
>>
>> Can you not have smbios_add_prop() continue to return NULL in this case?
>
>
> Hmm I don't know, but I wonder why I am not just checking t->bios_ver for Unknown.
> I'll have a look and change it

Ok, this can't be changed as easily.  smbios_add_prop() will not
return NULL in any case. It returns an integer. With the cleanup, it
will always writes 'Uknown' and not return 0 anymore.
I can add that default value you suggested but the ctx->last_str is
still used on the next line anyway.

Thanks
/Ilias

>
> [...]
>
> Thanks
> /Ilias


More information about the U-Boot mailing list