From 95a76f726371c80830bacc12ee9c95f47893fecf Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 20 Oct 2017 17:18:58 +0200 Subject: [PATCH] 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. --- src/settings/plugins/ifcfg-rh/shvar.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index 911da73a05..c0969bb36c 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -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; }