[SLOF] [PATCH 1/4] romfs/tools: Remove superfluous union around the rom header struct
Thomas Huth
thuth at redhat.com
Thu Jul 19 22:18:47 AEST 2018
On 19.07.2018 11:34, Alexey Kardashevskiy wrote:
>
>
> On 19/7/18 12:35 am, Segher Boessenkool wrote:
>> On Wed, Jul 18, 2018 at 02:41:41PM +0200, Thomas Huth wrote:
>>> - union {
>>> - unsigned char pcArray[FLASHFS_HEADER_DATA_SIZE];
>>> - struct stH stHeader;
>>> - } uHeader;
>>> + struct stH stHeader;
>>> +
>>> + assert(sizeof(stHeader) == FLASHFS_HEADER_DATA_SIZE);
>>>
>>> /* initialize Header */
>>> - memset(uHeader.pcArray, 0x00, FLASHFS_HEADER_DATA_SIZE);
>>> + memset(&stHeader, 0x00, FLASHFS_HEADER_DATA_SIZE);
>>
>> It would be nice to have a build-time assert for this.
>>
>> You can also get rid of this explicit memset by doing this as
>>
>> assert(sizeof(stHeader) == FLASHFS_HEADER_DATA_SIZE);
>>
>> struct stH stHeader = { 0 } ;
>
>
> I do not really know where this flashfs/romfs format came from so I'll
> simply ask why precisely we want this assert? Increasing
> FLASHFS_HEADER_DATA_SIZE to 0x88 does not make any difference as the
> header size is stored in a file header (is that even correct thing to say?)?
Looking at the code again, I think we don't need the
FLASHFS_HEADER_DATA_SIZE macro at all anymore, so I'll remove it in v2.
Thomas
More information about the SLOF
mailing list