Warnings-as-errors building trunk on Ubuntu 8.10 alpha 4

6 views
Skip to first unread message

Larry Hastings

unread,
Aug 28, 2008, 7:11:16 PM8/28/08
to zfs-fuse

I've built the ZFS-Fuse trunk on Ubuntu 8.10 alpha 4, on amd64 last
week and on i386 this week. I'm having a spot of trouble. Ubuntu
8.10 is due out in October; yes I am using a beta OS, but honestly it
should be fine.

The problem is: gcc (version 4.3.2-0ubuntu1) throws warnings about
ignoring the return value for write(). The code is clearly doing this
on purpose; it tries to placate these modern lint-y compilers by
casting the return value to void. Apparently this is no longer
sufficient.

As a specific example, I get this warning:
cmd/zdb/zdb.c:1943: warning: ignoring return value of 'write',
declared with attribute warn_unused_result
Line 1943 of zdb.c is:
(void) write(2, buf, size);

My "workaround" for this was to disable "-Werror".

Is this new warning a new feature of gcc 4.3.2? What should zfs-fuse
do to make the problem go away?


/larry/

Jonathan Schmidt

unread,
Aug 28, 2008, 7:33:35 PM8/28/08
to zfs-...@googlegroups.com

What about line 1961:

(void) printf("\n%s\n%6s %s 0123456789abcdef\n", label, "", hdr);

Does gcc care that zfs-fuse ignores the return value from printf
(throughout that file, actually)? Why only flag it for the call to
write()? I'd say, based on the obvious syntax clue (casting to void),
that gcc shouldn't warn. I'd file this as a gcc bug.

Jonathan Schmidt

unread,
Aug 28, 2008, 8:49:50 PM8/28/08
to zfs-...@googlegroups.com

Oops, I may have spoken too soon. It appears it may be related to the
__attribute__ ((warn_unused_result)) feature. See more information here
(and elsewhere):

http://gcc.gnu.org/ml/gcc-bugs/2007-04/msg02258.html

Larry Hastings

unread,
Aug 28, 2008, 9:06:15 PM8/28/08
to zfs-fuse

On Aug 28, 4:33 pm, "Jonathan Schmidt" <j...@jschmidt.ca> wrote:
> Does gcc care that zfs-fuse ignores the return value from printf?

No. It complains about write() 5 times, and once each for ftruncate,
chdir, and daemon.

This is definitely on purpose. Line 333 of my /usr/include/unistd.h
reads:
extern ssize_t write (int __fd, __const void *__buf, size_t __n)
__wur;
"__wur" is the attribute "warn_unused_result".

> Why only flag it for the call to write()?

Probably because the return value from write() can tell you something
important in some circumstances. Like if you dump some data down a
socket and only some of it gets written, the return value from write()
will not match the buffer length passed in. I was a bit surprised
when I saw the ZFS source ignoring the return value from write()--but
then I figured, these guys know wtf they are doing, and ZFS clearly
works.

FWIW, I tried "-Werror -Wno-error=unused-value" and "-Werror -Wno-
error=unused", and neither of those helped. There doesn't appear to
be a command-line flag that lets you fiddle with warnings on unused
results. So far I can only build if I remove "-Werror".

And, yeah, I think it's a gcc bug too.


/larry/
Reply all
Reply to author
Forward
0 new messages