files-backend: convert git_path() to strbuf_git_path()
[gitweb.git] / tempfile.c
index 2990c92424832d288d5bbab2dfe79b5db361e0b0..68437106703470f39a6079aaad7d3bb407ac3389 100644 (file)
@@ -247,12 +247,13 @@ int close_tempfile(struct tempfile *tempfile)
        tempfile->fd = -1;
        if (fp) {
                tempfile->fp = NULL;
-
-               /*
-                * Note: no short-circuiting here; we want to fclose()
-                * in any case!
-                */
-               err = ferror(fp) | fclose(fp);
+               if (ferror(fp)) {
+                       err = -1;
+                       if (!fclose(fp))
+                               errno = EIO;
+               } else {
+                       err = fclose(fp);
+               }
        } else {
                err = close(fd);
        }