diff options
author | Thomas Haller <thaller@redhat.com> | 2021-06-28 13:35:57 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-06-28 13:35:57 +0200 |
commit | c90a52eb23c10a6d2339c1097460b8a515440ce8 (patch) | |
tree | be68712a48d78bafa6146f88a526d63e74959516 | |
parent | f9040c3ccae84b9b483f015f8e7bd2e503132f82 (diff) | |
parent | 61d2af3518196512b70fefc3c551221cb8905f6a (diff) | |
download | NetworkManager-c90a52eb23c10a6d2339c1097460b8a515440ce8.tar.gz |
all: merge branch 'th/avoid-numeric-gsource-ids'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/904
-rwxr-xr-x | contrib/scripts/checkpatch.pl | 1 | ||||
-rw-r--r-- | src/core/devices/bluetooth/nm-bluez5-dun.c | 44 | ||||
-rw-r--r-- | src/core/devices/bluetooth/tests/nm-bt-test.c | 2 | ||||
-rw-r--r-- | src/core/devices/nm-acd-manager.c | 8 | ||||
-rw-r--r-- | src/core/devices/nm-device.c | 28 | ||||
-rw-r--r-- | src/core/devices/wifi/nm-device-wifi.c | 7 | ||||
-rw-r--r-- | src/core/dhcp/nm-dhcp-nettools.c | 4 | ||||
-rw-r--r-- | src/core/dns/nm-dns-systemd-resolved.c | 19 | ||||
-rw-r--r-- | src/core/main-utils.c | 1 | ||||
-rw-r--r-- | src/core/ndisc/nm-lndp-ndisc.c | 4 | ||||
-rw-r--r-- | src/core/nm-auth-utils.c | 8 | ||||
-rw-r--r-- | src/core/nm-connectivity.c | 12 | ||||
-rw-r--r-- | src/core/nm-iface-helper.c | 1 | ||||
-rw-r--r-- | src/libnm-glib-aux/nm-glib.h | 17 | ||||
-rw-r--r-- | src/libnm-glib-aux/nm-macros-internal.h | 1 | ||||
-rw-r--r-- | src/libnm-glib-aux/nm-shared-utils.c | 1 | ||||
-rw-r--r-- | src/libnm-glib-aux/nm-shared-utils.h | 33 | ||||
-rw-r--r-- | src/libnm-std-aux/nm-std-aux.h | 1 | ||||
-rw-r--r-- | src/nm-dispatcher/nm-dispatcher.c | 1 | ||||
-rw-r--r-- | src/nmcli/nmcli.c | 1 |
20 files changed, 86 insertions, 108 deletions
diff --git a/contrib/scripts/checkpatch.pl b/contrib/scripts/checkpatch.pl index c64f69db9b..c535fd0a93 100755 --- a/contrib/scripts/checkpatch.pl +++ b/contrib/scripts/checkpatch.pl @@ -191,6 +191,7 @@ complain ("This gtk-doc annotation looks wrong") if $line =~ /\*.*\( *(transfer- complain ("Prefer nm_assert() or g_return*() to g_assert*()") if $line =~ /g_assert/ and (not $filename =~ /\/tests\//) and (not $filename =~ /\/nm-test-/); complain ("Use gs_free_error with GError variables") if $line =~ /\bgs_free\b +GError *\*/; complain ("Don't use strcmp/g_strcmp0 unless you need to sort. Consider nm_streq()/nm_streq0(),NM_IN_STRSET() for testing equality") if $line =~ /\b(strcmp|g_strcmp0)\b/; +complain ("Don't use API that uses the numeric source id. Instead, use GSource and API like nm_g_idle_add_source(), nm_clear_g_source_inst(), etc.") if $line =~ /\b(g_idle_add|g_idle_add_full|g_timeout_add|g_timeout_add_seconds|g_source_remove|nm_clear_g_source)\b/; #complain ("Use spaces instead of tabs") if $line =~ /\t/; # Further on we process stuff without comments. diff --git a/src/core/devices/bluetooth/nm-bluez5-dun.c b/src/core/devices/bluetooth/nm-bluez5-dun.c index e29884d8b9..7efbfaf4c6 100644 --- a/src/core/devices/bluetooth/nm-bluez5-dun.c +++ b/src/core/devices/bluetooth/nm-bluez5-dun.c @@ -182,25 +182,18 @@ _connect_open_tty(NMBluez5DunContext *context) nm_strerror_native(errsv), errsv); context->cdat->connect_open_tty_started_at = nm_utils_get_monotonic_timestamp_nsec(); - context->cdat->source = nm_g_timeout_source_new(100, - G_PRIORITY_DEFAULT, - _connect_open_tty_retry_cb, - context, - NULL); - g_source_attach(context->cdat->source, NULL); + context->cdat->source = + nm_g_timeout_add_source(100, _connect_open_tty_retry_cb, context); } return -errsv; } context->rfcomm_tty_fd = fd; - context->rfcomm_tty_poll_source = nm_g_unix_fd_source_new(context->rfcomm_tty_fd, + context->rfcomm_tty_poll_source = nm_g_unix_fd_add_source(context->rfcomm_tty_fd, G_IO_ERR | G_IO_HUP, - G_PRIORITY_DEFAULT, _rfcomm_tty_poll_cb, - context, - NULL); - g_source_attach(context->rfcomm_tty_poll_source, NULL); + context); _context_invoke_callback_success(context); return 0; @@ -369,13 +362,10 @@ _connect_socket_connect(NMBluez5DunContext *context) context->dst_str, context->rfcomm_channel); - context->cdat->source = nm_g_unix_fd_source_new(context->rfcomm_sock_fd, + context->cdat->source = nm_g_unix_fd_add_source(context->rfcomm_sock_fd, G_IO_OUT, - G_PRIORITY_DEFAULT, _connect_socket_connect_cb, - context, - NULL); - g_source_attach(context->cdat->source, NULL); + context); return; } @@ -567,12 +557,8 @@ _connect_sdp_io_cb(int fd, GIOCondition condition, gpointer user_data) nm_strerror_native(errsv), errsv); nm_clear_g_source_inst(&context->cdat->source); - context->cdat->source = nm_g_timeout_source_new(1000, - G_PRIORITY_DEFAULT, - _connect_sdp_session_start_on_idle_cb, - context, - NULL); - g_source_attach(context->cdat->source, NULL); + context->cdat->source = + nm_g_timeout_add_source(1000, _connect_sdp_session_start_on_idle_cb, context); return G_SOURCE_REMOVE; } @@ -616,13 +602,10 @@ _connect_sdp_io_cb(int fd, GIOCondition condition, gpointer user_data) } /* Set callback responsible for update the internal SDP transaction */ - context->cdat->source = nm_g_unix_fd_source_new(fd, + context->cdat->source = nm_g_unix_fd_add_source(fd, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, - G_PRIORITY_DEFAULT, _connect_sdp_search_io_cb, - context, - NULL); - g_source_attach(context->cdat->source, NULL); + context); done: if (error) @@ -664,13 +647,10 @@ _connect_sdp_session_start(NMBluez5DunContext *context, GError **error) return FALSE; } - context->cdat->source = nm_g_unix_fd_source_new(sdp_get_socket(context->cdat->sdp_session), + context->cdat->source = nm_g_unix_fd_add_source(sdp_get_socket(context->cdat->sdp_session), G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL, - G_PRIORITY_DEFAULT, _connect_sdp_io_cb, - context, - NULL); - g_source_attach(context->cdat->source, NULL); + context); return TRUE; } diff --git a/src/core/devices/bluetooth/tests/nm-bt-test.c b/src/core/devices/bluetooth/tests/nm-bt-test.c index 0fc8aa872c..548e7249a9 100644 --- a/src/core/devices/bluetooth/tests/nm-bt-test.c +++ b/src/core/devices/bluetooth/tests/nm-bt-test.c @@ -2,8 +2,6 @@ #include "src/core/nm-default-daemon.h" -#include <glib-unix.h> - #include "devices/bluetooth/nm-bluez5-dun.h" #include "nm-test-utils-core.h" diff --git a/src/core/devices/nm-acd-manager.c b/src/core/devices/nm-acd-manager.c index 995abacded..eb2da53a12 100644 --- a/src/core/devices/nm-acd-manager.c +++ b/src/core/devices/nm-acd-manager.c @@ -347,9 +347,7 @@ nm_acd_manager_start_probe(NMAcdManager *self, guint timeout) nm_assert(!self->event_source); n_acd_get_fd(self->acd, &fd); - self->event_source = - nm_g_unix_fd_source_new(fd, G_IO_IN, G_PRIORITY_DEFAULT, acd_event, self, NULL); - g_source_attach(self->event_source, NULL); + self->event_source = nm_g_unix_fd_add_source(fd, G_IO_IN, acd_event, self); return success ? 0 : -NME_UNSPEC; } @@ -434,9 +432,7 @@ nm_acd_manager_announce_addresses(NMAcdManager *self) if (!self->event_source) { n_acd_get_fd(self->acd, &fd); - self->event_source = - nm_g_unix_fd_source_new(fd, G_IO_IN, G_PRIORITY_DEFAULT, acd_event, self, NULL); - g_source_attach(self->event_source, NULL); + self->event_source = nm_g_unix_fd_add_source(fd, G_IO_IN, acd_event, self); } return success ? 0 : -NME_UNSPEC; diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 1c70ecb328..d963863353 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -686,10 +686,10 @@ typedef struct _NMDevicePrivate { guint sriov_reset_pending; struct { - guint timeout_id; - guint refresh_rate_ms; - guint64 tx_bytes; - guint64 rx_bytes; + GSource *timeout_source; + guint refresh_rate_ms; + guint64 tx_bytes; + guint64 rx_bytes; } stats; bool mtu_force_set_done : 1; @@ -3341,7 +3341,7 @@ _stats_set_refresh_rate(NMDevice *self, guint refresh_rate_ms) if (_stats_refresh_rate_real(old_rate) == refresh_rate_ms) return; - nm_clear_g_source(&priv->stats.timeout_id); + nm_clear_g_source_inst(&priv->stats.timeout_source); if (!refresh_rate_ms) return; @@ -3353,7 +3353,7 @@ _stats_set_refresh_rate(NMDevice *self, guint refresh_rate_ms) if (ifindex > 0) nm_platform_link_refresh(nm_device_get_platform(self), ifindex); - priv->stats.timeout_id = g_timeout_add(refresh_rate_ms, _stats_timeout_cb, self); + priv->stats.timeout_source = nm_g_timeout_add_source(refresh_rate_ms, _stats_timeout_cb, self); } /*****************************************************************************/ @@ -5920,7 +5920,7 @@ realize_start_setup(NMDevice * self, NMPlatform * platform; NMDeviceCapabilities capabilities = 0; NMConfig * config; - guint real_rate; + guint refresh_rate_ms; gboolean unmanaged; /* plink is a NMPlatformLink type, however, we require it to come from the platform @@ -6028,10 +6028,12 @@ realize_start_setup(NMDevice * self, nm_device_set_carrier_from_platform(self); - nm_assert(!priv->stats.timeout_id); - real_rate = _stats_refresh_rate_real(priv->stats.refresh_rate_ms); - if (real_rate) - priv->stats.timeout_id = g_timeout_add(real_rate, _stats_timeout_cb, self); + nm_assert(!priv->stats.timeout_source); + refresh_rate_ms = _stats_refresh_rate_real(priv->stats.refresh_rate_ms); + if (refresh_rate_ms > 0) { + priv->stats.timeout_source = + nm_g_timeout_add_source(refresh_rate_ms, _stats_timeout_cb, self); + } klass->realize_start_notify(self, plink); @@ -6217,7 +6219,7 @@ nm_device_unrealize(NMDevice *self, gboolean remove_resources, GError **error) _notify(self, PROP_PHYSICAL_PORT_ID); } - nm_clear_g_source(&priv->stats.timeout_id); + nm_clear_g_source_inst(&priv->stats.timeout_source); _stats_update_counters(self, 0, 0); priv->hw_addr_len_ = 0; @@ -18378,7 +18380,7 @@ dispose(GObject *object) nm_clear_g_source(&priv->check_delete_unrealized_id); - nm_clear_g_source(&priv->stats.timeout_id); + nm_clear_g_source_inst(&priv->stats.timeout_source); carrier_disconnected_action_cancel(self); diff --git a/src/core/devices/wifi/nm-device-wifi.c b/src/core/devices/wifi/nm-device-wifi.c index fca2fde515..c5b6dddecd 100644 --- a/src/core/devices/wifi/nm-device-wifi.c +++ b/src/core/devices/wifi/nm-device-wifi.c @@ -1673,12 +1673,7 @@ _scan_supplicant_request_scan_cb(NMSupplicantInterface *supp_iface, * Artificially keep the scanning state on, for another SCAN_EXTRA_DELAY_MSEC msec. */ nm_clear_g_source_inst(&priv->scan_request_delay_source); priv->scan_request_delay_source = - nm_g_source_attach(nm_g_timeout_source_new(SCAN_EXTRA_DELAY_MSEC, - G_PRIORITY_DEFAULT, - _scan_request_delay_cb, - self, - NULL), - NULL); + nm_g_timeout_add_source(SCAN_EXTRA_DELAY_MSEC, _scan_request_delay_cb, self); g_clear_object(&priv->scan_request_cancellable); _scan_notify_is_scanning(self); diff --git a/src/core/dhcp/nm-dhcp-nettools.c b/src/core/dhcp/nm-dhcp-nettools.c index f755eebca3..584d99e28a 100644 --- a/src/core/dhcp/nm-dhcp-nettools.c +++ b/src/core/dhcp/nm-dhcp-nettools.c @@ -969,9 +969,7 @@ nettools_create(NMDhcpNettools *self, GError **error) n_dhcp4_client_get_fd(priv->client, &fd); - priv->event_source = - nm_g_unix_fd_source_new(fd, G_IO_IN, G_PRIORITY_DEFAULT, dhcp4_event_cb, self, NULL); - g_source_attach(priv->event_source, NULL); + priv->event_source = nm_g_unix_fd_add_source(fd, G_IO_IN, dhcp4_event_cb, self); return TRUE; } diff --git a/src/core/dns/nm-dns-systemd-resolved.c b/src/core/dns/nm-dns-systemd-resolved.c index 4b8c4f9418..61d52771df 100644 --- a/src/core/dns/nm-dns-systemd-resolved.c +++ b/src/core/dns/nm-dns-systemd-resolved.c @@ -422,12 +422,7 @@ ensure_resolved_running(NMDnsSystemdResolved *self) priv->try_start_blocked = TRUE; priv->try_start_timeout_source = - nm_g_source_attach(nm_g_timeout_source_new(4000, - G_PRIORITY_DEFAULT, - _ensure_resolved_running_timeout, - self, - NULL), - NULL); + nm_g_timeout_add_source(4000, _ensure_resolved_running_timeout, self); nm_dbus_connection_call_start_service_by_name(priv->dbus_connection, SYSTEMD_RESOLVED_DBUS_SERVICE, @@ -821,19 +816,13 @@ _resolve_start(NMDnsSystemdResolved *self, NMDnsSystemdResolvedResolveHandle *ha _LOG2T(handle, "systemd-resolved not running. Failing on idle..."); nm_assert(!handle->timeout_source); handle->is_failing_on_idle = TRUE; - handle->timeout_source = nm_g_source_attach( - nm_g_idle_source_new(G_PRIORITY_DEFAULT, _resolve_failing_on_idle, handle, NULL), - NULL); + handle->timeout_source = nm_g_idle_add_source(_resolve_failing_on_idle, handle); return; } if (!handle->timeout_source) { - handle->timeout_source = nm_g_source_attach(nm_g_timeout_source_new(handle->timeout_msec, - G_PRIORITY_DEFAULT, - _resolve_handle_timeout, - handle, - NULL), - NULL); + handle->timeout_source = + nm_g_timeout_add_source(handle->timeout_msec, _resolve_handle_timeout, handle); } if (is_running == NM_TERNARY_DEFAULT) { diff --git a/src/core/main-utils.c b/src/core/main-utils.c index 9bc497ca46..48f143c3a8 100644 --- a/src/core/main-utils.c +++ b/src/core/main-utils.c @@ -14,7 +14,6 @@ #include <locale.h> #include <glib/gstdio.h> -#include <glib-unix.h> #include "main-utils.h" #include "NetworkManagerUtils.h" diff --git a/src/core/ndisc/nm-lndp-ndisc.c b/src/core/ndisc/nm-lndp-ndisc.c index f11178f824..996c877571 100644 --- a/src/core/ndisc/nm-lndp-ndisc.c +++ b/src/core/ndisc/nm-lndp-ndisc.c @@ -599,9 +599,7 @@ start(NMNDisc *ndisc) fd = ndp_get_eventfd(priv->ndp); - priv->event_source = - nm_g_unix_fd_source_new(fd, G_IO_IN, G_PRIORITY_DEFAULT, event_ready, ndisc, NULL); - g_source_attach(priv->event_source, NULL); + priv->event_source = nm_g_unix_fd_add_source(fd, G_IO_IN, event_ready, ndisc); /* Flush any pending messages to avoid using obsolete information */ event_ready(fd, 0, ndisc); diff --git a/src/core/nm-auth-utils.c b/src/core/nm-auth-utils.c index 006264dd28..da17b1a4cc 100644 --- a/src/core/nm-auth-utils.c +++ b/src/core/nm-auth-utils.c @@ -124,12 +124,8 @@ _cancellable_idle_cb(gpointer user_data) static void _cancellable_on_idle(NMAuthChain *self) { - if (self->cancellable_idle_source) - return; - - self->cancellable_idle_source = - nm_g_idle_source_new(G_PRIORITY_DEFAULT, _cancellable_idle_cb, self, NULL); - g_source_attach(self->cancellable_idle_source, NULL); + if (!self->cancellable_idle_source) + self->cancellable_idle_source = nm_g_idle_add_source(_cancellable_idle_cb, self); } GCancellable * diff --git a/src/core/nm-connectivity.c b/src/core/nm-connectivity.c index 85d41b4919..2c412341b7 100644 --- a/src/core/nm-connectivity.c +++ b/src/core/nm-connectivity.c @@ -13,7 +13,6 @@ #include <curl/curl.h> #endif #include <linux/rtnetlink.h> -#include <glib-unix.h> #include "c-list/src/c-list.h" #include "libnm-core-intern/nm-core-internal.h" @@ -509,15 +508,8 @@ multi_socket_cb(CURL *e_handle, curl_socket_t fd, int what, void *userdata, void else condition = 0; - if (condition) { - fdp->source = nm_g_unix_fd_source_new(fd, - condition, - G_PRIORITY_DEFAULT, - _con_curl_socketevent_cb, - fdp, - NULL); - g_source_attach(fdp->source, NULL); - } + if (condition) + fdp->source = nm_g_unix_fd_add_source(fd, condition, _con_curl_socketevent_cb, fdp); } return CURLM_OK; diff --git a/src/core/nm-iface-helper.c b/src/core/nm-iface-helper.c index 296bf091ee..fedb480e3d 100644 --- a/src/core/nm-iface-helper.c +++ b/src/core/nm-iface-helper.c @@ -5,7 +5,6 @@ #include "src/core/nm-default-daemon.h" -#include <glib-unix.h> #include <getopt.h> #include <locale.h> #include <stdlib.h> diff --git a/src/libnm-glib-aux/nm-glib.h b/src/libnm-glib-aux/nm-glib.h index 66e5c16e14..0af9e21f29 100644 --- a/src/libnm-glib-aux/nm-glib.h +++ b/src/libnm-glib-aux/nm-glib.h @@ -684,12 +684,21 @@ g_hash_table_steal_extended(GHashTable * hash_table, /*****************************************************************************/ -__attribute__(( - __deprecated__("Don't use g_cancellable_reset(). Create a new cancellable instead."))) void -_nm_g_cancellable_reset(GCancellable *cancellable); +_nm_deprecated("Don't use this API") void _nm_forbidden_glib_api_0(void); +_nm_deprecated("Don't use this API") void _nm_forbidden_glib_api_n(gconstpointer arg0, ...); #undef g_cancellable_reset -#define g_cancellable_reset(cancellable) _nm_g_cancellable_reset(cancellable) +#define g_cancellable_reset(cancellable) _nm_forbidden_glib_api_n(cancellable) + +#undef g_idle_remove_by_data +#define g_idle_remove_by_data(data) _nm_forbidden_glib_api_n(data) + +#undef g_source_remove_by_funcs_user_data +#define g_source_remove_by_funcs_user_data(funcs, user_data) \ + _nm_forbidden_glib_api_n(funcs, user_data) + +#undef g_source_remove_by_user_data +#define g_source_remove_by_user_data(user_data) _nm_forbidden_glib_api_n(user_data) /*****************************************************************************/ diff --git a/src/libnm-glib-aux/nm-macros-internal.h b/src/libnm-glib-aux/nm-macros-internal.h index 23cf2f55a7..e11742a15b 100644 --- a/src/libnm-glib-aux/nm-macros-internal.h +++ b/src/libnm-glib-aux/nm-macros-internal.h @@ -13,6 +13,7 @@ #include <string.h> #include <gio/gio.h> +#include <glib-unix.h> /*****************************************************************************/ diff --git a/src/libnm-glib-aux/nm-shared-utils.c b/src/libnm-glib-aux/nm-shared-utils.c index e42e0fe590..908f6bec8e 100644 --- a/src/libnm-glib-aux/nm-shared-utils.c +++ b/src/libnm-glib-aux/nm-shared-utils.c @@ -12,7 +12,6 @@ #include <poll.h> #include <fcntl.h> #include <sys/syscall.h> -#include <glib-unix.h> #include <net/if.h> #include <net/ethernet.h> diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h index 7bd17c3986..49de9e12b9 100644 --- a/src/libnm-glib-aux/nm-shared-utils.h +++ b/src/libnm-glib-aux/nm-shared-utils.h @@ -1610,6 +1610,19 @@ nm_g_variant_builder_add_sv_str(GVariantBuilder *builder, const char *key, const static inline void nm_g_source_destroy_and_unref(GSource *source) { + /* Note that calling g_source_destroy() on a currently attached source, + * will destroy the user-data of the callback right away (and not only + * during the last g_source_unref()). + * + * It also means, that if the user data itself has the reference to the + * source, then this will lead to crash: + * + * g_source_destroy(user_data->my_source); + * // ups, user_data was destroyed (if source was attached). + * g_source_unref(user_data->my_source); + * + * nm_g_source_destroy_and_unref() and nm_clear_g_source_inst() does not + * suffer from this problem. */ g_source_destroy(source); g_source_unref(source); } @@ -1707,7 +1720,7 @@ nm_g_source_attach(GSource *source, GMainContext *context) static inline GSource * nm_g_idle_add_source(GSourceFunc func, gpointer user_data) { - /* G convenience function to attach a new timeout source to the default GMainContext. + /* A convenience function to attach a new timeout source to the default GMainContext. * In that sense it's very similar to g_idle_add() except that it returns a * reference to the new source. */ return nm_g_source_attach(nm_g_idle_source_new(G_PRIORITY_DEFAULT, func, user_data, NULL), @@ -1717,7 +1730,7 @@ nm_g_idle_add_source(GSourceFunc func, gpointer user_data) static inline GSource * nm_g_timeout_add_source(guint timeout_msec, GSourceFunc func, gpointer user_data) { - /* G convenience function to attach a new timeout source to the default GMainContext. + /* A convenience function to attach a new timeout source to the default GMainContext. * In that sense it's very similar to g_timeout_add() except that it returns a * reference to the new source. */ return nm_g_source_attach( @@ -1728,7 +1741,7 @@ nm_g_timeout_add_source(guint timeout_msec, GSourceFunc func, gpointer user_data static inline GSource * nm_g_timeout_add_source_seconds(guint timeout_sec, GSourceFunc func, gpointer user_data) { - /* G convenience function to attach a new timeout source to the default GMainContext. + /* A convenience function to attach a new timeout source to the default GMainContext. * In that sense it's very similar to g_timeout_add_seconds() except that it returns a * reference to the new source. */ return nm_g_source_attach( @@ -1757,6 +1770,20 @@ nm_g_timeout_add_source_approx(guint timeout_msec, return nm_g_source_attach(source, NULL); } +static inline GSource * +nm_g_unix_fd_add_source(int fd, + GIOCondition condition, + GUnixFDSourceFunc function, + gpointer user_data) +{ + /* A convenience function to attach a new unix-fd source to the default GMainContext. + * In that sense it's very similar to g_unix_fd_add() except that it returns a + * reference to the new source. */ + return nm_g_source_attach( + nm_g_unix_fd_source_new(fd, condition, G_PRIORITY_DEFAULT, function, user_data, NULL), + NULL); +} + NM_AUTO_DEFINE_FCN0(GMainContext *, _nm_auto_unref_gmaincontext, g_main_context_unref); #define nm_auto_unref_gmaincontext nm_auto(_nm_auto_unref_gmaincontext) diff --git a/src/libnm-std-aux/nm-std-aux.h b/src/libnm-std-aux/nm-std-aux.h index 49ec8aab0c..5bcb311d3a 100644 --- a/src/libnm-std-aux/nm-std-aux.h +++ b/src/libnm-std-aux/nm-std-aux.h @@ -24,6 +24,7 @@ #define _nm_section(s) __attribute__((__section__(s))) #define _nm_alignof(type) __alignof(type) #define _nm_alignas(type) _nm_align(_nm_alignof(type)) +#define _nm_deprecated(msg) __attribute__((__deprecated__(msg))) #define nm_auto(fcn) __attribute__((__cleanup__(fcn))) /* This is required to make LTO working. diff --git a/src/nm-dispatcher/nm-dispatcher.c b/src/nm-dispatcher/nm-dispatcher.c index 5df329592d..6751a2cb0b 100644 --- a/src/nm-dispatcher/nm-dispatcher.c +++ b/src/nm-dispatcher/nm-dispatcher.c @@ -16,7 +16,6 @@ #include <sys/stat.h> #include <sys/wait.h> #include <arpa/inet.h> -#include <glib-unix.h> #include "libnm-core-aux-extern/nm-dispatcher-api.h" #include "nm-dispatcher-utils.h" diff --git a/src/nmcli/nmcli.c b/src/nmcli/nmcli.c index e592e05482..c8f9fb5641 100644 --- a/src/nmcli/nmcli.c +++ b/src/nmcli/nmcli.c @@ -14,7 +14,6 @@ #include <termios.h> #include <unistd.h> #include <locale.h> -#include <glib-unix.h> #include <readline/readline.h> #include <readline/history.h> |