qemu-devel
[Top][All Lists]
Advanced

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

Re: s390-ccw: warning: writing 1 byte into a region of size 0 [-Wstringo


From: Philippe Mathieu-Daudé
Subject: Re: s390-ccw: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
Date: Thu, 22 Apr 2021 16:34:34 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

On 4/22/21 1:48 PM, Daniel P. Berrangé wrote:
> On Thu, Apr 22, 2021 at 01:24:30PM +0200, Philippe Mathieu-Daudé wrote:
>> This silents the warning however:
>>
>> -- >8 --
>> diff --git a/pc-bios/s390-ccw/libc.h b/pc-bios/s390-ccw/libc.h
>> index bcdc45732d..2dea399904 100644
>> --- a/pc-bios/s390-ccw/libc.h
>> +++ b/pc-bios/s390-ccw/libc.h
>> @@ -19,6 +19,8 @@ typedef unsigned short     uint16_t;
>>  typedef unsigned int       uint32_t;
>>  typedef unsigned long long uint64_t;
>>
>> +#pragma GCC diagnostic push
>> +#pragma GCC diagnostic ignored "-Wstringop-overflow"
>>  static inline void *memset(void *s, int c, size_t n)
>>  {
>>      size_t i;
>> @@ -30,6 +32,7 @@ static inline void *memset(void *s, int c, size_t n)
>>
>>      return s;
>>  }
>> +#pragma GCC diagnostic pop
> 
> I wonder if it works if you put the pragma around the specific
> caller, as that would make the scope more limited so we can still
> see valid bugs elsewhere

No, this doesn't silence it:

-- >8 --
diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c
@@ -182,7 +182,10 @@ static void boot_setup(void)
      * Clear out any potential S390EP magic (see jump_to_low_kernel()),
      * so we don't taint our decision-making process during a reboot.
      */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
     memset((char *)S390EP, 0, 6);
+#pragma GCC diagnostic pop

     have_iplb = store_iplb(&iplb);
 }
---

> 
>>
>>  static inline void *memcpy(void *s1, const void *s2, size_t n)
>>  {
>> ---
>>
>> Oddly this code doesn't emit any warning:
> 
> Let me correct that for you
> 
>   s/doesn't emit any warning/doesn't emit any warning *yet*/
> 
> compilers get more strict all the time. The memcmp is just
> a memory read, however, while memset is a write, so less
> severe

OK :)

>>   if (!memcmp((char *)S390EP, "S390EP", 6)) {
>>   ...
> 
> Regards,
> Daniel
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]