From: Alistair Francis <alistair23@gmail.com> To: "Daniel P. Berrangé" <berrange@redhat.com> Cc: Alistair Francis <Alistair.Francis@wdc.com>, "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>, "kraxel@redhat.com" <kraxel@redhat.com>, "riku.voipio@iki.fi" <riku.voipio@iki.fi>, "laurent@vivier.eu" <laurent@vivier.eu>, "qemu-trivial@nongnu.org" <qemu-trivial@nongnu.org> Subject: Re: [Qemu-devel] [PATCH v2 1/5] util/qemu-sockets: Fix GCC 9 build warnings Date: Thu, 2 May 2019 10:57:51 -0700 [thread overview] Message-ID: <CAKmqyKOOw5A24vmrv7x5z8jiRMRBYdqPL5udbUk4NHEbDTBksQ@mail.gmail.com> (raw) In-Reply-To: <20190501094140.GO29808@redhat.com> On Wed, May 1, 2019 at 2:41 AM Daniel P. Berrangé <berrange@redhat.com> wrote: > > On Tue, Apr 30, 2019 at 11:28:22PM +0000, Alistair Francis wrote: > > Fix this warning when building with GCC9 on Fedora 30: > > In function ‘strncpy’, > > inlined from ‘unix_connect_saddr.isra.0’ at util/qemu-sockets.c:925:5: > > /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 108 equals destination size [-Werror=stringop-truncation] > > 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > In function ‘strncpy’, > > inlined from ‘unix_listen_saddr.isra.0’ at util/qemu-sockets.c:880:5: > > > > Signed-off-by: Alistair Francis <alistair.francis@wdc.com> > > --- > > util/qemu-sockets.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c > > index 9705051690..8c3322958f 100644 > > --- a/util/qemu-sockets.c > > +++ b/util/qemu-sockets.c > > @@ -829,7 +829,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, > > struct sockaddr_un un; > > int sock, fd; > > char *pathbuf = NULL; > > - const char *path; > > + const char *path QEMU_NONSTRING; > > > > sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0); > > if (sock < 0) { > > @@ -922,7 +922,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp) > > > > memset(&un, 0, sizeof(un)); > > un.sun_family = AF_UNIX; > > - strncpy(un.sun_path, saddr->path, sizeof(un.sun_path)); > > + memcpy(un.sun_path, saddr->path, MIN(strlen(saddr->path), sizeof(un.sun_path))); > > > > /* connect to peer */ > > do { > > I think my proposed fix for this file is preferrable as it avoids > repeated strlen calls > > https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg02124.html That's fine with me, I have dropped this patch. Alistair > > > 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 :|
WARNING: multiple messages have this Message-ID (diff)
From: Alistair Francis <alistair23@gmail.com> To: "Daniel P. Berrangé" <berrange@redhat.com> Cc: "qemu-trivial@nongnu.org" <qemu-trivial@nongnu.org>, "riku.voipio@iki.fi" <riku.voipio@iki.fi>, "laurent@vivier.eu" <laurent@vivier.eu>, "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>, Alistair Francis <Alistair.Francis@wdc.com>, "kraxel@redhat.com" <kraxel@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 1/5] util/qemu-sockets: Fix GCC 9 build warnings Date: Thu, 2 May 2019 10:57:51 -0700 [thread overview] Message-ID: <CAKmqyKOOw5A24vmrv7x5z8jiRMRBYdqPL5udbUk4NHEbDTBksQ@mail.gmail.com> (raw) Message-ID: <20190502175751.1QKb2aZoK-fGJGcowHscHcEcEKa_ZsqZena6ZdLSSoM@z> (raw) In-Reply-To: <20190501094140.GO29808@redhat.com> On Wed, May 1, 2019 at 2:41 AM Daniel P. Berrangé <berrange@redhat.com> wrote: > > On Tue, Apr 30, 2019 at 11:28:22PM +0000, Alistair Francis wrote: > > Fix this warning when building with GCC9 on Fedora 30: > > In function ‘strncpy’, > > inlined from ‘unix_connect_saddr.isra.0’ at util/qemu-sockets.c:925:5: > > /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 108 equals destination size [-Werror=stringop-truncation] > > 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > In function ‘strncpy’, > > inlined from ‘unix_listen_saddr.isra.0’ at util/qemu-sockets.c:880:5: > > > > Signed-off-by: Alistair Francis <alistair.francis@wdc.com> > > --- > > util/qemu-sockets.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c > > index 9705051690..8c3322958f 100644 > > --- a/util/qemu-sockets.c > > +++ b/util/qemu-sockets.c > > @@ -829,7 +829,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, > > struct sockaddr_un un; > > int sock, fd; > > char *pathbuf = NULL; > > - const char *path; > > + const char *path QEMU_NONSTRING; > > > > sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0); > > if (sock < 0) { > > @@ -922,7 +922,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp) > > > > memset(&un, 0, sizeof(un)); > > un.sun_family = AF_UNIX; > > - strncpy(un.sun_path, saddr->path, sizeof(un.sun_path)); > > + memcpy(un.sun_path, saddr->path, MIN(strlen(saddr->path), sizeof(un.sun_path))); > > > > /* connect to peer */ > > do { > > I think my proposed fix for this file is preferrable as it avoids > repeated strlen calls > > https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg02124.html That's fine with me, I have dropped this patch. Alistair > > > 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 :|
next prev parent reply other threads:[~2019-05-02 17:59 UTC|newest] Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-04-30 23:28 [Qemu-devel] [PATCH v2 0/5] Fix some GCC 9 build warnings Alistair Francis 2019-04-30 23:28 ` Alistair Francis 2019-04-30 23:28 ` [Qemu-devel] [PATCH v2 1/5] util/qemu-sockets: Fix " Alistair Francis 2019-04-30 23:28 ` Alistair Francis 2019-05-01 9:35 ` Laurent Vivier 2019-05-01 9:35 ` Laurent Vivier 2019-05-01 9:41 ` Daniel P. Berrangé 2019-05-01 9:41 ` Daniel P. Berrangé 2019-05-02 17:57 ` Alistair Francis [this message] 2019-05-02 17:57 ` Alistair Francis 2019-04-30 23:28 ` [Qemu-devel] [PATCH v2 2/5] hw/usb/hcd-xhci: Fix GCC 9 build warning Alistair Francis 2019-04-30 23:28 ` Alistair Francis 2019-05-01 9:37 ` Laurent Vivier 2019-05-01 9:37 ` Laurent Vivier 2019-05-01 9:43 ` Daniel P. Berrangé 2019-05-01 9:43 ` Daniel P. Berrangé 2019-05-01 14:12 ` Richard Henderson 2019-05-01 14:12 ` Richard Henderson 2019-05-01 15:21 ` Philippe Mathieu-Daudé 2019-05-01 15:21 ` Philippe Mathieu-Daudé 2019-05-02 17:53 ` Alistair Francis 2019-05-02 17:53 ` Alistair Francis 2019-04-30 23:28 ` [Qemu-devel] [PATCH v2 3/5] hw/usb/dev-mtp: " Alistair Francis 2019-04-30 23:28 ` Alistair Francis 2019-05-01 7:12 ` Thomas Huth 2019-05-01 7:12 ` Thomas Huth 2019-05-01 9:40 ` Daniel P. Berrangé 2019-05-01 9:40 ` Daniel P. Berrangé 2019-05-02 17:48 ` Alistair Francis 2019-05-02 17:48 ` Alistair Francis 2019-04-30 23:28 ` [Qemu-devel] [PATCH v2 4/5] linux-user/uname: Fix GCC 9 build warnings Alistair Francis 2019-04-30 23:28 ` Alistair Francis 2019-05-01 9:40 ` Laurent Vivier 2019-05-01 9:40 ` Laurent Vivier 2019-05-01 9:44 ` Daniel P. Berrangé 2019-05-01 9:44 ` Daniel P. Berrangé 2019-05-01 9:46 ` Laurent Vivier 2019-05-01 9:46 ` Laurent Vivier 2019-05-01 12:00 ` Eric Blake 2019-05-01 12:00 ` Eric Blake 2019-05-02 17:24 ` Alistair Francis 2019-05-02 17:24 ` Alistair Francis 2019-04-30 23:29 ` [Qemu-devel] [PATCH v2 5/5] linux-user/elfload: " Alistair Francis 2019-04-30 23:29 ` Alistair Francis 2019-05-01 9:40 ` Laurent Vivier 2019-05-01 9:40 ` Laurent Vivier 2019-05-01 14:15 ` Richard Henderson 2019-05-01 14:15 ` Richard Henderson 2019-05-02 8:14 ` Laurent Vivier 2019-05-02 8:14 ` Laurent Vivier
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=CAKmqyKOOw5A24vmrv7x5z8jiRMRBYdqPL5udbUk4NHEbDTBksQ@mail.gmail.com \ --to=alistair23@gmail.com \ --cc=Alistair.Francis@wdc.com \ --cc=berrange@redhat.com \ --cc=kraxel@redhat.com \ --cc=laurent@vivier.eu \ --cc=qemu-devel@nongnu.org \ --cc=qemu-trivial@nongnu.org \ --cc=riku.voipio@iki.fi \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).