Skip to content

Commit

Permalink
networkd: fix __FUNCTION__ macro and implicit boolean condition
Browse files Browse the repository at this point in the history
  • Loading branch information
slyon committed Aug 21, 2024
1 parent d27f323 commit 51d6ad9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/networkd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 51d6ad9

Please sign in to comment.