Merge branch 'coverity-return-values' into 'master'

Minor Coverity fixes

See merge request GNOME/glib!1780
This commit is contained in:
Philip Withnall 2020-12-03 15:35:36 +00:00
commit 416339305f
2 changed files with 27 additions and 5 deletions

View File

@ -1824,6 +1824,7 @@ _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
{
static gsize home_dev_set = 0;
static dev_t home_dev;
static gboolean home_dev_valid = FALSE;
char *topdir, *globaldir, *trashdir, *tmpname;
uid_t uid;
char uid_str[32];
@ -1834,13 +1835,23 @@ _g_local_file_has_trash_dir (const char *dirname, dev_t dir_dev)
{
GStatBuf home_stat;
g_stat (g_get_home_dir (), &home_stat);
home_dev = home_stat.st_dev;
if (g_stat (g_get_home_dir (), &home_stat) == 0)
{
home_dev = home_stat.st_dev;
home_dev_valid = TRUE;
}
else
{
home_dev_valid = FALSE;
}
g_once_init_leave (&home_dev_set, 1);
}
/* Assume we can trash to the home */
if (dir_dev == home_dev)
if (!home_dev_valid)
return FALSE;
else if (dir_dev == home_dev)
return TRUE;
topdir = find_mountpoint_for (dirname, dir_dev, TRUE);
@ -1972,7 +1983,15 @@ g_local_file_trash (GFile *file,
}
homedir = g_get_home_dir ();
g_stat (homedir, &home_stat);
if (g_stat (homedir, &home_stat) != 0)
{
errsv = errno;
g_set_io_error (error,
_("Error trashing file %s: %s"),
file, errsv);
return FALSE;
}
is_homedir_trash = FALSE;
trashdir = NULL;

View File

@ -282,10 +282,13 @@ watcher_send_command (const gchar *command)
{
GIOChannel *channel;
GError *error = NULL;
GIOStatus status;
channel = watcher_init ();
g_io_channel_write_chars (channel, command, -1, NULL, &error);
do
status = g_io_channel_write_chars (channel, command, -1, NULL, &error);
while (status == G_IO_STATUS_AGAIN);
g_assert_no_error (error);
g_io_channel_flush (channel, &error);