Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MH3pB-0002QM-Pw for qemu-devel@nongnu.org; Wed, 17 Jun 2009 18:41:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MH3p8-0002Oy-2P for qemu-devel@nongnu.org; Wed, 17 Jun 2009 18:41:45 -0400 Received: from [199.232.76.173] (port=44321 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MH3p7-0002Oq-Lg for qemu-devel@nongnu.org; Wed, 17 Jun 2009 18:41:41 -0400 Received: from mx20.gnu.org ([199.232.41.8]:59755) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MH3p7-0000hx-5w for qemu-devel@nongnu.org; Wed, 17 Jun 2009 18:41:41 -0400 Received: from smtp6-g21.free.fr ([212.27.42.6]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MH3p5-0004fv-TB for qemu-devel@nongnu.org; Wed, 17 Jun 2009 18:41:40 -0400 From: "Jean-Christophe Dubois" Subject: Re: [Qemu-devel] [PATCH v4] avoid compilation warning/errors on up to date Date: Thu, 18 Jun 2009 00:41:31 +0200 References: <200906172322.35496.jcd@tribudubois.net> <4A396630.20105@codemonkey.ws> In-Reply-To: <4A396630.20105@codemonkey.ws> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200906180041.31816.jcd@tribudubois.net> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org Le mercredi 17 juin 2009 23:54:56 Anthony Liguori, vous avez =C3=A9crit : > Jean-Christophe Dubois wrote: > > Some system calls are now requiring to have their return value checked. > > > > Without this a warning is emitted and in the case a qemu an error is > > triggered as qemu is considering warnings as errors. > > > > For example: > > > > block/cow.c: In function =E2=80=98cow_create=E2=80=99: > > block/cow.c:251: error: ignoring return value of =E2=80=98write=E2=80= =99, declared with > > attribute warn_unused_result > > block/cow.c:253: error: ignoring return value of =E2=80=98ftruncate=E2= =80=99, declared > > with attribute warn_unused_result > > > > This is an attempt at removing all these warnings to allow a clean > > compilation with up to date compilers/distributions. > > > > The second version fixes an error detected by Stuart Brady as well > > as some coding style issues. Note however that some of the > > modified files don't follow the qemu coding style (using tabs > > instead of spaces). > > > > The Third version add one ftruncate() system call error handling that > > was missing from V2 (in block/vvfat.c). > > > > The Fourth version is correctly handling EINTR error on read/write > > system calls. read/write calls are replaced by qemu_read/qemu_write > > functions that are handling EINTR and incomplete read/write under > > the cover. > > > > Signed-off-by: Jean-Christophe DUBOIS > > This really makes me nervous to be honest. It's too much for one patch. It is what is required to fix the compilation failure. > What I'd rather do, is commit Gerd's patch and also add > -U_FORTIFY_SOURCE to the default CFLAGS. I've confirmed this fixes the > default build on Ubuntu. It certainly does. Qemu did compile for years with less strict compilers. > I'd rather take this set of clean ups as a set of smaller, well > thought-out patches. Once that's done, we can remove -U_FORTIFY_SOURCE. Well, without -U_FORTIFY_SOURCE the all set of patch is required. Once you = add=20 =2DU_FORTIFY_SOURCE I am skeptical it will be removed any time soon. Actual= ly I=20 bet more code without error checking will be added and the problem will jus= t=20 build up. > > --- > > block.c | 3 +- > > block/bochs.c | 3 +- > > block/cow.c | 12 +++++++++- > > block/qcow.c | 22 +++++++++++++++----- > > block/qcow2.c | 37 ++++++++++++++++++++++++++++------- > > block/raw-posix.c | 9 +++++-- > > block/vmdk.c | 54 > > +++++++++++++++++++++++++++++++++++----------------- block/vvfat.c = |=20 > > 24 ++++++++++++++++------ > > linux-user/mmap.c | 7 ++++- > > linux-user/path.c | 6 ++++- > > osdep.c | 5 +++- > > qemu-common.h | 31 ++++++++++++++++++++++++++++++ > > slirp/misc.c | 4 ++- > > usb-linux.c | 3 +- > > vl.c | 14 +++++++++--- > > 15 files changed, 177 insertions(+), 57 deletions(-) > > > > diff --git a/block.c b/block.c > > index aca5a6d..c78d66a 100644 > > --- a/block.c > > +++ b/block.c > > @@ -371,7 +371,8 @@ int bdrv_open2(BlockDriverState *bs, const char > > *filename, int flags, snprintf(backing_filename, > > sizeof(backing_filename), "%s", filename); > > else > > - realpath(filename, backing_filename); > > + if (!realpath(filename, backing_filename)) > > + return -1; > > There should be cleanup work to do, no? > > > bdrv_qcow2 =3D bdrv_find_format("qcow2"); > > options =3D parse_option_parameters("", > > bdrv_qcow2->create_options, NULL); diff --git a/block/bochs.c > > b/block/bochs.c > > index bac81c4..1fbce9e 100644 > > --- a/block/bochs.c > > +++ b/block/bochs.c > > @@ -199,7 +199,8 @@ static inline int seek_to_sector(BlockDriverState > > *bs, int64_t sector_num) // read in bitmap for current extent > > lseek(s->fd, bitmap_offset + (extent_offset / 8), SEEK_SET); > > > > - read(s->fd, &bitmap_entry, 1); > > + if (qemu_read(s->fd, &bitmap_entry, 1) !=3D 1) > > + return -1; // not allocated > > Why check errors on read but not lseek? =20 Well, my first goal was to fix the compilation failure in a useful way. lse= ek()=20 doesn't trigger the warning and so doesn't make the compilation fail. Now, I would agree that lseek return code should also be checked. But can y= ou=20 guess how many lseek() (and other system calls) without error check there i= s=20 in the qemu source code. > If we're going to add error > checking to this function, we should make it robust, not just enough > error checking to silence GCC. Why do you think my functions are not robust enough? Just curious ... If I = can=20 fix them, I'll do it. My goal was not to just silence GCC (I would use - U_FORTIFY_SOURCE for this) but to actually handle the error in a meaningful= =20 way. > We should just silence GCC with > -U_FORTIFY_SOURCE. You can do this but once done I doubt anybody will step up to actually fix = the=20 multiple place in the code where system calls are used without error checki= ng.=20 As there will be no more warning/error the problem will be=20 forgotten/invisible. > The same is true for most of the remainder. This is definitely a good > task worth doing but I think we should do it more carefully. Once again, when all warnings are suppressed I doubt anybody will volunteer= =20 for this boring task. And all future code added to the project without syst= em=20 call error check will get unnoticed because you silenced GCC. But at the end it is your call. > Regards, > > Anthony Liguori