From eb2b8c2798bf50392b7cdd0ed203749742408bfa Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Fri, 15 May 2015 16:36:43 +0200 Subject: [PATCH 1/7] build: use compat version of g_clear_pointer() Ubuntu 12.04 has an ancient version of glib, which we nevertheless support. --- libnm-core/nm-dbus-utils.c | 1 + src/main-utils.c | 2 ++ src/nm-connectivity.c | 2 ++ src/settings/plugins/keyfile/writer.c | 2 ++ src/supplicant-manager/nm-supplicant-manager.c | 2 ++ 5 files changed, 9 insertions(+) diff --git a/libnm-core/nm-dbus-utils.c b/libnm-core/nm-dbus-utils.c index 1f1e20ced..4bdbdd094 100644 --- a/libnm-core/nm-dbus-utils.c +++ b/libnm-core/nm-dbus-utils.c @@ -24,6 +24,7 @@ #include #include +#include "nm-glib-compat.h" #include "nm-core-internal.h" typedef struct { diff --git a/src/main-utils.c b/src/main-utils.c index 1d899587e..5378ca97a 100644 --- a/src/main-utils.c +++ b/src/main-utils.c @@ -34,6 +34,8 @@ #include #include +#include "nm-glib-compat.h" + #include "gsystem-local-alloc.h" #include "main-utils.h" #include "NetworkManagerUtils.h" diff --git a/src/nm-connectivity.c b/src/nm-connectivity.c index 1dfcf00b1..f7e7576c2 100644 --- a/src/nm-connectivity.c +++ b/src/nm-connectivity.c @@ -26,6 +26,8 @@ #include #endif +#include "nm-glib-compat.h" + #include "nm-connectivity.h" #include "nm-config.h" #include "nm-logging.h" diff --git a/src/settings/plugins/keyfile/writer.c b/src/settings/plugins/keyfile/writer.c index 9cf119c0c..b6a8786dc 100644 --- a/src/settings/plugins/keyfile/writer.c +++ b/src/settings/plugins/keyfile/writer.c @@ -27,6 +27,8 @@ #include #include +#include "nm-glib-compat.h" + #include "nm-logging.h" #include "writer.h" #include "common.h" diff --git a/src/supplicant-manager/nm-supplicant-manager.c b/src/supplicant-manager/nm-supplicant-manager.c index d07e23aea..083f2ebcb 100644 --- a/src/supplicant-manager/nm-supplicant-manager.c +++ b/src/supplicant-manager/nm-supplicant-manager.c @@ -25,6 +25,8 @@ #include #include +#include "nm-glib-compat.h" + #include "nm-supplicant-manager.h" #include "nm-supplicant-interface.h" #include "nm-logging.h" From 22b99e3bbb2ca33963e839f12ab95314ab8d9ba9 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Fri, 15 May 2015 16:37:20 +0200 Subject: [PATCH 2/7] ppp-manager: fix build with Linux 3.2.0 headers Fixes build with Ubuntu 12.04. In file included from ppp-manager/nm-ppp-manager.c:42:0: /usr/include/linux/if_ppp.h:103:16: error: field 'b' has incomplete type /usr/include/linux/if_ppp.h:108:21: error: field 'b' has incomplete type --- src/ppp-manager/nm-ppp-manager.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c index e27c82b70..d410ebfab 100644 --- a/src/ppp-manager/nm-ppp-manager.c +++ b/src/ppp-manager/nm-ppp-manager.c @@ -39,6 +39,7 @@ #ifndef aligned_u64 #define aligned_u64 unsigned long long __attribute__((aligned(8))) #endif +#include #include #include "NetworkManagerUtils.h" From 3811a68389b9277533f2eee8372927ca6238653e Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Fri, 15 May 2015 16:38:10 +0200 Subject: [PATCH 3/7] systemd-dhcp: fix build with Linux 3.2.0 headers Fixes build on Ubuntu 12.04. systemd/src/libsystemd-network/dhcp-network.c: In function '_bind_raw_socket': systemd/src/libsystemd-network/dhcp-network.c:75:17: error: 'BPF_XOR' undeclared (first use in this function) systemd/src/libsystemd-network/dhcp-network.c:75:17: note: each undeclared identifier is reported only once for each function it appears in make[4]: *** [libsystemd_nm_la-dhcp-network.lo] Error 1 --- src/systemd/nm-sd-adapt.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/systemd/nm-sd-adapt.h b/src/systemd/nm-sd-adapt.h index 049b535c4..929ddc637 100644 --- a/src/systemd/nm-sd-adapt.h +++ b/src/systemd/nm-sd-adapt.h @@ -41,6 +41,11 @@ #include "nm-logging.h" +/* Missing in Linux 3.2.0, in Ubuntu 12.04 */ +#ifndef BPF_XOR +#define BPF_XOR 0xa0 +#endif + /*****************************************************************************/ static inline NMLogLevel From ccb0ca4493d8276c3a14b8c764c7fecc4fedc1fa Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Fri, 15 May 2015 18:27:19 +0200 Subject: [PATCH 4/7] libnm-core,libnm-util: avoid calling a constructor It yields completely unpredictable results on Ubuntu 12.04 (the global variable successfully comparing to NULL despite demonstrably not NULL). Possibly a toolchain bug. --- libnm-core/nm-setting.c | 8 +++++++- libnm-util/nm-setting.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index b78d9376f..0791b0d19 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -91,7 +91,7 @@ _nm_gtype_hash (gconstpointer v) return *((const GType *) v); } -static void __attribute__((constructor)) +static void _ensure_registered (void) { if (G_UNLIKELY (registered_settings == NULL)) { @@ -103,6 +103,12 @@ _ensure_registered (void) } } +static void __attribute__((constructor)) +_ensure_registered_constructor (void) +{ + _ensure_registered (); +} + #define _ensure_setting_info(self, priv) \ G_STMT_START { \ NMSettingPrivate *_priv_esi = (priv); \ diff --git a/libnm-util/nm-setting.c b/libnm-util/nm-setting.c index 105981bc3..35ae01daf 100644 --- a/libnm-util/nm-setting.c +++ b/libnm-util/nm-setting.c @@ -99,7 +99,7 @@ _nm_gtype_hash (gconstpointer v) return *((const GType *) v); } -static void __attribute__((constructor)) +static void _ensure_registered (void) { if (G_UNLIKELY (registered_settings == NULL)) { @@ -112,6 +112,12 @@ _ensure_registered (void) } } +static void __attribute__((constructor)) +_ensure_registered_constructor (void) +{ + _ensure_registered (); +} + #define _ensure_setting_info(self, priv) \ G_STMT_START { \ NMSettingPrivate *_priv_esi = (priv); \ From b9b7bb19586934dda19516ed37f50ca91d2e0f1b Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Fri, 15 May 2015 19:33:32 +0200 Subject: [PATCH 5/7] tests: avoid calling GLib.IOChannel.unix_new() The Ubuntu 12.04 introspection data don't contain it. However, the default constructor works just well and even looks a bit more Python-y. --- tools/test-networkmanager-service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py index 50803c887..6035fecd5 100755 --- a/tools/test-networkmanager-service.py +++ b/tools/test-networkmanager-service.py @@ -1148,7 +1148,7 @@ def main(): sys.exit(1) # Watch stdin; if it closes, assume our parent has crashed, and exit - io = GLib.IOChannel.unix_new(0) + io = GLib.IOChannel(0) io.add_watch(GLib.IOCondition.HUP, stdin_cb) # also quit after inactivity to ensure we don't stick around if the above fails somehow From e486a3803d74d406d014847cc88f50cd1cef87c7 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Sun, 17 May 2015 20:16:36 +0200 Subject: [PATCH 6/7] build: don't abort configure if there's no systemd devel headers Just disable systemd-logind session tracking instead. --- configure.ac | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 5f2eb2e85..442f25abd 100644 --- a/configure.ac +++ b/configure.ac @@ -364,12 +364,19 @@ AS_IF([test "$with_session_tracking" = "none"], [use_consolekit="no" use_systemd AS_IF([test -n "$with_systemd_logind" ], [use_systemd_logind="$with_systemd_logind"]) AS_IF([test -n "$with_consolekit" ], [use_consolekit="$with_consolekit"]) # defaults -AS_IF([test -z "$use_systemd_logind"], [use_systemd_logind="yes"]) +AS_IF([test -z "$use_systemd_logind"], [use_systemd_logind="auto"]) AS_IF([test -z "$use_consolekit"], [use_consolekit="yes"]) # output session_tracking= -if test "$use_systemd_logind" = "yes"; then - PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd], , [PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd-login])]) +if test "$use_systemd_logind" = "yes" -o "$use_systemd_logind" = "auto"; then + PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd], [have_systemd_logind=yes], [PKG_CHECK_MODULES(SYSTEMD_LOGIN, [libsystemd-login], [have_systemd_logind=yes], [have_systemd_logind=no])]) +else + have_systemd_logind=no +fi +if test "$use_systemd_logind" = "yes" -a "$have_systemd_logind" = "no"; then + AC_MSG_ERROR([You must have libsystemd installed to build with systemd-logind support.]) +fi +if test "$have_systemd_logind" = "yes"; then AC_SUBST(SYSTEMD_LOGIN_CFLAGS) AC_SUBST(SYSTEMD_LOGIN_LIBS) AC_DEFINE([SESSION_TRACKING_SYSTEMD], 1, [Define to 1 if libsystemd-login is available]) From 84021454eb0b126fda9cf29c46b7860f75c7ff8c Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Sun, 17 May 2015 20:49:06 +0200 Subject: [PATCH 7/7] build: don't default to -Werror It seems like a poor default for various downstream toolchains. We can't anticipate the compiler warnings for future compiler versions and older ones are prone to false positives. Also, older gdbus-codegen is known to generate code that triggers compiler warnings. Let's keep it enabled for maintainer builds and distcheck so that we're sure a tool chain that builds releases without warnings exists. --- Makefile.am | 2 +- autogen.sh | 2 +- m4/compiler_warnings.m4 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 18bb6c68c..2420f3bbf 100644 --- a/Makefile.am +++ b/Makefile.am @@ -59,7 +59,7 @@ DISTCLEANFILES = intltool-extract intltool-merge intltool-update pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = NetworkManager.pc -ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} +DISTCHECK_CONFIGURE_FLAGS = --enable-more-warnings=error CLEANFILES = cscope.in.out cscope.out cscope.po.out diff --git a/autogen.sh b/autogen.sh index 141bcf120..5ec9a5aa8 100755 --- a/autogen.sh +++ b/autogen.sh @@ -28,5 +28,5 @@ AUTOPOINT='intltoolize --automake --copy' autoreconf --force --install --verbose cd $olddir if test -z "$NOCONFIGURE"; then - exec $srcdir/configure --enable-maintainer-mode "$@" + exec $srcdir/configure --enable-maintainer-mode --enable-more-warnings=error "$@" fi diff --git a/m4/compiler_warnings.m4 b/m4/compiler_warnings.m4 index 5c8d20777..a1c4e1288 100644 --- a/m4/compiler_warnings.m4 +++ b/m4/compiler_warnings.m4 @@ -22,7 +22,7 @@ AC_DEFUN([NM_COMPILER_WARNING], [ AC_DEFUN([NM_COMPILER_WARNINGS], [AC_ARG_ENABLE(more-warnings, AS_HELP_STRING([--enable-more-warnings], [Possible values: no/yes/error]), - set_more_warnings="$enableval",set_more_warnings=error) + set_more_warnings="$enableval",set_more_warnings=yes) AC_MSG_CHECKING(for more warnings) if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then AC_MSG_RESULT(yes)