[Skiboot] [PATCH v2] secvar/backend: use endian-aware types in edk2.h

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Tue Jul 20 17:33:10 AEST 2021


On 6/23/21 3:11 PM, Daniel Axtens wrote:
> Recently we had an issue where we did the following:
> 
> uint16_t year = le32_to_cpu(timestamp->year);
> 
> This is wrong and will break on BE. However, we didn't catch this
> with sparse because there was a whole slew of warnings.
> 
> The reason for the slew of warnings is that we didn't annotate the
> types that store little-endian specific data in edk2.h.
> 
> Provide the appropriate annotations.
> 
> We now get a single sparse warning for the file, which correctly
> identifies the issue:
> 
> edk2-compat-process.c:374:46: warning: incorrect type in argument 1 (different base types)
> edk2-compat-process.c:374:46:    expected restricted leint32_t [usertype] le_val
> edk2-compat-process.c:374:46:    got restricted leint16_t const [usertype] year
> 
> We do lose the signedness of efi_time->timezone, but that's probably OK:
> we never use the timezone anyway and the comment above the data structure
> makes the signedness pretty clear.
> 
> Signed-off-by: Daniel Axtens <dja at axtens.net>

Thanks! Merged to master as d722dc185.

-Vasant




More information about the Skiboot mailing list