Signed-off-by: Fabien Chouteau <chout...@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