All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-trivial] [PATCH V2] get_tmp_filename: add explicit error message
@ 2013-02-06 14:17 Fabien Chouteau
  2013-02-18 13:47 ` Stefan Hajnoczi
  2013-02-18 16:37 ` [Qemu-trivial] [Qemu-devel] " Markus Armbruster
  0 siblings, 2 replies; 5+ messages in thread
From: Fabien Chouteau @ 2013-02-06 14:17 UTC (permalink / raw)
  To: qemu-trivial; +Cc: kwolf, qemu-devel, stefanha, armbru

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
---
 block.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/block.c b/block.c
index ba67c0d..79fe01b 100644
--- a/block.c
+++ b/block.c
@@ -428,9 +428,16 @@ int get_tmp_filename(char *filename, int size)
     /* GetTempFileName requires that its output buffer (4th param)
        have length MAX_PATH or greater.  */
     assert(size >= MAX_PATH);
-    return (GetTempPath(MAX_PATH, temp_dir)
-            && GetTempFileName(temp_dir, "qem", 0, filename)
-            ? 0 : -GetLastError());
+    if (GetTempPath(MAX_PATH, temp_dir) == 0) {
+        error_report("%s: GetTempPath() error: %d\n", __func__, GetLastError());
+        return -GetLastError();
+    }
+    if (GetTempFileName(temp_dir, "qem", 0, filename) == 0) {
+        error_report("%s: GetTempFileName(%s) error: %d\n", __func__, temp_dir,
+                GetLastError());
+        return -GetLastError();
+    }
+    return 0;
 #else
     int fd;
     const char *tmpdir;
@@ -442,9 +449,11 @@ int get_tmp_filename(char *filename, int size)
     }
     fd = mkstemp(filename);
     if (fd < 0) {
+        error_report("%s: mkstemp() error: %s\n", __func__, strerror(errno));
         return -errno;
     }
     if (close(fd) != 0) {
+        error_report("%s: close() error: %s\n", __func__, strerror(errno));
         unlink(filename);
         return -errno;
     }
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-02-19 12:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-06 14:17 [Qemu-trivial] [PATCH V2] get_tmp_filename: add explicit error message Fabien Chouteau
2013-02-18 13:47 ` Stefan Hajnoczi
2013-02-18 16:37 ` [Qemu-trivial] [Qemu-devel] " Markus Armbruster
2013-02-19 10:28   ` Fabien Chouteau
2013-02-19 12:01     ` Markus Armbruster

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.