Re: [PATCH 1/1] x86/boot: clear some fields explicitly

From: John Hubbard
Date: Thu Jul 25 2019 - 14:03:34 EST


On 7/24/19 7:12 PM, hpa@xxxxxxxxx wrote:
On July 24, 2019 4:15:28 PM PDT, john.hubbard@xxxxxxxxx wrote:
From: John Hubbard <jhubbard@xxxxxxxxxx>
...
+ boot_params->ext_ramdisk_image = 0;
+ boot_params->ext_ramdisk_size = 0;
+ boot_params->ext_cmd_line_ptr = 0;
+
+ memset(&boot_params->_pad4, 0, sizeof(boot_params->_pad4));
memset(&boot_params->_pad7[0], 0,
(char *)&boot_params->edd_mbr_sig_buffer[0] -
(char *)&boot_params->_pad7[0]);

The problem with this is that it will break silently when changes are made to this structure.

So, that is a NAK from me.


Understood. It occurs to me, though, that it would be trivial to
just add build time assertions to check a few struct member offset
values, and fail out if they changed. That would give us everything:
warnings-free builds, and no silent failures.

Thoughts?

thanks,
--
John Hubbard
NVIDIA