GNOME Bugzilla – Bug 743439
Fails to build with -Werror=unused-result
Last modified: 2015-06-11 09:18:31 UTC
Version: 1.0.0 Latest version of network-manager-vpnc fails to build here under Debian (since the default is Werror): make[2]: Entering directory '/home/michael/debian/build-area/network-manager-vpnc-1.0.0/src' gcc -DHAVE_CONFIG_H -I. -I.. -I.. -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_32 -I/usr/include/libnm-glib -I/usr/include/NetworkManager -I/usr/include/libnm-glib -I/usr/include/NetworkManager -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -DG_DISABLE_DEPRECATED -DBINDIR=\"/usr/bin\" -DPREFIX=\""/usr"\" -DSYSCONFDIR=\""/etc"\" -DVERSION="\"1.0.0\"" -DLIBDIR=\""/usr/lib/x86_64-linux-gnu"\" -DLIBEXECDIR=\""/usr/lib/NetworkManager"\" -DLOCALSTATEDIR=\""/var"\" -DDATADIR=\"/usr/share\" -DNM_VPNC_LOCALEDIR=\"/usr/share/locale\" -D_FORTIFY_SOURCE=2 -Wall -std=gnu89 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wdeclaration-after-statement -Wstrict-prototypes -Wfloat-equal -Wno-unused-parameter -Wno-sign-compare -fno-strict-aliasing -Wno-unused-but-set-variable -Werror -c -o nm-vpnc-service.o nm-vpnc-service.c nm-vpnc-service.c: In function '_connect_common': nm-vpnc-service.c:887:3: error: ignoring return value of 'write', declared with attribute warn_unused_result [-Werror=unused-result] write (priv->infd, &end, sizeof (end)); ^ cc1: all warnings being treated as errors Makefile:510: recipe for target 'nm-vpnc-service.o' failed
Looking at the code a bit, we have another write() call in write_config_option() [1]. While the return value of write() is stored, there is no proper error handling. Shouldn't this at least log an error if x != strlen (string)? [1] https://git.gnome.org/browse/network-manager-vpnc/tree/src/nm-vpnc-service.c#n660
A fix pushed to master and nm-1-0: 6013122 service: check write() return value to please compilers (bgo #743439)