Re: [kvm-unit-tests PATCH v2 2/2] s390x: Fix gcc 12 warning about array bounds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/24/22 09:31, Claudio Imbrenda wrote:
> On Fri, 20 May 2022 16:05:46 +0200
> Janis Schoetterl-Glausch <scgl@xxxxxxxxxxxxx> wrote:
> 
>> gcc 12 warns about pointer constant <4k dereference.
>> Silence the warning by using the extern lowcore symbol to derive the
>> pointers. This way gcc cannot conclude that the pointer is <4k.
>>
>> Signed-off-by: Janis Schoetterl-Glausch <scgl@xxxxxxxxxxxxx>
>> ---
>>  lib/s390x/asm/mem.h | 4 ++++
>>  s390x/emulator.c    | 5 +++--
>>  s390x/skey.c        | 2 +-
>>  3 files changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/lib/s390x/asm/mem.h b/lib/s390x/asm/mem.h
>> index 845c00cc..e7901fe0 100644
>> --- a/lib/s390x/asm/mem.h
>> +++ b/lib/s390x/asm/mem.h
>> @@ -7,6 +7,10 @@
>>   */
>>  #ifndef _ASMS390X_MEM_H_
>>  #define _ASMS390X_MEM_H_
>> +#include <asm/arch_def.h>
>> +
>> +/* pointer to 0 used to avoid compiler warnings */
>> +uint8_t *mem_all = (uint8_t *)&lowcore;
> 
> this is defined in a .h, so maybe it's better to declare it static?
> 
> 
> although maybe you can simply declare a macro like this:
> 
> #define MEM(x) ((void *)((uint8_t *)&lowcore + (x)))
> 
> and then just use MEM(x)...
> 
> (please find a less generic name for MEM, though)

MEM_ALL
MEM_ABS
MEM_OPAQUE
OPAQUE_PTR

Suggestions welcome, the last would be my favorite.

[...]




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux