From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gdNQ3-0002iM-DA for qemu-devel@nongnu.org; Sat, 29 Dec 2018 17:49:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gdNFO-0000TJ-Rk for qemu-devel@nongnu.org; Sat, 29 Dec 2018 17:38:27 -0500 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:41715) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gdN5s-0008Ao-KL for qemu-devel@nongnu.org; Sat, 29 Dec 2018 17:28:32 -0500 Received: by mail-pf1-x441.google.com with SMTP id b7so11870047pfi.8 for ; Sat, 29 Dec 2018 14:28:32 -0800 (PST) References: <20181228173356.15359-1-philmd@redhat.com> <20181228173356.15359-2-philmd@redhat.com> From: Richard Henderson Message-ID: <9f71b1bf-f6f2-dddf-3e4a-ad007edccaa1@linaro.org> Date: Sun, 30 Dec 2018 09:28:23 +1100 MIME-Version: 1.0 In-Reply-To: <20181228173356.15359-2-philmd@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v4 1/5] qemu/compiler: Define QEMU_NONSTRING List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , qemu-devel@nongnu.org Cc: Thomas Huth , Juan Quintela , David Hildenbrand , "Dr. David Alan Gilbert" , Markus Armbruster , =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= , "Michael S. Tsirkin" , Igor Mammedov , Paolo Bonzini , David Gibson On 12/29/18 4:33 AM, Philippe Mathieu-Daudé wrote: > GCC 8 introduced the -Wstringop-truncation checker to detect truncation by > the strncat and strncpy functions (closely related to -Wstringop-overflow, > which detect buffer overflow by string-modifying functions declared in > ). > > In tandem of -Wstringop-truncation, the "nonstring" attribute was added: > > The nonstring variable attribute specifies that an object or member > declaration with type array of char, signed char, or unsigned char, > or pointer to such a type is intended to store character arrays that > do not necessarily contain a terminating NUL. This is useful in detecting > uses of such arrays or pointers with functions that expect NUL-terminated > strings, and to avoid warnings when such an array or pointer is used as > an argument to a bounded string manipulation function such as strncpy. > > From the GCC manual: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-nonstring-variable-attribute > > Add the QEMU_NONSTRING macro which checks if the compiler supports this > attribute. > > Suggested-by: Michael S. Tsirkin > Reviewed-by: Eric Blake > Reviewed-by: Michael S. Tsirkin > Signed-off-by: Philippe Mathieu-Daudé > --- Reviewed-by: Richard Henderson r~