[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/6] commands/i386/pc/sendkey: Fix "writing 1 byte into a reg
From: |
Toomas Soome |
Subject: |
Re: [PATCH 3/6] commands/i386/pc/sendkey: Fix "writing 1 byte into a region of size 0" build error |
Date: |
Fri, 11 Mar 2022 19:23:12 +0200 |
> On 11. Mar 2022, at 19:10, Glenn Washburn <development@efficientek.com> wrote:
>
> On Fri, 11 Mar 2022 00:35:57 +0100
> Daniel Kiper <daniel.kiper@oracle.com> wrote:
>
>> Latest GCC may complain in that way:
>>
>> commands/i386/pc/sendkey.c: In function ‘grub_sendkey_postboot’:
>> commands/i386/pc/sendkey.c:223:21: error: writing 1 byte into a region of
>> size 0 [-Werror=stringop-overflow=]
>> 223 | *((char *) 0x41a) = 0x1e;
>> | ~~~~~~~~~~~~~~~~~~^~~~~~
>
> I'm curious why I'm not seeing this. It looks like the target was
> i386-pc, correct? I'm guessing this is on GCC11. What compiler are you
> using? Any extra CFLAGS? Anything else I might need to reproduce?
>
> Glenn
gcc 11 can report those, I have used workaround of assigning address to
variable. It is interesting that volatile qualifier can pacify it too.
Rgds,
Toomas
>
>>
>> The volatile keyword addition helps and additionally assures us the
>> compiler will not optimize out fixed assignments.
>>
>> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
>> ---
>> grub-core/commands/i386/pc/sendkey.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/grub-core/commands/i386/pc/sendkey.c
>> b/grub-core/commands/i386/pc/sendkey.c
>> index 26d9acd3d..ab4bca9e9 100644
>> --- a/grub-core/commands/i386/pc/sendkey.c
>> +++ b/grub-core/commands/i386/pc/sendkey.c
>> @@ -220,8 +220,8 @@ grub_sendkey_postboot (void)
>>
>> *flags = oldflags;
>>
>> - *((char *) 0x41a) = 0x1e;
>> - *((char *) 0x41c) = 0x1e;
>> + *((volatile char *) 0x41a) = 0x1e;
>> + *((volatile char *) 0x41c) = 0x1e;
>>
>> return GRUB_ERR_NONE;
>> }
>> @@ -236,8 +236,8 @@ grub_sendkey_preboot (int noret __attribute__ ((unused)))
>> oldflags = *flags;
>>
>> /* Set the sendkey. */
>> - *((char *) 0x41a) = 0x1e;
>> - *((char *) 0x41c) = keylen + 0x1e;
>> + *((volatile char *) 0x41a) = 0x1e;
>> + *((volatile char *) 0x41c) = keylen + 0x1e;
>> grub_memcpy ((char *) 0x41e, sendkey, 0x20);
>>
>> /* Transform "any ctrl" to "right ctrl" flag. */
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel