platform: print sysctl absolute path when pathid is NULL

@pathid can be NULL, in such case print the absolute path.
This commit is contained in:
Beniamino Galvani
2019-01-02 17:20:48 +01:00
parent 3ed23d405e
commit b5009ccd29

View File

@@ -4385,18 +4385,18 @@ _log_dbg_sysctl_set_impl (NMPlatform *platform, const char *pathid, int dirfd, c
if (nm_utils_file_get_contents (dirfd, path, 1*1024*1024, if (nm_utils_file_get_contents (dirfd, path, 1*1024*1024,
NM_UTILS_FILE_GET_CONTENTS_FLAG_NONE, NM_UTILS_FILE_GET_CONTENTS_FLAG_NONE,
&contents, NULL, &error) < 0) { &contents, NULL, &error) < 0) {
_LOGD ("sysctl: setting '%s' to '%s' (current value cannot be read: %s)", pathid, value_escaped, error->message); _LOGD ("sysctl: setting '%s' to '%s' (current value cannot be read: %s)", pathid ?: path, value_escaped, error->message);
g_clear_error (&error); g_clear_error (&error);
return; return;
} }
g_strstrip (contents); g_strstrip (contents);
if (nm_streq (contents, value)) if (nm_streq (contents, value))
_LOGD ("sysctl: setting '%s' to '%s' (current value is identical)", pathid, value_escaped); _LOGD ("sysctl: setting '%s' to '%s' (current value is identical)", pathid ?: path, value_escaped);
else { else {
gs_free char *contents_escaped = g_strescape (contents, NULL); gs_free char *contents_escaped = g_strescape (contents, NULL);
_LOGD ("sysctl: setting '%s' to '%s' (current value is '%s')", pathid, value_escaped, contents_escaped); _LOGD ("sysctl: setting '%s' to '%s' (current value is '%s')", pathid ?: path, value_escaped, contents_escaped);
} }
g_free (contents); g_free (contents);
} }