Commit Diff


commit - 5bb151602f7bbbdda1d76e528186ff4de4060b7c
commit + 098056c9af1a2a51aeabb65765cdce5ffc5f1021
blob - e9efb90c2107143711b3b4283142f00087f5eba9
blob + 7530e80c91e7061efdb03aa62e3b9c1595b0d834
--- libexec/got-read-blob/got-read-blob.c
+++ libexec/got-read-blob/got-read-blob.c
@@ -172,6 +172,7 @@ main(int argc, char *argv[])
 			err = got_error_from_errno("fdopen");
 			goto done;
 		}
+		fd = -1;
 
 		if (obj->size + obj->hdrlen <=
 		    GOT_PRIVSEP_INLINE_BLOB_DATA_MAX) {
@@ -197,17 +198,12 @@ main(int argc, char *argv[])
 		err = got_privsep_send_blob(&ibuf, size, obj->hdrlen, buf);
 done:
 		free(buf);
-		if (f) {
-			if (fclose(f) == EOF && err == NULL)
-				err = got_error_from_errno("fclose");
-		} else if (fd != -1) {
-			if (close(fd) == -1 && err == NULL)
-				err = got_error_from_errno("close");
-		}
-		if (outfd != -1) {
-			if (close(outfd) == -1 && err == NULL)
-				err = got_error_from_errno("close");
-		}
+		if (f && fclose(f) == EOF && err == NULL)
+			err = got_error_from_errno("fclose");
+		if (fd != -1 && close(fd) == -1 && err == NULL)
+			err = got_error_from_errno("close");
+		if (outfd != -1 && close(outfd) == -1 && err == NULL)
+			err = got_error_from_errno("close");
 
 		imsg_free(&imsg);
 		imsg_free(&imsg_outfd);