diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2020-12-03 15:35:36 +0000 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2020-12-03 15:35:36 +0000 |
commit | 416339305f613383876473914484f22dc726164e (patch) | |
tree | 289ba6844436d76a658f1b8b5b65e53dac4a7a6b | |
parent | f83a7d54072b12721d1ac69865c120d65a25ccc5 (diff) | |
parent | eba2e7f0564beb04595fcf7581f761558f877661 (diff) | |
download | glib-416339305f613383876473914484f22dc726164e.tar.gz |
Merge branch 'coverity-return-values' into 'master'
Minor Coverity fixes
See merge request GNOME/glib!1780
-rw-r--r-- | gio/glocalfile.c | 27 | ||||
-rw-r--r-- | gio/gtestdbus.c | 5 |
2 files changed, 27 insertions, 5 deletions
diff --git a/gio/glocalfile.c b/gio/glocalfile.c index a87de9cc4..15738d8b8 100644 --- a/gio/glocalfile.c +++ b/gio/glocalfile.c @@ -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; diff --git a/gio/gtestdbus.c b/gio/gtestdbus.c index 96da52c68..9cfaadbf0 100644 --- a/gio/gtestdbus.c +++ b/gio/gtestdbus.c @@ -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); |