When using errno in g_set_error with _(), preserve errno. Bug #592457.
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;
}
}
/* 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;
}
GError **error)
{
GDir *dir;
+ int errsv;
#ifdef G_OS_WIN32
wchar_t *wpath;
#else
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);
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);
{
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
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;
}
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;
}
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;
}
{
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));
}
}
}
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;
}
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;
}
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