src/ui/gui/psppire-conf.c: Use GError instead of strerror.
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 29 Aug 2020 06:26:23 +0000 (08:26 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 29 Aug 2020 06:26:23 +0000 (08:26 +0200)
Apparently the use of strerror was causing problems on certain
platforms.  In this case, since the function being checked provides
a GError argument it makes sense to use that instead.

Closes bug #59034

src/ui/gui/psppire-conf.c

index 1f5914ed722751eb8c6d1830be960b4540ef11c4..60cbc0ceddddb47a092172e6a1ccfecb14ae203b 100644 (file)
@@ -50,11 +50,12 @@ flush_conf (PsppireConf *conf)
   gsize length = 0;
 
   gchar *kf = g_key_file_to_data  (conf->keyfile, &length, NULL);
+  GError *err = NULL;
 
-  if (! g_file_set_contents (conf->filename, kf, length, NULL))
+  if (! g_file_set_contents (conf->filename, kf, length, &err))
     {
-      char *msg = strerror (errno);
-      g_warning ("Cannot open %s for writing: %s", conf->filename, msg);
+      g_warning ("Cannot open %s for writing: %s", conf->filename, err->message);
+      g_error_free (err);
     }
 
   g_free (kf);