diff mbox series

[1/1] smbios: amend the description of smbios_string()

Message ID 20211021091631.13500-1-heinrich.schuchardt@canonical.com
State Rejected, archived
Delegated to: Heinrich Schuchardt
Headers show
Series [1/1] smbios: amend the description of smbios_string() | expand

Commit Message

Heinrich Schuchardt Oct. 21, 2021, 9:16 a.m. UTC
Add a warning that this function only works for strings preceding the first
non-string field.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 include/smbios.h | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Simon Glass Oct. 24, 2021, 7:54 p.m. UTC | #1
Hi Heinrich,

On Thu, 21 Oct 2021 at 03:16, Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> Add a warning that this function only works for strings preceding the first
> non-string field.

What is a non-string field? If you mean an int field, for example,
then that would not have an entry in the string table, so I'm a bit
unsure about what exactly the problem is?

Regards,
Simon


>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
>  include/smbios.h | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/include/smbios.h b/include/smbios.h
> index aa6b6f3849..b7a1b8e412 100644
> --- a/include/smbios.h
> +++ b/include/smbios.h
> @@ -258,6 +258,10 @@ const struct smbios_header *smbios_header(const struct smbios_entry *entry, int
>  /**
>   * smbios_string() - Return string from SMBIOS
>   *
> + * This function counts the zero bytes at the end of strings to identify the
> + * string to retrieve. This only works up to the first non-string field in the
> + * table.
> + *
>   * @header:    pointer to struct smbios_header
>   * @index:     string index
>   * @return:    NULL or a valid const char pointer
> --
> 2.32.0
>
Heinrich Schuchardt Oct. 25, 2021, 7:26 a.m. UTC | #2
On 10/24/21 21:54, Simon Glass wrote:
> Hi Heinrich,
> 
> On Thu, 21 Oct 2021 at 03:16, Heinrich Schuchardt
> <heinrich.schuchardt@canonical.com> wrote:
>>
>> Add a warning that this function only works for strings preceding the first
>> non-string field.
> 
> What is a non-string field? If you mean an int field, for example,
> then that would not have an entry in the string table, so I'm a bit
> unsure about what exactly the problem is?

https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.4.0.pdf
Table 6 – BIOS Information (Type 0) structure

"Vendor", "BIOS Version" are strings.
The are followed by "BIOS Starting Address Segment" is a word which may 
contain a zero byte or not.

You can not use smbios_string() to find the string "BIOS Release Date".

Best regards

Heinrich

> 
> Regards,
> Simon
> 
> 
>>
>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
>> ---
>>   include/smbios.h | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/include/smbios.h b/include/smbios.h
>> index aa6b6f3849..b7a1b8e412 100644
>> --- a/include/smbios.h
>> +++ b/include/smbios.h
>> @@ -258,6 +258,10 @@ const struct smbios_header *smbios_header(const struct smbios_entry *entry, int
>>   /**
>>    * smbios_string() - Return string from SMBIOS
>>    *
>> + * This function counts the zero bytes at the end of strings to identify the
>> + * string to retrieve. This only works up to the first non-string field in the
>> + * table.
>> + *
>>    * @header:    pointer to struct smbios_header
>>    * @index:     string index
>>    * @return:    NULL or a valid const char pointer
>> --
>> 2.32.0
>>
Simon Glass Oct. 25, 2021, 3:18 p.m. UTC | #3
Hi Heinrich,

On Mon, 25 Oct 2021 at 01:26, Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> On 10/24/21 21:54, Simon Glass wrote:
> > Hi Heinrich,
> >
> > On Thu, 21 Oct 2021 at 03:16, Heinrich Schuchardt
> > <heinrich.schuchardt@canonical.com> wrote:
> >>
> >> Add a warning that this function only works for strings preceding the first
> >> non-string field.
> >
> > What is a non-string field? If you mean an int field, for example,
> > then that would not have an entry in the string table, so I'm a bit
> > unsure about what exactly the problem is?
>
> https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.4.0.pdf
> Table 6 – BIOS Information (Type 0) structure
>
> "Vendor", "BIOS Version" are strings.
> The are followed by "BIOS Starting Address Segment" is a word which may
> contain a zero byte or not.
>
> You can not use smbios_string() to find the string "BIOS Release Date".

I'm still lost...what does this have to do with the string table? As I
understand it, in the archaic format for SMBIOS, type 0 can have
entries in the string table for:

vendor (string 1)
bios version (2)
bios release (3)

So if you want those you have a string table like:

my_vendor\0my_bios_v\0my_release\0\0

?

Regards,
SImon


> >>
> >> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> >> ---
> >>   include/smbios.h | 4 ++++
> >>   1 file changed, 4 insertions(+)
> >>
> >> diff --git a/include/smbios.h b/include/smbios.h
> >> index aa6b6f3849..b7a1b8e412 100644
> >> --- a/include/smbios.h
> >> +++ b/include/smbios.h
> >> @@ -258,6 +258,10 @@ const struct smbios_header *smbios_header(const struct smbios_entry *entry, int
> >>   /**
> >>    * smbios_string() - Return string from SMBIOS
> >>    *
> >> + * This function counts the zero bytes at the end of strings to identify the
> >> + * string to retrieve. This only works up to the first non-string field in the
> >> + * table.
> >> + *
> >>    * @header:    pointer to struct smbios_header
> >>    * @index:     string index
> >>    * @return:    NULL or a valid const char pointer
> >> --
> >> 2.32.0
> >>
>
diff mbox series

Patch

diff --git a/include/smbios.h b/include/smbios.h
index aa6b6f3849..b7a1b8e412 100644
--- a/include/smbios.h
+++ b/include/smbios.h
@@ -258,6 +258,10 @@  const struct smbios_header *smbios_header(const struct smbios_entry *entry, int
 /**
  * smbios_string() - Return string from SMBIOS
  *
+ * This function counts the zero bytes at the end of strings to identify the
+ * string to retrieve. This only works up to the first non-string field in the
+ * table.
+ *
  * @header:    pointer to struct smbios_header
  * @index:     string index
  * @return:    NULL or a valid const char pointer