Re: [Monetdb-developers] [Monetdb-sql-checkins] sql/src/backends/monet5 merovingian.mx, , 1.9, 1.10
On Sun, Nov 25, 2007 at 10:18:26AM +0000, Fabian wrote:
Update of /cvsroot/monetdb/sql/src/backends/monet5 In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26685
Modified Files: merovingian.mx Log Message: Attempt to fix some compiler warnings. I cannot test myself, as I don't get them, and if I use TestWeb's CFLAGS the code doesn't compile at all at a much earlier stage.
"TestWeb" does not use any (particular) CFLAGS, but just the default that (our) configure uses/provides (with --enable-strict, which is default for the development trunk). In case you have problems with this (or other) settings, please help us fixing them by reporting them ans bug report. The compiler warning is triggered by the following setting in lines 742,3 of buildtools/conf/MonetDB.m4 ======== dnl The default configure invocation when doing an rpmbuild also uses this X_CFLAGS="$X_CFLAGS -Wp,-D_FORTIFY_SOURCE=2" ======== Some functions (system calls) do return, whether they were successful, or not, and the calling ocde should check the respective return values. Ignoring them via (e.g.) (void)write(...); will (most probably) not help. Rather, the code should check the results, e.g., if (write(...) < 0) { ... } or at least pretend to do so, e.g., ssize_t wrt_res = 0; wrt_res = write(...); (void)wrt_res; /* deliberately irgnore portential errors */ Stefan
Index: merovingian.mx =================================================================== RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian.mx,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- merovingian.mx 25 Nov 2007 09:55:05 -0000 1.9 +++ merovingian.mx 25 Nov 2007 10:18:24 -0000 1.10 @@ -1203,10 +1203,10 @@ case -1: /* oops, forking went wrong, cheat a bit in order to write to * the console */ - write(oerr, "unable to fork into background: ", + (void)write(oerr, "unable to fork into background: ", sizeof("unable to fork into background: ")); - write(oerr, strerror(errno), strlen(strerror(errno))); - write(oerr, "\n", 1); + (void)write(oerr, strerror(errno), strlen(strerror(errno))); + (void)write(oerr, "\n", 1); return(1); case 0: /* the child, we want to keep it, try to lock, we can only @@ -1217,17 +1217,17 @@ * remain available, otherwise we loose the lock */ if ((ret = MT_lockf(buf, F_TLOCK, 4, 1)) == -1) { /* locking failed */ - write(oerr, "another merovingian is already running\n", + (void)write(oerr, "another merovingian is already running\n", sizeof("another merovingian is already running\n")); exit(1); } else if (ret == -2) { /* directory or something doesn't exist */ - write(oerr, "unable to create .merovingian_lock file in ", + (void)write(oerr, "unable to create .merovingian_lock file in ", sizeof("unable to create .merovingian_lock file in ")); - write(oerr, dbfarm, strlen(dbfarm)); - write(oerr, ": ", 2); - write(oerr, strerror(errno), strlen(strerror(errno))); - write(oerr, "\n", 1); + (void)write(oerr, dbfarm, strlen(dbfarm)); + (void)write(oerr, ": ", 2); + (void)write(oerr, strerror(errno), strlen(strerror(errno))); + (void)write(oerr, "\n", 1); exit(1); }
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Monetdb-sql-checkins mailing list Monetdb-sql-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |
On 25-11-2007 11:38:45 +0100, Stefan Manegold wrote:
On Sun, Nov 25, 2007 at 10:18:26AM +0000, Fabian wrote:
Update of /cvsroot/monetdb/sql/src/backends/monet5 In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26685
Modified Files: merovingian.mx Log Message: Attempt to fix some compiler warnings. I cannot test myself, as I don't get them, and if I use TestWeb's CFLAGS the code doesn't compile at all at a much earlier stage.
"TestWeb" does not use any (particular) CFLAGS, but just the default that (our) configure uses/provides (with --enable-strict, which is default for the development trunk).
In case you have problems with this (or other) settings, please help us fixing them by reporting them ans bug report.
The compiler warning is triggered by the following setting in lines 742,3 of buildtools/conf/MonetDB.m4 ======== dnl The default configure invocation when doing an rpmbuild also uses this X_CFLAGS="$X_CFLAGS -Wp,-D_FORTIFY_SOURCE=2" ========
Point is, that this is already in my X_CFLAGS, and apparently it is not enough. However, the Gentoo machine (which is complaining on this topic), uses the following X_CFLAGS: -Werror-implicit-function-declaration -Werror -Wpointer-arith -Wdeclaration-after-statement -Wundef -Wp,-D_FORTIFY_SOURCE=2 And this makes it die in some bison generated code, hence I didn't file a bug.
Some functions (system calls) do return, whether they were successful, or not, and the calling ocde should check the respective return values. Ignoring them via (e.g.) (void)write(...); will (most probably) not help. Rather, the code should check the results, e.g., if (write(...) < 0) { ... } or at least pretend to do so, e.g., ssize_t wrt_res = 0; wrt_res = write(...); (void)wrt_res; /* deliberately irgnore portential errors */
Yes, but interestingly if you look at the error, it only complains about the 5th or so write invocation, all the earlier ones it simply appears to be happy about. Its really a bit misterious to me as to why.
On Sun, Nov 25, 2007 at 11:46:46AM +0100, Fabian Groffen wrote:
On 25-11-2007 11:38:45 +0100, Stefan Manegold wrote:
On Sun, Nov 25, 2007 at 10:18:26AM +0000, Fabian wrote:
Update of /cvsroot/monetdb/sql/src/backends/monet5 In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26685
Modified Files: merovingian.mx Log Message: Attempt to fix some compiler warnings. I cannot test myself, as I don't get them, and if I use TestWeb's CFLAGS the code doesn't compile at all at a much earlier stage.
"TestWeb" does not use any (particular) CFLAGS, but just the default that (our) configure uses/provides (with --enable-strict, which is default for the development trunk).
In case you have problems with this (or other) settings, please help us fixing them by reporting them ans bug report.
The compiler warning is triggered by the following setting in lines 742,3 of buildtools/conf/MonetDB.m4 ======== dnl The default configure invocation when doing an rpmbuild also uses this X_CFLAGS="$X_CFLAGS -Wp,-D_FORTIFY_SOURCE=2" ========
Point is, that this is already in my X_CFLAGS, and apparently it is not enough.
However, the Gentoo machine (which is complaining on this topic), uses the following X_CFLAGS: -Werror-implicit-function-declaration -Werror -Wpointer-arith -Wdeclaration-after-statement -Wundef -Wp,-D_FORTIFY_SOURCE=2
And this makes it die in some bison generated code, hence I didn't file a bug.
That's why we also use GCC_BISON_CFLAGS = -Wno-undef for bison generated code (and GCC_SWIG_CFLAGS = -Wno-strict-aliasing -Wno-unused-variable -Wno-unused-function -Wno-unused-parameter -Wno-undef -Wno-missing-field-initializers for swig generated code). Hence, try also these (or the default, i.e., w/o externally set X_CFLAGS), and things shoudl work (or be reported as bug).
Some functions (system calls) do return, whether they were successful, or not, and the calling ocde should check the respective return values. Ignoring them via (e.g.) (void)write(...); will (most probably) not help. Rather, the code should check the results, e.g., if (write(...) < 0) { ... } or at least pretend to do so, e.g., ssize_t wrt_res = 0; wrt_res = write(...); (void)wrt_res; /* deliberately irgnore portential errors */
Yes, but interestingly if you look at the error, it only complains about the 5th or so write invocation, all the earlier ones it simply appears to be happy about. Its really a bit misterious to me as to why.
Hm, the error message says ======= cc1: warnings being treated as errors /home/monet/monet.GNU.32.32.d.777/sql/src/backends/monet5/merovingian.mx: In function ‘main’: /home/monet/monet.GNU.32.32.d.777/sql/src/backends/monet5/merovingian.mx:1206: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result /home/monet/monet.GNU.32.32.d.777/sql/src/backends/monet5/merovingian.mx:1208: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result /home/monet/monet.GNU.32.32.d.777/sql/src/backends/monet5/merovingian.mx:1209: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result /home/monet/monet.GNU.32.32.d.777/sql/src/backends/monet5/merovingian.mx:1220: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result /home/monet/monet.GNU.32.32.d.777/sql/src/backends/monet5/merovingian.mx:1225: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result /home/monet/monet.GNU.32.32.d.777/sql/src/backends/monet5/merovingian.mx:1227: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result /home/monet/monet.GNU.32.32.d.777/sql/src/backends/monet5/merovingian.mx:1228: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result /home/monet/monet.GNU.32.32.d.777/sql/src/backends/monet5/merovingian.mx:1229: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result /home/monet/monet.GNU.32.32.d.777/sql/src/backends/monet5/merovingian.mx:1230: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result make[7]: *** [merovingian.o] Error 1 ======== and `grep -n -w write sql/src/backends/monet5/merovingian.mx` says ======== 571: fout = block_stream(socket_wastream(sock, "write")); 1135: /* write to the given file */ 1151: /* write to the given file */ 1169: /* make sure we will be able to write the our pid */ 1204: /* oops, forking went wrong, cheat a bit in order to write to 1206: write(oerr, "unable to fork into background: ", 1208: write(oerr, strerror(errno), strlen(strerror(errno))); 1209: write(oerr, "\n", 1); 1220: write(oerr, "another merovingian is already running\n", 1225: write(oerr, "unable to create .merovingian_lock file in ", 1227: write(oerr, dbfarm, strlen(dbfarm)); 1228: write(oerr, ": ", 2); 1229: write(oerr, strerror(errno), strlen(strerror(errno))); 1230: write(oerr, "\n", 1); 1245: /* write out the pid */ ======== Hence, I'd say it complain about the first occurance of "write" thet is not a srting literall or in a comment, which qualifies as the first write invocation (in this file) for me. Stefan -- | Dr. Stefan Manegold | mailto:Stefan.Manegold@cwi.nl | | CWI, P.O.Box 94079 | http://www.cwi.nl/~manegold/ | | 1090 GB Amsterdam | Tel.: +31 (20) 592-4212 | | The Netherlands | Fax : +31 (20) 592-4312 |
participants (2)
-
Fabian Groffen
-
Stefan Manegold