Ensure that nm_logging_setup() was called for all functions
where it actually makes a difference.
This is especially important for nm_logging_enabled(),
so that the behavior of the following is identical:
nm_log_info(LOGD_CORE, "hello world");
and
if (nm_logging_enabled (LOGL_INFO, LOGD_CORE))
nm_log_info(LOGD_CORE, "hello world");
Signed-off-by: Thomas Haller <thaller@redhat.com>
NMObjectCache was assuming there would never be more than one object
with the same path, but since NMClient is an NMObject, it was getting
cached too, so if you created two clients and then unreffed one of
them, it's possible the wrong one could get left in the cache, causing
a crash the next time the other one called nm_object_cache_clear().
Fix this by only adding NMObjects to the cache in the codepaths where
we also check to see if the object was already in the cache.
(This also means we can remove the "except" argument to
nm_object_cache_clear(), since the NMClient won't be cached any more.)
test-nm-client.c and test-remote-settings-client.c were using their
own assertion macros so they could kill the test service on assertion
failure. Except that some new code didn't get the memo and used the
g_assert* macros. Not to mention that sometimes the tests would crash
outside of an assertion macro.
We can make test-networkmanager-service.py notice that its parent has
crashed by opening a pipe between them and taking advantage of the
fact that the pipe will be automatically closed if the parent crashes.
So then test-networkmanager-service.py just has to watch for that, and
exit if the pipe closes.
Then that lets us drop the test_assert* macros and just use g_assert*
instead.
Use "TESTS = tests-nm-client test-remote-settings-client" rather than
overriding "check-local".
Add a script "libnm-test-launch.sh" that will handle redirecting the
test via dbus-launch if needed.
Rather than passing the path to the test service on the command line,
compile it into the test programs.
(Among other things, this makes it easier to run the test directly
from the command line.)
Out-of-tree build fails with:
../../src/dns-manager/nm-dns-manager.c:38:33: fatal error: libnm-util/nm-utils.h: No such file or directory
Fixes regression introduced by commit 7580cfef20.
Signed-off-by: Thomas Haller <thaller@redhat.com>
Use nm_utils_inet4_ntop() and nm_utils_inet6_ntop() instead.
And get rid of the unneeded error-checking.
gcc warns:
make[4]: Entering directory `/data/src/NetworkManager/src'
CC nm-dns-manager.lo
dns-manager/nm-dns-manager.c: In function 'merge_one_ip4_config':
dns-manager/nm-dns-manager.c:137:37: warning: ordered comparison of pointer with integer zero [-Wextra]
if (inet_ntop (AF_INET, &addr, buf, INET_ADDRSTRLEN) > 0)
^
dns-manager/nm-dns-manager.c:168:37: warning: ordered comparison of pointer with integer zero [-Wextra]
if (inet_ntop (AF_INET, &addr, buf, INET_ADDRSTRLEN) > 0)
^
dns-manager/nm-dns-manager.c: In function 'merge_one_ip6_config':
dns-manager/nm-dns-manager.c:197:64: warning: ordered comparison of pointer with integer zero [-Wextra]
if (inet_ntop (AF_INET, &(addr->s6_addr32[3]), buf, INET_ADDRSTRLEN) > 0)
^
dns-manager/nm-dns-manager.c:200:38: warning: ordered comparison of pointer with integer zero [-Wextra]
if (inet_ntop (AF_INET6, addr, buf, INET6_ADDRSTRLEN) > 0) {
^
Signed-off-by: Thomas Haller <thaller@redhat.com>
gcc warns:
make[4]: Entering directory `./NetworkManager/cli/src'
CC utils.o
utils.c: In function ‘parse_output_fields’:
utils.c:707:7: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
if (found) {
^
Signed-off-by: Thomas Haller <thaller@redhat.com>
gcc warns:
make[4]: Entering directory `./NetworkManager/libnm-util'
CC nm-value-transforms.lo
nm-value-transforms.c: In function '_nm_utils_convert_op_array_to_string':
nm-value-transforms.c:121:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
if (i > 0)
^
nm-value-transforms.c: In function '_nm_utils_convert_string_array_to_string':
nm-value-transforms.c:121:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
if (i > 0)
^
make[7]: Entering directory `./NetworkManager/src/settings/plugins/ifcfg-rh'
CC reader.lo
reader.c: In function 'make_wired_setting':
reader.c:3295:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
if (!found)
^
reader.c: In function 'wireless_connection_from_ifcfg':
reader.c:3295:6: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
if (!found)
^
Signed-off-by: Thomas Haller <thaller@redhat.com>
gcc warns:
make[4]: Entering directory `./NetworkManager/cli/src'
CC connections.o
connections.c: In function ‘complete_connection_by_type’:
connections.c:4235:18: error: ‘mtu_int’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
g_object_set (s_wired, NM_SETTING_WIRED_MTU, mtu_int, NULL);
^
Signed-off-by: Thomas Haller <thaller@redhat.com>
gcc warns:
make[5]: Entering directory `./NetworkManager/src/platform/tests'
CC platform.o
platform.c: In function ‘do_ip6_route_add’:
platform.c:696:2: error: ‘plen’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
return nm_platform_ip6_route_add (ifindex, NM_PLATFORM_SOURCE_USER,
^
platform.c: In function ‘do_ip6_route_delete’:
platform.c:724:2: error: ‘plen’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
return nm_platform_ip6_route_delete (ifindex, network, plen, metric);
^
platform.c: In function ‘do_ip4_route_delete’:
[...]
Signed-off-by: Thomas Haller <thaller@redhat.com>
clang warns:
make[5]: Entering directory `./NetworkManager/src/platform/tests'
CC test_link_fake-test-link.o
test-link.c:133:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]
}
^
test-link.c:191:10: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
char *stdout = NULL;
^
/usr/include/stdio.h:173:16: note: expanded from macro 'stdout'
#define stdout stdout
^
/usr/include/stdio.h:169:25: note: previous declaration is here
extern struct _IO_FILE *stdout; /* Standard output stream. */
^
Signed-off-by: Thomas Haller <thaller@redhat.com>
NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED would map
to NM_DEVICE_STATE_REASON_NOW_MANAGED.
clang warns:
make[6]: Entering directory `./NetworkManager/src/devices/wifi'
CC nm-device-olpc-mesh.lo
nm-device-olpc-mesh.c:193:28: error: implicit conversion from enumeration type 'enum NMVPNConnectionStateReason' to different enumeration type 'NMDeviceStateReason' [-Werror,-Wenum-conversion]
NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nm-device-olpc-mesh.c:319:27: error: implicit conversion from enumeration type 'enum NMVPNConnectionStateReason' to different enumeration type 'NMDeviceStateReason' [-Werror,-Wenum-conversion]
NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Thomas Haller <thaller@redhat.com>
g_error() does not return, but clang seems not to understand that
and gives the following warning.
make[4]: Entering directory `./NetworkManager/src'
CC NetworkManagerUtils.lo
NetworkManagerUtils.c:1584:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]
}
^
Signed-off-by: Thomas Haller <thaller@redhat.com>
This bug has no real consequense, because the numerical values of the
enum values are identical.
clang warns:
make[4]: Entering directory `./NetworkManager/src'
CC nm-vpn-connection.lo
vpn-manager/nm-vpn-connection.c:179:10: error: implicit conversion from enumeration type 'VpnState' to different enumeration type 'NMVPNConnectionState' (aka 'enum NMVPNConnectionState') [-Werror,-Wenum-conversion]
return STATE_UNKNOWN;
~~~~~~ ^~~~~~~~~~~~~
Signed-off-by: Thomas Haller <thaller@redhat.com>
Since kernel commit 8fe02e167efa8ed4a4503a5eedc0f49fcb7e3eb9,
the value NL80211_FREQUENCY_ATTR_NO_IR replaces PASSIVE_SCAN
and NO_IBSS. Hence their numerical values are identical and
cause the following compiler warning.
clang warns:
make[4]: Entering directory `./NetworkManager/src'
CC wifi-utils-nl80211.lo
platform/wifi/wifi-utils-nl80211.c:683:48: error: initializer overrides prior initialization of this subobject [-Werror,-Winitializer-overrides]
[NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
^~~~~~~~
platform/wifi/wifi-utils-nl80211.c:682:53: note: previous initialization is here
[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] = { .type = NLA_FLAG },
^~~~~~~~
Signed-off-by: Thomas Haller <thaller@redhat.com>
The variable is not actually unused, because it is used
to free the nl_object instance.
clang warns:
make[4]: Entering directory `./NetworkManager/src'
CC nm-linux-platform.lo
platform/nm-linux-platform.c:1746:35: error: unused variable 'obj_cleanup' [-Werror,-Wunused-variable]
auto_nl_object struct nl_object *obj_cleanup = obj;
^
Signed-off-by: Thomas Haller <thaller@redhat.com>
Due to a bug, when dcb fails it would change the device state
to NM_DEVICE_STATE_UNKNOWN (zero), instead of NM_DEVICE_STATE_FAILED.
clang warns:
make[4]: Entering directory `./NetworkManager/src'
CC nm-device-ethernet.lo
devices/nm-device-ethernet.c:1237:30: error: implicit conversion from enumeration type 'enum NMActStageReturn' to different enumeration type 'NMDeviceState' [-Werror,-Wenum-conversion]
NM_ACT_STAGE_RETURN_FAILURE,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
devices/nm-device-ethernet.c:1261:30: error: implicit conversion from enumeration type 'enum NMActStageReturn' to different enumeration type 'NMDeviceState' [-Werror,-Wenum-conversion]
NM_ACT_STAGE_RETURN_FAILURE,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Thomas Haller <thaller@redhat.com>
clang warns:
make[4]: Entering directory `./NetworkManager/libnm-util'
CC nm-setting-8021x.lo
nm-setting-8021x.c:1824:17: error: implicit conversion from enumeration type 'NMCryptoFileFormat' to different enumeration type 'NMSetting8021xCKFormat' [-Werror,-Wenum-conversion]
*out_format = format;
~ ^~~~~~
nm-setting-8021x.c:2135:17: error: implicit conversion from enumeration type 'NMCryptoFileFormat' to different enumeration type 'NMSetting8021xCKFormat' [-Werror,-Wenum-conversion]
*out_format = format;
~ ^~~~~~
Signed-off-by: Thomas Haller <thaller@redhat.com>
For clang, the defines G_GNUC_BEGIN_IGNORE_DEPRECATIONS and
G_GNUC_END_IGNORE_DEPRECATIONS are not working. Redefine them
for clang in our glib compatibility wrapper.
Signed-off-by: Thomas Haller <thaller@redhat.com>
clang does not exit with error when it is called with an
unrecognized (warning) option. Instead it just prints
a warning that makes the configure script believe the
warning is supported. Later, during build we might pass
-Werror, which causes clang to fail due to unrecognized
arguments.
Fix the script to detect compiler warnings by passing
'-Werror=unknown-warning-option', which lets clang fail too.
Signed-off-by: Thomas Haller <thaller@redhat.com>
- register a weak references and ensure that the connection
is removed when expected.
- disconnect the vis_new_connection_cb() handler
Signed-off-by: Thomas Haller <thaller@redhat.com>
test_make_invisible() forgot to disconnect handler invis_removed_cb().
Later, during test_remove_connection(), the connection will be eventually
removed and the callback will corrupt the stack by writing to the '&done'
user data.
Signed-off-by: Thomas Haller <thaller@redhat.com>
Now that nm-version.h.in lives in libnm-util/, a stale nm-version.h
from include/ messes up the build with errors about NM_VERSION_*.
Clean both old & new nm-version.h on 'make clean' so that we can
switch branches between nm-0-9-8, nm-0-9-10, and git master and
just run 'make clean' and get things to work.
We cannot rely on connectivity data freeing to disconnect the signal,
because the simple async result might be kept alive by external
code (for example the language runtime for JS), but we must not
call dbus_g_proxy_cancel_call() if that cancellable is cancelled or
reused afterwards.
https://bugzilla.gnome.org/show_bug.cgi?id=733915
When building with '--disable-concheck' with libsoup installed,
configure would set HAVE_LIBSOUP. But without connection
checking, we didn't link against libsoup, resulting in a
linker error.
Add a new configure option '--with-libsoup' / '--without-libsoup'
to control whether linking against libsoup.
The combination '--without-libsoup --enable-concheck' does not
make sense.
https://bugzilla.gnome.org/show_bug.cgi?id=734062
Signed-off-by: Thomas Haller <thaller@redhat.com>
Some subdirectories of src/ encapsulate large chunks of functionality,
but src/config/, src/logging/, and src/posix-signals/ are really only
separated out because they used to be built into separate
sub-libraries that were needed either for test programs, or to prevent
circular dependencies. Since this is no longer relevant, simplify
things by moving their files back into the main source directory.
Move libnm-glib's test-fake-nm.py and test-remote-settings-service.py
to tools/, merge them together into a single program, and fix a few
bugs (notably some missing signal emissions in the Settings service).
Although they are currently only used by libnm-glib's tests, they are
generic enough that they could be used by other code in the future
(and in particular, they will be used by libnm's tests as well).
The remaining contents of the test/ directory are:
- 2 python example programs that aren't as good as the ones in examples/
- a test of the deprecated libnm_glib API which isn't as good as the one
in libnm-glib/
- A DHCP-related test program that hasn't been relevant since 2005
Let's just kill it all
Create a new clients/ subdirectory at the top level, and move cli/ and
tui/ into it, as well as nm-online.c (which was previously in test/,
which made no sense).
cli/ was split into two subdirectories, src/ and completion/. While
this does simplify things (given that the completion file and the
binary both need to be named "nmcli"), it bloats the source tree, and
we can work around it by just renaming the completion file at install
time. Then we can combine the two directories into one and just have
it all under clients/cli/.