diff --git a/src/networkd.c b/src/networkd.c index 96ca082b5..7b4ed196e 100644 --- a/src/networkd.c +++ b/src/networkd.c @@ -42,11 +42,11 @@ _netplan_sysfs_get_mac_by_ifname(const char* ifname, const char* rootdir) { g_autofree gchar* content = NULL; g_autofree gchar* sysfs_path = NULL; - sysfs_path = g_build_path(G_DIR_SEPARATOR_S, rootdir ?: G_DIR_SEPARATOR_S, + sysfs_path = g_build_path(G_DIR_SEPARATOR_S, !!rootdir ? rootdir : G_DIR_SEPARATOR_S, "sys", "class", "net", ifname, "address", NULL); if (!g_file_get_contents (sysfs_path, &content, NULL, NULL)) { - g_debug("%s: Cannot read file contents.", __FUNCTION__); + g_debug("%s: Cannot read file contents.", __func__); return NULL; } @@ -63,12 +63,12 @@ _netplan_sysfs_get_driver_by_ifname(const char* ifname, const char* rootdir) { g_autofree gchar* link = NULL; g_autofree gchar* sysfs_path = NULL; - sysfs_path = g_build_path(G_DIR_SEPARATOR_S, rootdir ?: G_DIR_SEPARATOR_S, + sysfs_path = g_build_path(G_DIR_SEPARATOR_S, !!rootdir ? rootdir : G_DIR_SEPARATOR_S, "sys", "class", "net", ifname, "device", "driver", NULL); link = g_file_read_link(sysfs_path, NULL); if (!link) { - g_debug("%s: Cannot read symlink of %s.", __FUNCTION__, sysfs_path); + g_debug("%s: Cannot read symlink of %s.", __func__, sysfs_path); return NULL; } @@ -394,7 +394,8 @@ write_regdom(const NetplanNetDefinition* def, const char* rootdir, GError** erro { g_assert(def->regulatory_domain); g_autofree gchar* id_escaped = NULL; - g_autofree char* link = g_strjoin(NULL, rootdir ?: "", "/run/systemd/system/network.target.wants/netplan-regdom.service", NULL); + g_autofree char* link = g_strjoin(NULL, !!rootdir ? rootdir : "", + "/run/systemd/system/network.target.wants/netplan-regdom.service", NULL); g_autofree char* path = g_strjoin(NULL, "/run/systemd/system/netplan-regdom.service", NULL); GString* s = g_string_new("[Unit]\n"); @@ -1489,7 +1490,8 @@ _netplan_netdef_write_networkd( } if (def->type == NETPLAN_DEF_TYPE_WIFI || def->has_auth) { - g_autofree char* link = g_strjoin(NULL, rootdir ?: "", "/run/systemd/system/systemd-networkd.service.wants/netplan-wpa-", escaped_netdef_id, ".service", NULL); + g_autofree char* link = g_strjoin(NULL, !!rootdir ? rootdir : "", + "/run/systemd/system/systemd-networkd.service.wants/netplan-wpa-", escaped_netdef_id, ".service", NULL); g_autofree char* slink = g_strjoin(NULL, "/run/systemd/system/netplan-wpa-", escaped_netdef_id, ".service", NULL); if (def->type == NETPLAN_DEF_TYPE_WIFI && def->has_match) { g_set_error(error, NETPLAN_BACKEND_ERROR, NETPLAN_ERROR_UNSUPPORTED, "ERROR: %s: networkd backend does not support wifi with match:, only by interface name\n", def->id);