summaryrefslogtreecommitdiff
path: root/src/nm-manager.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-11-17 15:54:49 +0100
committerThomas Haller <thaller@redhat.com>2018-11-18 11:59:47 +0100
commit28c386df8a7c2542c38cea54cdcd75d8f11b0b52 (patch)
treef53b18bab1aae0312255f3c61531ef89a6661883 /src/nm-manager.c
parentbc23dc8ff007341a6e8f5e569b1454750f988ea7 (diff)
downloadNetworkManager-28c386df8a7c2542c38cea54cdcd75d8f11b0b52.tar.gz
manager: prefer nm_streq over strcmp in impl_manager_add_and_activate_connection()
- use nm_streq() instead of g_strcmp0(). I think streq() is easier to understand. - the strings that are checked here must never be %NULL, because they come from string variants. Use nm_streq() instead of nm_streq0() or g_strcmp0(). - don't add a "." to the GError messages. GError messages are commonly embedded in a larger message, and shoult not themself contain the dot.
Diffstat (limited to 'src/nm-manager.c')
-rw-r--r--src/nm-manager.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c
index c0bb1c10a5..c960155fde 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -5254,25 +5254,24 @@ impl_manager_add_and_activate_connection (NMDBusObject *obj,
option_value_free = option_value;
- if ((g_strcmp0 (option_name, "persist") == 0) &&
- g_variant_is_of_type (option_value, G_VARIANT_TYPE_STRING)) {
+ if ( nm_streq (option_name, "persist")
+ && g_variant_is_of_type (option_value, G_VARIANT_TYPE_STRING)) {
s = g_variant_get_string (option_value, NULL);
- if (g_strcmp0 (s, "volatile") == 0) {
+ if (nm_streq (s, "volatile"))
persist = NM_SETTINGS_CONNECTION_PERSIST_MODE_VOLATILE_ONLY;
- } else if (g_strcmp0 (s, "memory") == 0) {
+ else if (nm_streq (s, "memory"))
persist = NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY_ONLY;
- } else if (g_strcmp0 (s, "disk") == 0) {
+ else if (nm_streq (s, "disk"))
persist = NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK;
- } else {
+ else {
error = g_error_new_literal (NM_MANAGER_ERROR,
NM_MANAGER_ERROR_INVALID_ARGUMENTS,
- "Option \"persist\" must be one of \"volatile\", \"memory\" or \"disk\".");
+ "Option \"persist\" must be one of \"volatile\", \"memory\" or \"disk\"");
goto error;
}
-
- } else if ((g_strcmp0 (option_name, "bind") == 0) &&
- g_variant_is_of_type (option_value, G_VARIANT_TYPE_STRING)) {
+ } else if ( nm_streq (option_name, "bind")
+ && g_variant_is_of_type (option_value, G_VARIANT_TYPE_STRING)) {
s = g_variant_get_string (option_value, NULL);
if (nm_streq (s, "dbus-client"))
@@ -5282,14 +5281,13 @@ impl_manager_add_and_activate_connection (NMDBusObject *obj,
else {
error = g_error_new_literal (NM_MANAGER_ERROR,
NM_MANAGER_ERROR_INVALID_ARGUMENTS,
- "Option \"bind\" must be one of \"dbus-client\" or \"none\".");
+ "Option \"bind\" must be one of \"dbus-client\" or \"none\"");
goto error;
}
} else {
- /* Unknown argument */
error = g_error_new_literal (NM_MANAGER_ERROR,
NM_MANAGER_ERROR_INVALID_ARGUMENTS,
- "Unknown extra option passed.");
+ "Unknown extra option passed");
goto error;
}
}