ifcfg-rh: don't fail creating shvarFile instance

When calling svOpenFileInternal() with @create, we don't care about
potential errors reading the file. We shouldn't return NULL in such
case, but always create a shvarFile instance.
This commit is contained in:
Thomas Haller 2017-10-20 17:18:58 +02:00
parent 8687081534
commit 95a76f7263

View file

@ -794,7 +794,7 @@ svOpenFileInternal (const char *name, gboolean create, GError **error)
int errsv = 0;
char *arena;
const char *p, *q;
GError *local = NULL;
gs_free_error GError *local = NULL;
nm_auto_close int fd = -1;
if (create)
@ -824,11 +824,13 @@ svOpenFileInternal (const char *name, gboolean create, GError **error)
&arena,
NULL,
&local) < 0) {
if (create)
return svFile_new (name);
g_set_error (error, G_FILE_ERROR,
local->domain == G_FILE_ERROR ? local->code : G_FILE_ERROR_FAILED,
"Could not read file '%s': %s",
name, local->message);
g_error_free (local);
return NULL;
}