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/initrd | |
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/initrd')
-rw-r--r-- | src/initrd/nm-initrd-generator.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/initrd/nm-initrd-generator.c b/src/initrd/nm-initrd-generator.c index 6a1bf35a0d..964d87143c 100644 --- a/src/initrd/nm-initrd-generator.c +++ b/src/initrd/nm-initrd-generator.c @@ -63,7 +63,12 @@ output_conn (gpointer key, gpointer value, gpointer user_data) filename = nm_keyfile_utils_create_filename (basename, TRUE); full_filename = g_build_filename (connections_dir, filename, NULL); - if (nm_utils_file_set_contents (full_filename, data, len, 0600, &error) < 0) + if (!nm_utils_file_set_contents (full_filename, + data, + len, + 0600, + NULL, + &error)) goto err_out; } else g_print ("\n*** Connection '%s' ***\n\n%s", basename, data); |