summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/devices/nm-device-ethernet.c2
-rw-r--r--src/devices/nm-device-logging.h2
-rw-r--r--src/devices/wifi/nm-wifi-ap.c2
-rw-r--r--src/main-utils.c2
-rw-r--r--src/nm-core-utils.h16
-rw-r--r--src/nm-ip4-config.c2
-rw-r--r--src/nm-logging.c6
-rw-r--r--src/nm-manager.c2
-rw-r--r--src/platform/nm-linux-platform.c2
-rw-r--r--src/platform/nm-platform.c2
-rw-r--r--src/platform/tests/test-link.c2
-rw-r--r--src/rdisc/tests/test-rdisc-fake.c2
-rw-r--r--src/settings/plugins/ifcfg-rh/utils.h2
-rw-r--r--src/settings/plugins/keyfile/utils.h2
-rw-r--r--src/vpn-manager/nm-vpn-connection.c2
15 files changed, 16 insertions, 32 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index dbcd623328..db6b434d14 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -158,7 +158,7 @@ _update_s390_subchannels (NMDeviceEthernet *self)
dev = (GUdevDevice *) nm_platform_link_get_udev_device (NM_PLATFORM_GET, ifindex);
if (!dev) {
_LOGW (LOGD_DEVICE | LOGD_HW, "failed to find device %d '%s' with udev",
- ifindex, str_if_set (nm_device_get_iface (NM_DEVICE (self)), "(null)"));
+ ifindex, nm_device_get_iface (NM_DEVICE (self)) ?: "(null)");
goto out;
}
g_object_ref (dev);
diff --git a/src/devices/nm-device-logging.h b/src/devices/nm-device-logging.h
index 8a2c9b681c..1be17073b6 100644
--- a/src/devices/nm-device-logging.h
+++ b/src/devices/nm-device-logging.h
@@ -36,7 +36,7 @@ _nm_device_log_self_to_device (t *self) \
#define _NMLOG(level, domain, ...) \
nm_log_obj ((level), (domain), (self), "device", \
"(%s): " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
- (self) ? str_if_set (nm_device_get_iface (_nm_device_log_self_to_device (self)), "(null)") : "(none)" \
+ (self) ? (nm_device_get_iface (_nm_device_log_self_to_device (self)) ?: "(null)") : "(none)" \
_NM_UTILS_MACRO_REST(__VA_ARGS__))
#endif /* __NETWORKMANAGER_DEVICE_LOGGING_H__ */
diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c
index 307825c6f9..a0c2570996 100644
--- a/src/devices/wifi/nm-wifi-ap.c
+++ b/src/devices/wifi/nm-wifi-ap.c
@@ -741,7 +741,7 @@ nm_ap_dump (NMAccessPoint *self,
nm_log_dbg (LOGD_WIFI_SCAN, "%s[%s%c] %-32s[%s%u %3u%% %c W:%04X R:%04X] [%3u] %s%s",
prefix,
- str_if_set (priv->address, "(none)"),
+ priv->address ?: "(none)",
mode_to_char (self),
priv->ssid ? nm_utils_escape_ssid (priv->ssid->data, priv->ssid->len) : "(none)",
chan > 99 ? "" : (chan > 9 ? " " : " "),
diff --git a/src/main-utils.c b/src/main-utils.c
index e0f254b752..7385e9c2a4 100644
--- a/src/main-utils.c
+++ b/src/main-utils.c
@@ -178,7 +178,7 @@ void
nm_main_utils_ensure_root ()
{
if (getuid () != 0) {
- fprintf (stderr, _("You must be root to run %s!\n"), str_if_set (g_get_prgname (), ""));
+ fprintf (stderr, _("You must be root to run %s!\n"), g_get_prgname () ?: "");
exit (1);
}
}
diff --git a/src/nm-core-utils.h b/src/nm-core-utils.h
index c51b02de8a..7e1fdec470 100644
--- a/src/nm-core-utils.h
+++ b/src/nm-core-utils.h
@@ -145,22 +145,6 @@ int nm_spawn_process (const char *args, GError **error);
int nm_utils_modprobe (GError **error, gboolean suppress_error_loggin, const char *arg1, ...) G_GNUC_NULL_TERMINATED;
-/**
- * str_if_set:
- * @str: input string that will be returned if @str is not %NULL
- * @fallback: if @str is %NULL, return @fallback instead
- *
- * This utility function is useful when printing a string to avoid passing
- * %NULL. E.g. printf ("%s", str_if_set (get_string(), "(none)"));
- *
- * Returns: either @str or @fallback, depending on whether @str is %NULL.
- */
-static inline const char *
-str_if_set (const char *str, const char *fallback)
-{
- return str ? str : fallback;
-}
-
guint64 nm_utils_get_start_time_for_pid (pid_t pid, char *out_state, pid_t *out_ppid);
void nm_utils_kill_process_sync (pid_t pid, guint64 start_time, int sig, guint64 log_domain,
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c
index f556bd283b..4b27edf74b 100644
--- a/src/nm-ip4-config.c
+++ b/src/nm-ip4-config.c
@@ -1315,7 +1315,7 @@ nm_ip4_config_dump (const NMIP4Config *config, const char *detail)
g_message (" nis: %s", nm_utils_inet4_ntop (tmp, NULL));
}
- g_message (" nisdmn: %s", str_if_set (nm_ip4_config_get_nis_domain (config), "(none)"));
+ g_message (" nisdmn: %s", nm_ip4_config_get_nis_domain (config) ?: "(none)");
/* WINS */
for (i = 0; i < nm_ip4_config_get_num_wins (config); i++) {
diff --git a/src/nm-logging.c b/src/nm-logging.c
index bb53c7a15f..16951764e0 100644
--- a/src/nm-logging.c
+++ b/src/nm-logging.c
@@ -725,11 +725,11 @@ nm_log_handler (const gchar *log_domain,
boottime = nm_utils_monotonic_timestamp_as_boottime (now, 1);
sd_journal_send ("PRIORITY=%d", syslog_priority,
- "MESSAGE=%s", str_if_set (message, ""),
+ "MESSAGE=%s", message ?: "",
"SYSLOG_IDENTIFIER=%s", G_LOG_DOMAIN,
"SYSLOG_PID=%ld", (long) getpid (),
"SYSLOG_FACILITY=GLIB",
- "GLIB_DOMAIN=%s", str_if_set (log_domain, ""),
+ "GLIB_DOMAIN=%s", log_domain ?: "",
"GLIB_LEVEL=%d", (int) (level & G_LOG_LEVEL_MASK),
"TIMESTAMP_MONOTONIC=%lld.%06lld", (long long) (now / NM_UTILS_NS_PER_SECOND), (long long) ((now % NM_UTILS_NS_PER_SECOND) / 1000),
"TIMESTAMP_BOOTTIME=%lld.%06lld", (long long) (boottime / NM_UTILS_NS_PER_SECOND), (long long) ((boottime % NM_UTILS_NS_PER_SECOND) / 1000),
@@ -738,7 +738,7 @@ nm_log_handler (const gchar *log_domain,
break;
#endif
default:
- syslog (syslog_priority, "%s", str_if_set (message, ""));
+ syslog (syslog_priority, "%s", message ?: "");
break;
}
}
diff --git a/src/nm-manager.c b/src/nm-manager.c
index e7eb7c63c8..6d7f96ccbf 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -2827,7 +2827,7 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError *
_LOGD (LOGD_CORE, "Activation of '%s' depends on active connection %p %s",
nm_settings_connection_get_id (connection),
master_ac,
- str_if_set (nm_exported_object_get_path (NM_EXPORTED_OBJECT (master_ac)), ""));
+ nm_exported_object_get_path (NM_EXPORTED_OBJECT (master_ac)) ?: "");
}
/* Check slaves for master connection and possibly activate them */
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 14ce74d5a2..eaa302a39c 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -4018,7 +4018,7 @@ link_get_type_name (NMPlatform *platform, int ifindex)
return nm_link_type_to_string (obj->link.type);
}
/* Link type not detected. Fallback to rtnl_link_get_type()/IFLA_INFO_KIND. */
- return str_if_set (obj->link.kind, "unknown");
+ return obj->link.kind ?: "unknown";
}
static gboolean
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index 06b6442c6e..8659cff517 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -3081,7 +3081,7 @@ nm_platform_link_to_string (const NMPlatformLink *link, char *buf, gsize len)
str_flags->str,
link->mtu, master,
link->arptype,
- str_if_set (str_link_type, "???"),
+ str_link_type ?: "???",
link->kind ? (g_strcmp0 (str_link_type, link->kind) ? "/" : "*") : "?",
link->kind && g_strcmp0 (str_link_type, link->kind) ? link->kind : "",
link->initialized ? " init" : " not-init",
diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c
index c136bbc640..e175a170be 100644
--- a/src/platform/tests/test-link.c
+++ b/src/platform/tests/test-link.c
@@ -1664,7 +1664,7 @@ test_create_many_links (gconstpointer user_data)
guint n_devices = GPOINTER_TO_UINT (user_data);
if (n_devices > 100 && nmtst_test_quick ()) {
- g_print ("Skipping test: don't run long running test %s (NMTST_DEBUG=slow)\n", str_if_set (g_get_prgname (), "test-link-linux"));
+ g_print ("Skipping test: don't run long running test %s (NMTST_DEBUG=slow)\n", g_get_prgname () ?: "test-link-linux");
g_test_skip ("Skip long running test");
return;
}
diff --git a/src/rdisc/tests/test-rdisc-fake.c b/src/rdisc/tests/test-rdisc-fake.c
index 00a98dcadf..1c514b9042 100644
--- a/src/rdisc/tests/test-rdisc-fake.c
+++ b/src/rdisc/tests/test-rdisc-fake.c
@@ -431,7 +431,7 @@ main (int argc, char **argv)
nmtst_init_with_logging (&argc, &argv, NULL, "DEFAULT");
if (nmtst_test_quick ()) {
- g_print ("Skipping test: don't run long running test %s (NMTST_DEBUG=slow)\n", str_if_set (g_get_prgname (), "test-rdisc-fake"));
+ g_print ("Skipping test: don't run long running test %s (NMTST_DEBUG=slow)\n", g_get_prgname () ?: "test-rdisc-fake");
return g_test_run ();
}
diff --git a/src/settings/plugins/ifcfg-rh/utils.h b/src/settings/plugins/ifcfg-rh/utils.h
index 329f4547ca..752d08a60b 100644
--- a/src/settings/plugins/ifcfg-rh/utils.h
+++ b/src/settings/plugins/ifcfg-rh/utils.h
@@ -26,7 +26,7 @@
#include "shvar.h"
#include "common.h"
-#define NM_IFCFG_CONNECTION_LOG_PATH(path) str_if_set (path,"in-memory")
+#define NM_IFCFG_CONNECTION_LOG_PATH(path) ((path) ?: "in-memory")
#define NM_IFCFG_CONNECTION_LOG_FMT "%s (%s,\"%s\")"
#define NM_IFCFG_CONNECTION_LOG_ARG(con) NM_IFCFG_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con))
#define NM_IFCFG_CONNECTION_LOG_FMTD "%s (%s,\"%s\",%p)"
diff --git a/src/settings/plugins/keyfile/utils.h b/src/settings/plugins/keyfile/utils.h
index 0b2b6f4e5e..c18fb2bcce 100644
--- a/src/settings/plugins/keyfile/utils.h
+++ b/src/settings/plugins/keyfile/utils.h
@@ -27,7 +27,7 @@
#define KEYFILE_PLUGIN_NAME "keyfile"
#define KEYFILE_PLUGIN_INFO "(c) 2007 - 2015 Red Hat, Inc. To report bugs please use the NetworkManager mailing list."
-#define NM_KEYFILE_CONNECTION_LOG_PATH(path) str_if_set (path,"in-memory")
+#define NM_KEYFILE_CONNECTION_LOG_PATH(path) ((path) ?: "in-memory")
#define NM_KEYFILE_CONNECTION_LOG_FMT "%s (%s,\"%s\")"
#define NM_KEYFILE_CONNECTION_LOG_ARG(con) NM_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con))
#define NM_KEYFILE_CONNECTION_LOG_FMTD "%s (%s,\"%s\",%p)"
diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c
index 54d20b1914..27132d7f1d 100644
--- a/src/vpn-manager/nm-vpn-connection.c
+++ b/src/vpn-manager/nm-vpn-connection.c
@@ -196,7 +196,7 @@ __LOG_create_prefix (char *buf, NMVpnConnection *self)
"]",
_NMLOG_PREFIX_NAME,
self,
- con ? "," : "--", con ? str_if_set (nm_connection_get_uuid (con), "??") : "",
+ con ? "," : "--", con ? (nm_connection_get_uuid (con) ?: "??") : "",
con ? "," : "", NM_PRINT_FMT_QUOTED (id, "\"", id, "\"", con ? "??" : ""),
priv->ip_ifindex,
priv->ip_iface ? ":" : "", NM_PRINT_FMT_QUOTED (priv->ip_iface, "(", priv->ip_iface, ")", "")