[gtk+] Preserve errno, and always use g_strerror()



commit e8dcf330cca3e97ee8ca1a5b81c6f475df4eeed1
Author: Christian Persch <chpe gnome org>
Date:   Thu Aug 20 15:32:22 2009 +0200

    Preserve errno, and always use g_strerror()
    
    Bug #592461.

 gdk-pixbuf/io-gif.c         |    2 +-
 gtk/gtkfilesel.c            |   12 +++++++++---
 gtk/gtkmountoperation-x11.c |    6 ++++--
 gtk/updateiconcache.c       |   18 +++++++++++++-----
 4 files changed, 27 insertions(+), 11 deletions(-)
---
diff --git a/gdk-pixbuf/io-gif.c b/gdk-pixbuf/io-gif.c
index 0a5803f..04fb1d1 100644
--- a/gdk-pixbuf/io-gif.c
+++ b/gdk-pixbuf/io-gif.c
@@ -220,7 +220,7 @@ gif_read (GifContext *context, guchar *buffer, size_t len)
                                      G_FILE_ERROR,
                                      g_file_error_from_errno (save_errno),
                                      _("Failure reading GIF: %s"), 
-                                     strerror (save_errno));
+                                     g_strerror (save_errno));
                 }
                 
 #ifdef IO_GIFDEBUG
diff --git a/gtk/gtkfilesel.c b/gtk/gtkfilesel.c
index 0aa9f17..eca76ca 100644
--- a/gtk/gtkfilesel.c
+++ b/gtk/gtkfilesel.c
@@ -1355,8 +1355,10 @@ gtk_file_selection_create_dir_confirmed (GtkWidget *widget,
 
   if (g_mkdir (sys_full_path, 0777) < 0)
     {
+      int errsv = errno;
+
       buf = g_strdup_printf (_("Error creating folder '%s': %s"), 
-			     dirname, g_strerror (errno));
+			     dirname, g_strerror (errsv));
       gtk_file_selection_fileop_error (fs, buf);
     }
 
@@ -1484,8 +1486,10 @@ gtk_file_selection_delete_file_response (GtkDialog *dialog,
 
   if (g_unlink (sys_full_path) < 0) 
     {
+      int errsv = errno;
+
       buf = g_strdup_printf (_("Error deleting file '%s': %s"),
-			     fs->fileop_file, g_strerror (errno));
+			     fs->fileop_file, g_strerror (errsv));
       gtk_file_selection_fileop_error (fs, buf);
     }
   
@@ -1602,9 +1606,11 @@ gtk_file_selection_rename_file_confirmed (GtkWidget *widget,
   
   if (g_rename (sys_old_filename, sys_new_filename) < 0) 
     {
+      int errsv = errno;
+
       buf = g_strdup_printf (_("Error renaming file \"%s\" to \"%s\": %s"),
 			     sys_old_filename, sys_new_filename,
-			     g_strerror (errno));
+			     g_strerror (errsv));
       gtk_file_selection_fileop_error (fs, buf);
       goto out2;
     }
diff --git a/gtk/gtkmountoperation-x11.c b/gtk/gtkmountoperation-x11.c
index 2a2c4a0..1bfb503 100644
--- a/gtk/gtkmountoperation-x11.c
+++ b/gtk/gtkmountoperation-x11.c
@@ -952,6 +952,8 @@ _gtk_mount_operation_kill_process (GPid      pid,
 
   if (kill ((pid_t) pid, SIGTERM) != 0)
     {
+      int errsv = errno;
+
       /* TODO: On EPERM, we could use a setuid helper using polkit (very easy to implement
        *       via pkexec(1)) to allow the user to e.g. authenticate to gain the authorization
        *       to kill the process. But that's not how things currently work.
@@ -960,10 +962,10 @@ _gtk_mount_operation_kill_process (GPid      pid,
       ret = FALSE;
       g_set_error (error,
                    G_IO_ERROR,
-                   g_io_error_from_errno (errno),
+                   g_io_error_from_errno (errsv),
                    _("Cannot end process with pid %d: %s"),
                    pid,
-                   strerror (errno));
+                   g_strerror (errsv));
     }
 
   return ret;
diff --git a/gtk/updateiconcache.c b/gtk/updateiconcache.c
index 627f49e..02d0047 100644
--- a/gtk/updateiconcache.c
+++ b/gtk/updateiconcache.c
@@ -1516,9 +1516,11 @@ opentmp:
       g_unlink (bak_cache_path);
       if (g_rename (cache_path, bak_cache_path) == -1)
 	{
+          int errsv = errno;
+
 	  g_printerr (_("Could not rename %s to %s: %s, removing %s then.\n"),
 		      cache_path, bak_cache_path,
-		      g_strerror (errno),
+		      g_strerror (errsv),
 		      cache_path);
 	  g_unlink (cache_path);
 	  bak_cache_path = NULL;
@@ -1528,16 +1530,22 @@ opentmp:
 
   if (g_rename (tmp_cache_path, cache_path) == -1)
     {
+      int errsv = errno;
+
       g_printerr (_("Could not rename %s to %s: %s\n"),
 		  tmp_cache_path, cache_path,
-		  g_strerror (errno));
+		  g_strerror (errsv));
       g_unlink (tmp_cache_path);
 #ifdef G_OS_WIN32
       if (bak_cache_path != NULL)
 	if (g_rename (bak_cache_path, cache_path) == -1)
-	  g_printerr (_("Could not rename %s back to %s: %s.\n"),
-		      bak_cache_path, cache_path,
-		      g_strerror (errno));
+          {
+            errsv = errno;
+
+            g_printerr (_("Could not rename %s back to %s: %s.\n"),
+                        bak_cache_path, cache_path,
+                        g_strerror (errsv));
+          }
 #endif
       exit (1);
     }



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