Commit Diff


commit - 7614e0f6e88b262ccbce1f107e54a8f5b80c0fef
commit + b3be78f9089a5962b5ae04df5f76c6d0137879d5
blob - bef01d3c3adfe6a70c48ee294f475d29377f5400
blob + b3be4749f4694271e276c0162905dccddf9cc21d
--- libexec/got-read-blob/got-read-blob.c
+++ libexec/got-read-blob/got-read-blob.c
@@ -161,6 +161,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) {
@@ -186,17 +187,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);