Commit 8ef30758 authored by Christian Persch's avatar Christian Persch

Preserve errno

When using errno in g_set_error with _(), preserve errno. Bug #592457.
parent feff29ae
......@@ -633,10 +633,13 @@ g_convert_with_iconv (const gchar *str,
have_error = TRUE;
break;
default:
if (error)
g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED,
_("Error during conversion: %s"),
g_strerror (errno));
{
int errsv = errno;
g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED,
_("Error during conversion: %s"),
g_strerror (errsv));
}
have_error = TRUE;
break;
}
......@@ -940,9 +943,14 @@ g_convert_with_fallback (const gchar *str,
}
/* fall thru if p is NULL */
default:
g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED,
_("Error during conversion: %s"),
g_strerror (errno));
{
int errsv = errno;
g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED,
_("Error during conversion: %s"),
g_strerror (errsv));
}
have_error = TRUE;
break;
}
......
......@@ -80,6 +80,7 @@ g_dir_open (const gchar *path,
GError **error)
{
GDir *dir;
int errsv;
#ifdef G_OS_WIN32
wchar_t *wpath;
#else
......@@ -103,12 +104,13 @@ g_dir_open (const gchar *path,
return dir;
/* error case */
errsv = errno;
g_set_error (error,
G_FILE_ERROR,
g_file_error_from_errno (errno),
g_file_error_from_errno (errsv),
_("Error opening directory '%s': %s"),
path, g_strerror (errno));
path, g_strerror (errsv));
g_free (dir);
......@@ -122,13 +124,16 @@ g_dir_open (const gchar *path,
return dir;
/* error case */
errsv = errno;
utf8_path = g_filename_to_utf8 (path, -1,
NULL, NULL, NULL);
g_set_error (error,
G_FILE_ERROR,
g_file_error_from_errno (errno),
g_file_error_from_errno (errsv),
_("Error opening directory '%s': %s"),
utf8_path, g_strerror (errno));
utf8_path, g_strerror (errsv));
g_free (utf8_path);
g_free (dir);
......
......@@ -294,9 +294,11 @@ make_pipe (gint p[2],
{
if (_pipe (p, 4096, _O_BINARY) < 0)
{
int errsv = errno;
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Failed to create pipe for communicating with child process (%s)"),
g_strerror (errno));
g_strerror (errsv));
return FALSE;
}
else
......@@ -330,11 +332,12 @@ read_helper_report (int fd,
if (chunk < 0)
{
int errsv = errno;
/* Some weird shit happened, bail out */
g_set_error (error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED,
_("Failed to read from child pipe (%s)"),
g_strerror (errno));
g_strerror (errsv));
return FALSE;
}
......
......@@ -182,11 +182,13 @@ read_data (GString *str,
goto again;
else if (bytes < 0)
{
int errsv = errno;
g_set_error (error,
G_SPAWN_ERROR,
G_SPAWN_ERROR_READ,
_("Failed to read data from child process (%s)"),
g_strerror (errno));
g_strerror (errsv));
return READ_FAILED;
}
......@@ -317,13 +319,15 @@ g_spawn_sync (const gchar *working_directory,
if (ret < 0 && errno != EINTR)
{
int errsv = errno;
failed = TRUE;
g_set_error (error,
G_SPAWN_ERROR,
G_SPAWN_ERROR_READ,
_("Unexpected error in select() reading data from a child process (%s)"),
g_strerror (errno));
g_strerror (errsv));
break;
}
......@@ -400,13 +404,15 @@ g_spawn_sync (const gchar *working_directory,
{
if (!failed) /* avoid error pileups */
{
int errsv = errno;
failed = TRUE;
g_set_error (error,
G_SPAWN_ERROR,
G_SPAWN_ERROR_READ,
_("Unexpected error in waitpid() (%s)"),
g_strerror (errno));
g_strerror (errsv));
}
}
}
......@@ -1124,13 +1130,14 @@ read_ints (int fd,
if (chunk < 0)
{
int errsv = errno;
/* Some weird shit happened, bail out */
g_set_error (error,
G_SPAWN_ERROR,
G_SPAWN_ERROR_FAILED,
_("Failed to read from child pipe (%s)"),
g_strerror (errno));
g_strerror (errsv));
return FALSE;
}
......@@ -1190,12 +1197,14 @@ fork_exec_with_pipes (gboolean intermediate_child,
pid = fork ();
if (pid < 0)
{
{
int errsv = errno;
g_set_error (error,
G_SPAWN_ERROR,
G_SPAWN_ERROR_FORK,
_("Failed to fork (%s)"),
g_strerror (errno));
g_strerror (errsv));
goto cleanup_and_fail;
}
......@@ -1390,11 +1399,13 @@ fork_exec_with_pipes (gboolean intermediate_child,
if (n_ints < 1)
{
int errsv = errno;
g_set_error (error,
G_SPAWN_ERROR,
G_SPAWN_ERROR_FAILED,
_("Failed to read enough data from child pid pipe (%s)"),
g_strerror (errno));
g_strerror (errsv));
goto cleanup_and_fail;
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment