diff options
author | Thomas Haller <thaller@redhat.com> | 2019-08-08 11:09:58 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-08-08 11:59:59 +0200 |
commit | b216abb012b97a7e0e50b969e4a04c8b11a4cbe9 (patch) | |
tree | b32f160bc5f97f56723f4e28fb1155976cad6e60 /src/settings/plugins/keyfile/nms-keyfile-utils.c | |
parent | 1bad35061fb3d0807048601b404619ad816be28b (diff) | |
download | NetworkManager-b216abb012b97a7e0e50b969e4a04c8b11a4cbe9.tar.gz |
shared,all: return boolean success from nm_utils_file_get_contents()
... and nm_utils_fd_get_contents() and nm_utils_file_set_contents().
Don't mix negative errno return value with a GError output. Instead,
return a boolean result indicating success or failure.
Also, optionally
- output GError
- set out_errsv to the positive errno (or 0 on success)
Obviously, the return value and the output arguments (contents, length,
out_errsv, error) must all agree in their success/failure result.
That means, you may check any of the return value, out_errsv, error, and
contents to reliably detect failure or success.
Also note that out_errsv gives the positive(!) errno. But you probably
shouldn't care about the distinction and use nm_errno_native() either
way to normalize the value.
Diffstat (limited to 'src/settings/plugins/keyfile/nms-keyfile-utils.c')
-rw-r--r-- | src/settings/plugins/keyfile/nms-keyfile-utils.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/settings/plugins/keyfile/nms-keyfile-utils.c b/src/settings/plugins/keyfile/nms-keyfile-utils.c index eef6ae6e82..ed07bea679 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-utils.c +++ b/src/settings/plugins/keyfile/nms-keyfile-utils.c @@ -266,7 +266,12 @@ nms_keyfile_nmmeta_write (const char *dirname, contents = g_key_file_to_data (kf, &length, NULL); - if (nm_utils_file_set_contents (full_filename, contents, length, 0600, NULL) < 0) { + if (!nm_utils_file_set_contents (full_filename, + contents, + length, + 0600, + NULL, + NULL)) { NM_SET_OUT (out_full_filename, g_steal_pointer (&full_filename_tmp)); return FALSE; } |