[network-manager-libreswan/th/vpn-plugin-debug-bgo766872: 5/21] properties: cache errno in local variable



commit 418ee41075b9825c8221b9f3133aa7d396f5d5e0
Author: Thomas Haller <thaller redhat com>
Date:   Thu May 26 10:57:10 2016 +0200

    properties: cache errno in local variable

 properties/nm-libreswan-editor-plugin.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/properties/nm-libreswan-editor-plugin.c b/properties/nm-libreswan-editor-plugin.c
index a62e7e6..dcc3308 100644
--- a/properties/nm-libreswan-editor-plugin.c
+++ b/properties/nm-libreswan-editor-plugin.c
@@ -70,12 +70,13 @@ import_from_file (NMVpnEditorPlugin *self,
        NMSettingVpn *s_vpn;
        GIOChannel *chan;
        gchar *str;
-       int fd;
+       int fd, errsv;
 
        fd = g_open (path, O_RDONLY, 0777);
        if (fd == -1) {
+               errsv = errno;
                g_set_error (error, NMV_EDITOR_PLUGIN_ERROR, 0,
-                            _("Can't open file '%s': %s"), path, g_strerror (errno));
+                            _("Can't open file '%s': %s"), path, g_strerror (errsv));
                return NULL;
        }
 
@@ -123,12 +124,13 @@ export_to_file (NMVpnEditorPlugin *self,
 {
        NMSettingVpn *s_vpn;
        gboolean openswan = FALSE;
-       int fd;
+       int fd, errsv;
 
        fd = g_open (path, O_WRONLY | O_CREAT, 0777);
        if (fd == -1) {
+               errsv = errno;
                g_set_error (error, NMV_EDITOR_PLUGIN_ERROR, 0,
-                            _("Can't open file '%s': %s"), path, g_strerror (errno));
+                            _("Can't open file '%s': %s"), path, g_strerror (errsv));
                return FALSE;
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]