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: Daniel P . Berrangé
Subject: Re: s390-ccw: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
Date: Thu, 22 Apr 2021 12:48:35 +0100
User-agent: Mutt/2.0.5 (2021-01-21)

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

> 
>  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

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

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




reply via email to

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