See attachment.
[Fix] Avoid recent gcc error messages about unused write(2) return value
2009/1/30 Damien Cassou damien.cassou@gmail.com:
See attachment.
[Fix] Avoid recent gcc error messages about unused write(2) return value
There is a reason why GCC forces you to check the return value.
Cheers Philippe
On Fri, Jan 30, 2009 at 2:22 PM, Philippe Marschall philippe.marschall@gmail.com wrote:
There is a reason why GCC forces you to check the return value.
This was already ignored before, just with the wrong trick. I don't know enough about VMs to decide what can be ignored or not :-).
On 30.01.2009, at 14:22, Philippe Marschall wrote:
2009/1/30 Damien Cassou damien.cassou@gmail.com:
See attachment.
[Fix] Avoid recent gcc error messages about unused write(2) return value
There is a reason why GCC forces you to check the return value.
This is actually not GCC's fault, but newer header files declare write() with the warn_unused_result attribute to enforce that check.
- Bert -
Damien Cassou wrote:
[Fix] Avoid recent gcc error messages about unused write(2) return value
I'm not seeing an error, or even a warning from gcc 4.3.2 for this, on the latest svn/trunk. Could you post the error your getting, and what options you are giving to gcc?
-gavin...
On Fri, Jan 30, 2009 at 6:44 PM, Gavin Romig-Koch gavin@redhat.com wrote:
I'm not seeing an error, or even a warning from gcc 4.3.2 for this, on the latest svn/trunk. Could you post the error your getting, and what options you are giving to gcc?
I do not pass any option to gcc.
$ gcc --version gcc (Ubuntu 4.3.2-1ubuntu12) 4.3.2
The script I use to compile the vm:
$ cd /tmp && svn co http://squeakvm.org/svn/squeak/trunk squeak-svn && cd squeak-svn && mkdir bld && cd bld && ../platforms/unix/config/configure --prefix=/opt/squeak && make && sudo make install
cc1: warnings being treated as errors In file included from /tmp/squeak-svn/platforms/unix/vm-display-fbdev/sqUnixFBDevMouse.c:109, from /tmp/squeak-svn/platforms/unix/vm-display-fbdev/sqUnixFBDev.c:128: /tmp/squeak-svn/platforms/unix/vm-display-fbdev/sqUnixFBDevMousePS2.c: In function 'ms_ps2_send': /tmp/squeak-svn/platforms/unix/vm-display-fbdev/sqUnixFBDevMousePS2.c:113: error: ignoring return value of 'write', declared with attribute warn_unused_result /tmp/squeak-svn/platforms/unix/vm-display-fbdev/sqUnixFBDevMousePS2.c: In function 'ms_ps2_disable': /tmp/squeak-svn/platforms/unix/vm-display-fbdev/sqUnixFBDevMousePS2.c:144: error: ignoring return value of 'write', declared with attribute warn_unused_result make[1]: *** [sqUnixFBDev.lo] Error 1 make: *** [vm-display-fbdev.la] Error 2
Damien Cassou wrote:
[Fix] Avoid recent gcc error messages about unused write(2) return value
What a mess: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509
with the additional fact that the makefile in vm-display-fbdev turns on -Werror.
In any case, if this code has to be changed, I think it would be better in this case to check the return values than to go to extra ordinary lengths to ignore them. Patch attached.
-gavin...
Index: platforms/unix/vm-display-fbdev/sqUnixFBDevMousePS2.c =================================================================== --- platforms/unix/vm-display-fbdev/sqUnixFBDevMousePS2.c (revision 1966) +++ platforms/unix/vm-display-fbdev/sqUnixFBDevMousePS2.c (working copy) @@ -110,11 +110,15 @@ for (i= 0; i < len; ++i) { resend: - (void)write(self->fd, command + i, 1); + if (1 != write(self->fd, command + i, 1)) + { + dprintf("%s: send failed during write\n", self->msName); + return 0; + } dprintf(">%02x\n", command[i]); if (1 != ms_read(self, buf, 1, 1, PS2_SEND_DELAY)) { - dprintf("%s: send failed\n", self->msName); + dprintf("%s: send failed during read\n", self->msName); return 0; } switch (buf[0]) @@ -141,7 +145,11 @@ { unsigned char command[]= { PS2_DISABLE }; dprintf("%s: disable\n", self->msName); - (void)write(self->fd, command, 1); + if (1 != write(self->fd, command, 1)) + { + dprintf("%s: disable failed during write\n", self->msName); + return; + } dprintf(">%02x\n", command[0]); while (1 == ms_read(self, command, 1, 1, PS2_DISABLE_DELAY)) if (PS2_OK == command[0])
vm-dev@lists.squeakfoundation.org