dns/resolved: adjust coding style

This commit is contained in:
Thomas Haller
2016-09-06 14:35:14 +02:00
parent 818023c257
commit 040bf6c1e8
2 changed files with 55 additions and 50 deletions

View File

@@ -1604,15 +1604,16 @@ _resolvconf_resolved_managed (void)
f = g_file_new_for_path (_PATH_RESCONF); f = g_file_new_for_path (_PATH_RESCONF);
info = g_file_query_info (f, info = g_file_query_info (f,
G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK","\ G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK","\
G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET, G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
NULL, NULL); NULL, NULL);
if (info && g_file_info_get_is_symlink (info)) if (info && g_file_info_get_is_symlink (info)) {
ret = _nm_utils_strv_find_first ((gchar **) resolved_paths, ret = _nm_utils_strv_find_first ((gchar **) resolved_paths,
G_N_ELEMENTS (resolved_paths), G_N_ELEMENTS (resolved_paths),
g_file_info_get_symlink_target (info)) >= 0; g_file_info_get_symlink_target (info)) >= 0;
}
g_clear_object(&info); g_clear_object(&info);
g_clear_object(&f); g_clear_object(&f);
@@ -1666,9 +1667,9 @@ again:
rc_manager = _check_resconf_immutable (rc_manager); rc_manager = _check_resconf_immutable (rc_manager);
if ( (!mode && _resolvconf_resolved_managed ()) if ( (!mode && _resolvconf_resolved_managed ())
|| nm_streq0 (mode, "systemd-resolved")) { || nm_streq0 (mode, "systemd-resolved")) {
if ( force_reload_plugin if ( force_reload_plugin
|| !NM_IS_DNS_SYSTEMD_RESOLVED (priv->plugin)) { || !NM_IS_DNS_SYSTEMD_RESOLVED (priv->plugin)) {
_clear_plugin (self); _clear_plugin (self);
priv->plugin = nm_dns_systemd_resolved_new (); priv->plugin = nm_dns_systemd_resolved_new ();
plugin_changed = TRUE; plugin_changed = TRUE;

View File

@@ -20,6 +20,7 @@
*/ */
#include "nm-default.h" #include "nm-default.h"
#include "nm-dns-systemd-resolved.h" #include "nm-dns-systemd-resolved.h"
#include <stdlib.h> #include <stdlib.h>
@@ -97,8 +98,8 @@ call_done (GObject *source, GAsyncResult *r, gpointer user_data)
static void static void
add_interface_configuration (NMDnsSystemdResolved *self, add_interface_configuration (NMDnsSystemdResolved *self,
GArray *interfaces, GArray *interfaces,
const NMDnsIPConfigData *data) const NMDnsIPConfigData *data)
{ {
int i; int i;
InterfaceConfig *ic = NULL; InterfaceConfig *ic = NULL;
@@ -128,7 +129,7 @@ add_interface_configuration (NMDnsSystemdResolved *self,
if (!ic) { if (!ic) {
g_array_set_size (interfaces, interfaces->len + 1); g_array_set_size (interfaces, interfaces->len + 1);
ic = &g_array_index (interfaces, InterfaceConfig, ic = &g_array_index (interfaces, InterfaceConfig,
interfaces->len - 1); interfaces->len - 1);
ic->ifindex = ifindex; ic->ifindex = ifindex;
} }
@@ -137,9 +138,10 @@ add_interface_configuration (NMDnsSystemdResolved *self,
static void static void
update_add_ip6_config (NMDnsSystemdResolved *self, update_add_ip6_config (NMDnsSystemdResolved *self,
GVariantBuilder *dns, GVariantBuilder *dns,
GVariantBuilder *domains, GVariantBuilder *domains,
const NMIP6Config *config) { const NMIP6Config *config)
{
int i; int i;
for (i = 0 ; i < nm_ip6_config_get_num_nameservers (config); i++) { for (i = 0 ; i < nm_ip6_config_get_num_nameservers (config); i++) {
@@ -155,22 +157,23 @@ update_add_ip6_config (NMDnsSystemdResolved *self,
for (i = 0; i < nm_ip6_config_get_num_searches (config); i++) { for (i = 0; i < nm_ip6_config_get_num_searches (config); i++) {
g_variant_builder_add (domains, "(sb)", g_variant_builder_add (domains, "(sb)",
nm_ip6_config_get_search(config, i), nm_ip6_config_get_search (config, i),
FALSE); FALSE);
} }
for (i = 0; i < nm_ip6_config_get_num_domains (config); i++) { for (i = 0; i < nm_ip6_config_get_num_domains (config); i++) {
g_variant_builder_add (domains, "(sb)", g_variant_builder_add (domains, "(sb)",
nm_ip6_config_get_domain (config, i), nm_ip6_config_get_domain (config, i),
TRUE); TRUE);
} }
} }
static void static void
update_add_ip4_config (NMDnsSystemdResolved *self, update_add_ip4_config (NMDnsSystemdResolved *self,
GVariantBuilder *dns, GVariantBuilder *dns,
GVariantBuilder *domains, GVariantBuilder *domains,
const NMIP4Config *config) { const NMIP4Config *config)
{
int i; int i;
for (i = 0 ; i < nm_ip4_config_get_num_nameservers (config); i++) { for (i = 0 ; i < nm_ip4_config_get_num_nameservers (config); i++) {
@@ -186,14 +189,14 @@ update_add_ip4_config (NMDnsSystemdResolved *self,
for (i = 0; i < nm_ip4_config_get_num_searches (config); i++) { for (i = 0; i < nm_ip4_config_get_num_searches (config); i++) {
g_variant_builder_add (domains, "(sb)", g_variant_builder_add (domains, "(sb)",
nm_ip4_config_get_search (config, i), nm_ip4_config_get_search (config, i),
FALSE); FALSE);
} }
for (i = 0; i < nm_ip4_config_get_num_domains (config); i++) { for (i = 0; i < nm_ip4_config_get_num_domains (config); i++) {
g_variant_builder_add (domains, "(sb)", g_variant_builder_add (domains, "(sb)",
nm_ip4_config_get_domain (config, i), nm_ip4_config_get_domain (config, i),
TRUE); TRUE);
} }
} }
@@ -203,10 +206,10 @@ free_pending_updates (NMDnsSystemdResolved *self)
NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self); NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self);
GVariant *v; GVariant *v;
while ((v = g_queue_pop_head(&priv->dns_updates)) != NULL) while ((v = g_queue_pop_head (&priv->dns_updates)) != NULL)
g_variant_unref (v); g_variant_unref (v);
while ((v = g_queue_pop_head(&priv->domain_updates)) != NULL) while ((v = g_queue_pop_head (&priv->domain_updates)) != NULL)
g_variant_unref (v); g_variant_unref (v);
} }
@@ -237,9 +240,9 @@ prepare_one_interface (NMDnsSystemdResolved *self, InterfaceConfig *ic)
g_variant_builder_close (&domains); g_variant_builder_close (&domains);
g_queue_push_tail (&priv->dns_updates, g_queue_push_tail (&priv->dns_updates,
g_variant_ref_sink(g_variant_builder_end (&dns))); g_variant_ref_sink (g_variant_builder_end (&dns)));
g_queue_push_tail (&priv->domain_updates, g_queue_push_tail (&priv->domain_updates,
g_variant_ref_sink(g_variant_builder_end (&domains))); g_variant_ref_sink (g_variant_builder_end (&domains)));
} }
static void static void
@@ -251,17 +254,17 @@ send_updates (NMDnsSystemdResolved *self)
if (!priv->resolve) if (!priv->resolve)
return; return;
while ((v = g_queue_pop_head(&priv->dns_updates)) != NULL) { while ((v = g_queue_pop_head (&priv->dns_updates)) != NULL) {
g_dbus_proxy_call (priv->resolve, "SetLinkDNS", v, g_dbus_proxy_call (priv->resolve, "SetLinkDNS", v,
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
-1, priv->update_cancellable, call_done, self); -1, priv->update_cancellable, call_done, self);
g_variant_unref (v); g_variant_unref (v);
} }
while ((v = g_queue_pop_head(&priv->domain_updates)) != NULL) { while ((v = g_queue_pop_head (&priv->domain_updates)) != NULL) {
g_dbus_proxy_call (priv->resolve, "SetLinkDomains", v, g_dbus_proxy_call (priv->resolve, "SetLinkDomains", v,
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
-1, priv->update_cancellable, call_done, self); -1, priv->update_cancellable, call_done, self);
g_variant_unref (v); g_variant_unref (v);
} }
} }
@@ -274,7 +277,7 @@ update (NMDnsPlugin *plugin,
{ {
NMDnsSystemdResolved *self = NM_DNS_SYSTEMD_RESOLVED (plugin); NMDnsSystemdResolved *self = NM_DNS_SYSTEMD_RESOLVED (plugin);
NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self); NMDnsSystemdResolvedPrivate *priv = NM_DNS_SYSTEMD_RESOLVED_GET_PRIVATE (self);
GArray *interfaces = g_array_new (TRUE, TRUE, sizeof(InterfaceConfig)); GArray *interfaces = g_array_new (TRUE, TRUE, sizeof (InterfaceConfig));
const NMDnsIPConfigData **c; const NMDnsIPConfigData **c;
int i; int i;
@@ -288,6 +291,7 @@ update (NMDnsPlugin *plugin,
for (i = 0; i < interfaces->len; i++) { for (i = 0; i < interfaces->len; i++) {
InterfaceConfig *ic = &g_array_index (interfaces, InterfaceConfig, i); InterfaceConfig *ic = &g_array_index (interfaces, InterfaceConfig, i);
prepare_one_interface (self, ic); prepare_one_interface (self, ic);
g_list_free (ic->configs); g_list_free (ic->configs);
} }
@@ -330,7 +334,7 @@ resolved_proxy_created (GObject *source, GAsyncResult *r, gpointer user_data)
g_clear_object (&priv->init_cancellable); g_clear_object (&priv->init_cancellable);
priv->resolve = g_dbus_proxy_new_finish(r, &error); priv->resolve = g_dbus_proxy_new_finish (r, &error);
if (priv->resolve == NULL) { if (priv->resolve == NULL) {
_LOGW ("failed to connect to resolved via DBus: %s", error->message); _LOGW ("failed to connect to resolved via DBus: %s", error->message);
@@ -339,7 +343,7 @@ resolved_proxy_created (GObject *source, GAsyncResult *r, gpointer user_data)
return; return;
} }
send_updates(self); send_updates (self);
} }
@@ -350,8 +354,8 @@ nm_dns_systemd_resolved_init (NMDnsSystemdResolved *self)
NMBusManager *dbus_mgr; NMBusManager *dbus_mgr;
GDBusConnection *connection; GDBusConnection *connection;
g_queue_init(&priv->dns_updates); g_queue_init (&priv->dns_updates);
g_queue_init(&priv->domain_updates); g_queue_init (&priv->domain_updates);
dbus_mgr = nm_bus_manager_get (); dbus_mgr = nm_bus_manager_get ();
g_return_if_fail (dbus_mgr); g_return_if_fail (dbus_mgr);
@@ -361,15 +365,15 @@ nm_dns_systemd_resolved_init (NMDnsSystemdResolved *self)
priv->init_cancellable = g_cancellable_new (); priv->init_cancellable = g_cancellable_new ();
g_dbus_proxy_new (connection, g_dbus_proxy_new (connection,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
NULL, NULL,
SYSTEMD_RESOLVED_DBUS_SERVICE, SYSTEMD_RESOLVED_DBUS_SERVICE,
SYSTEMD_RESOLVED_DBUS_PATH, SYSTEMD_RESOLVED_DBUS_PATH,
SYSTEMD_RESOLVED_DBUS_SERVICE ".Manager", SYSTEMD_RESOLVED_DBUS_SERVICE ".Manager",
priv->init_cancellable, priv->init_cancellable,
resolved_proxy_created, resolved_proxy_created,
self); self);
} }
static void static void