On Fri, Mar 27, 2009 at 01:07:14PM +0100, Hofmann Johannes wrote:
Hi,
On Fri, Mar 27, 2009 at 12:00:46AM +0100, Michal Nowak wrote:
Found this three warnings when compiling with gcc-4.3.2-7.i386:
gcc -DHAVE_CONFIG_H -I. -I../.. -I/usr/local/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -g -O2 -DD_DNS_THREADED -D_REENTRANT -D_THREAD_SAFE -Wall -W -Waggregate-return -MT dpi.o -MD -MP -MF .deps/dpi.Tpo -c -o dpi.o dpi.c dpi.c: In function ?Dpi_get_dpid_uds_dir?: dpi.c:382: warning: ignoring return value of ?fgets?, declared with attribute warn_unused_result dpi.c: In function ?a_Dpi_bye_dpid?: dpi.c:733: warning: ignoring return value of ?write?, declared with attribute warn_unused_result
g++ -DHAVE_CONFIG_H -I. -I.. -DDILLORC_SYS='"/usr/local/etc/dillorc"' -I/usr/local/include -I.. -I/usr/include/libpng12 -I/usr/include/freetype2 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Wno-non-virtual-dtor -g -O2 -Wall -W -Wno-unused-parameter -fno-rtti -fno-exceptions -MT styleengine.o -MD -MP -MF .deps/styleengine.Tpo -c -o styleengine.o styleengine.cc ../lout/misc.hh: In member function ?void StyleEngine::apply(dw::core::style::StyleAttrs*, CssPropertyList*)?: ../lout/misc.hh:181: warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false
Can you please check whether attached patches fix the warnings?
Michal, do the patches fix the warnings for you? Cheers, Johannes
@all: please have a look at the dpi.c fix.
Cheers, Johannes
diff -r b06377790b00 src/IO/dpi.c --- a/src/IO/dpi.c Thu Mar 26 23:18:02 2009 +0000 +++ b/src/IO/dpi.c Fri Mar 27 13:05:11 2009 +0100 @@ -371,7 +371,7 @@ static char *Dpi_get_dpid_uds_dir(void) { FILE *in; char *saved_name_filename; /* :) */ - char dpid_uds_dir[256], *p = NULL; + char buf[256], *dpid_uds_dir, *p = NULL, *p1;
saved_name_filename = dStrconcat(dGethomedir(), "/.dillo/dpi_socket_dir", NULL); @@ -379,14 +379,16 @@ static char *Dpi_get_dpid_uds_dir(void) dFree(saved_name_filename);
if (in != NULL) { - fgets(dpid_uds_dir, 256, in); + dpid_uds_dir = fgets(buf, sizeof(buf), in); fclose(in); - if ((p = strchr(dpid_uds_dir, '\n'))) { - *p = 0; - } - if (access(dpid_uds_dir, F_OK) == 0) { - p = dStrdup(dpid_uds_dir); - _MSG("Dpi_get_dpid_uds_dir:: %s\n", p); + if (dpid_uds_dir) { + if ((p1 = strchr(dpid_uds_dir, '\n'))) { + *p1 = 0; + } + if (access(dpid_uds_dir, F_OK) == 0) { + p = dStrdup(dpid_uds_dir); + _MSG("Dpi_get_dpid_uds_dir:: %s\n", p); + } } }
@@ -730,7 +732,9 @@ void a_Dpi_bye_dpid() MSG("%s\n", sa.sun_path); } DpiBye_cmd = a_Dpip_build_cmd("cmd=%s", "DpiBye"); - (void) write(new_socket, DpiBye_cmd, strlen(DpiBye_cmd)); + if (write(new_socket, DpiBye_cmd, strlen(DpiBye_cmd)) != + (ssize_t) strlen(DpiBye_cmd)) + MSG_WARN("Failed to send DpiBye\n"); dFree(DpiBye_cmd); Dpi_close_fd(new_socket); }
diff -r b06377790b00 lout/misc.hh --- a/lout/misc.hh Thu Mar 26 23:18:02 2009 +0000 +++ b/lout/misc.hh Fri Mar 27 12:52:36 2009 +0100 @@ -178,7 +178,7 @@ public: */ inline T get (int i) { if (BOUND_CHECKING) - assert (i >= 0 && i < this->num); + assert (i >= 0 && this->num - i > 0); return this->array[i]; }
@@ -192,7 +192,7 @@ public: */ inline void set (int i, T t) { if (BOUND_CHECKING) - assert (i >= 0 && i < this->num); + assert (i >= 0 && this->num - i > 0); this->array[i] = t; } };