Commit Diff


commit - a6b21eef0424b9af0a7d5dc6ade675b94dde3150
commit + 56b63ca4ab1049de6fa2d6910ce22c16e2b42a53
blob - 47e8801b98449d0d980a504de018d37c45183fc7
blob + 4cb72ca19c8b859c0474710e93a5154db3170520
--- got/got.c
+++ got/got.c
@@ -8442,7 +8442,7 @@ histedit_run_editor(struct got_histedit_list *histedit
 
 	err = histedit_check_script(histedit_cmds, commits, repo);
 done:
-	if (f && fclose(f) != 0 && err == NULL)
+	if (f && fclose(f) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	free(editor);
 	return err;
@@ -8479,7 +8479,7 @@ histedit_edit_script(struct got_histedit_list *histedi
 		rewind(f);
 		err = histedit_parse_list(histedit_cmds, f, repo);
 	} else {
-		if (fclose(f) != 0) {
+		if (fclose(f) == EOF) {
 			err = got_error_from_errno("fclose");
 			goto done;
 		}
@@ -8494,7 +8494,7 @@ histedit_edit_script(struct got_histedit_list *histedi
 		}
 	}
 done:
-	if (f && fclose(f) != 0 && err == NULL)
+	if (f && fclose(f) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	if (path && unlink(path) != 0 && err == NULL)
 		err = got_error_from_errno2("unlink", path);
@@ -8537,7 +8537,7 @@ histedit_save_list(struct got_histedit_list *histedit_
 		}
 	}
 done:
-	if (f && fclose(f) != 0 && err == NULL)
+	if (f && fclose(f) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	free(path);
 	if (commit)
@@ -8571,7 +8571,7 @@ histedit_load_list(struct got_histedit_list *histedit_
 
 	err = histedit_parse_list(histedit_cmds, f, repo);
 done:
-	if (f && fclose(f) != 0 && err == NULL)
+	if (f && fclose(f) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	return err;
 }
blob - b657ec5ba42677b92a8726bc24022c48ee71e23e
blob + 5251b5a0c5366a6290eb08871fc51273ed568885
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
@@ -2696,7 +2696,7 @@ gw_get_repo_description(char **description, struct gw_
 	if (n == 0 && ferror(f))
 		error = got_ferror(f, GOT_ERR_IO);
 done:
-	if (f != NULL && fclose(f) == -1 && error == NULL)
+	if (f != NULL && fclose(f) == EOF && error == NULL)
 		error = got_error_from_errno("fclose");
 	free(d_file);
 	return error;
@@ -2911,7 +2911,7 @@ gw_output_diff(struct gw_trans *gw_trans, struct gw_he
 	if (linelen == -1 && ferror(f))
 		error = got_error_from_errno("getline");
 done:
-	if (f && fclose(f) == -1 && error == NULL)
+	if (f && fclose(f) == EOF && error == NULL)
 		error = got_error_from_errno("fclose");
 	free(line);
 	free(label1);
@@ -2994,7 +2994,7 @@ gw_get_clone_url(char **url, struct gw_trans *gw_trans
 	if (n == 0 && ferror(f))
 		error = got_ferror(f, GOT_ERR_IO);
 done:
-	if (f && fclose(f) == -1 && error == NULL)
+	if (f && fclose(f) == EOF && error == NULL)
 		error = got_error_from_errno("fclose");
 	free(d_file);
 	return NULL;
blob - c8bf3d34301f36a4658b22aaa33062dfaad55853
blob + 8c1e08c465eace7793b3aec1bcd4841063476335
--- lib/blame.c
+++ lib/blame.c
@@ -293,9 +293,9 @@ blame_close(struct got_blame *blame)
 		if (munmap(blame->map2, blame->size2) == -1 && err == NULL)
 			err = got_error_from_errno("munmap");
 	}
-	if (blame->f1 && fclose(blame->f1) != 0 && err == NULL)
+	if (blame->f1 && fclose(blame->f1) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
-	if (blame->f2 && fclose(blame->f2) != 0 && err == NULL)
+	if (blame->f2 && fclose(blame->f2) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	free(blame->lines);
 	free(blame->line_offsets1);
blob - 194fedc8fa1abc94fee0ebebe9c8a693426b89c2
blob + d26165918de1c2cf191ee734e77336fd67356f58
--- lib/delta.c
+++ lib/delta.c
@@ -382,7 +382,7 @@ got_delta_apply(FILE *base_file, const uint8_t *delta_
 		err = got_error(GOT_ERR_BAD_DELTA);
 
 	if (memstream != NULL) {
-		if (fclose(memstream) != 0)
+		if (fclose(memstream) == EOF)
 			err = got_error_from_errno("fclose");
 		if (err == NULL) {
 			size_t n;
blob - ab9338f610ccb3d2aac14b126d7201e501f48cb3
blob + 54a0944d64ec3e964a3e3d8938d5cea99aaf76f6
--- lib/diff.c
+++ lib/diff.c
@@ -189,9 +189,9 @@ diff_blobs(off_t **line_offsets, size_t *nlines,
 			err = free_err;
 	}
 done:
-	if (f1 && fclose(f1) != 0 && err == NULL)
+	if (f1 && fclose(f1) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
-	if (f2 && fclose(f2) != 0 && err == NULL)
+	if (f2 && fclose(f2) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	return err;
 }
@@ -279,7 +279,7 @@ diff_blob_file(struct got_diffreg_result **resultp,
 			err = free_err;
 	}
 done:
-	if (f1 && fclose(f1) != 0 && err == NULL)
+	if (f1 && fclose(f1) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	return err;
 }
blob - 861cb6f29586892ef12113a5db50c7e4329eb9e0
blob + 837a0e0977d8c7fbd52ad7789978b0e57d7b1ebb
--- lib/diff3.c
+++ lib/diff3.c
@@ -244,11 +244,11 @@ done:
 			err = got_error_from_errno2("unlink", outpath);
 		free(outpath);
 	}
-	if (outfile && fclose(outfile) != 0 && err == NULL)
+	if (outfile && fclose(outfile) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
-	if (f1 && fclose(f1) != 0 && err == NULL)
+	if (f1 && fclose(f1) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
-	if (f2 && fclose(f2) != 0 && err == NULL)
+	if (f2 && fclose(f2) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	return err;
 }
@@ -394,7 +394,7 @@ out:
 	free(patch);
 
 	for (i = 0; i < nitems(d3s->fp); i++) {
-		if (d3s->fp[i] && fclose(d3s->fp[i]) != 0 && err == NULL)
+		if (d3s->fp[i] && fclose(d3s->fp[i]) == EOF && err == NULL)
 			err = got_error_from_errno("fclose");
 	}
 	if (err == NULL && diffb) {
@@ -629,7 +629,7 @@ readin(size_t *n, char *name, struct diff **dd, struct
 		(*dd)[i].new.from = (*dd)[i - 1].new.to;
 	}
 done:
-	if (fclose(f) != 0 && err == NULL)
+	if (fclose(f) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	if (err == NULL)
 		*n = i;
blob - 918b50bbce65306ade20a6e42612dd9e4ad88aac
blob + 7bfd862b598c07fd5e72ed48db149670ae49ffbb
--- lib/diffreg.c
+++ lib/diffreg.c
@@ -98,9 +98,9 @@ got_diffreg_close(FILE *f1, char *p1, size_t size1,
 		err = got_error_from_errno("munmap");
 	if (p2 && munmap(p2, size2) == -1 && err == NULL)
 		err = got_error_from_errno("munmap");
-	if (f1 && fclose(f1) != 0 && err == NULL)
+	if (f1 && fclose(f1) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
-	if (f2 && fclose(f2) != 0 && err == NULL)
+	if (f2 && fclose(f2) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	return err;
 }
blob - 7bd55922b5b83ac06fbadac4c69364802b1a6179
blob + 7fe404aef7be55ad09e966e88a09b5f50694bda7
--- lib/object.c
+++ lib/object.c
@@ -1229,7 +1229,7 @@ got_object_blob_close(struct got_blob_object *blob)
 {
 	const struct got_error *err = NULL;
 	free(blob->read_buf);
-	if (blob->f && fclose(blob->f) != 0)
+	if (blob->f && fclose(blob->f) == EOF)
 		err = got_error_from_errno("fclose");
 	free(blob->data);
 	free(blob);
blob - 71e76e0ebe9a73692b22f11470e926c20f44b98c
blob + 69a6e9627e2dc2a7d0090ee468fbae0ab966ad61
--- lib/object_create.c
+++ lib/object_create.c
@@ -104,7 +104,7 @@ done:
 			err = got_error_from_errno2("unlink", tmppath);
 		free(tmppath);
 	}
-	if (tmpfile && fclose(tmpfile) != 0 && err == NULL)
+	if (tmpfile && fclose(tmpfile) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	if (lf)
 		unlock_err = got_lockfile_unlock(lf);
@@ -394,7 +394,7 @@ got_object_tree_create(struct got_object_id **id,
 done:
 	free(header);
 	free(sorted_entries);
-	if (treefile && fclose(treefile) != 0 && err == NULL)
+	if (treefile && fclose(treefile) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	if (err) {
 		free(*id);
@@ -573,7 +573,7 @@ done:
 	free(tree_str);
 	free(author_str);
 	free(committer_str);
-	if (commitfile && fclose(commitfile) != 0 && err == NULL)
+	if (commitfile && fclose(commitfile) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	if (err) {
 		free(*id);
@@ -751,7 +751,7 @@ done:
 	free(header);
 	free(obj_str);
 	free(tagger_str);
-	if (tagfile && fclose(tagfile) != 0 && err == NULL)
+	if (tagfile && fclose(tagfile) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	if (err) {
 		free(*id);
blob - 29ca0f7c0d9a9deade9e459946d5f1eaca46a77b
blob + 71840ebb38db39cca7f0629d64ca474b0077e335
--- lib/reference.c
+++ lib/reference.c
@@ -227,7 +227,7 @@ parse_ref_file(struct got_reference **ref, const char 
 	}
 done:
 	free(line);
-	if (fclose(f) != 0 && err == NULL) {
+	if (fclose(f) == EOF && err == NULL) {
 		err = got_error_from_errno("fclose");
 		if (*ref) {
 			if (lock)
@@ -486,7 +486,7 @@ got_ref_open(struct got_reference **ref, struct got_re
 			err = open_packed_ref(ref, f, subdirs, nitems(subdirs),
 			    refname);
 			if (!err) {
-				if (fclose(f) != 0) {
+				if (fclose(f) == EOF) {
 					err = got_error_from_errno("fclose");
 					got_ref_close(*ref);
 					*ref = NULL;
@@ -1006,7 +1006,7 @@ done:
 	free(buf);
 	free(line);
 	free(path_refs);
-	if (f && fclose(f) != 0 && err == NULL)
+	if (f && fclose(f) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	return err;
 }
@@ -1159,7 +1159,7 @@ done:
 	if (ref->lf == NULL && lf)
 		unlock_err = got_lockfile_unlock(lf);
 	if (f) {
-		if (fclose(f) != 0 && err == NULL)
+		if (fclose(f) == EOF && err == NULL)
 			err = got_error_from_errno("fclose");
 	}
 	free(path_refs);
@@ -1304,12 +1304,12 @@ done:
 	if (delref->lf == NULL && lf)
 		unlock_err = got_lockfile_unlock(lf);
 	if (f) {
-		if (fclose(f) != 0 && err == NULL)
+		if (fclose(f) == EOF && err == NULL)
 			err = got_error_from_errno("fclose");
 	}
 	if (tmpf) {
 		unlink(tmppath);
-		if (fclose(tmpf) != 0 && err == NULL)
+		if (fclose(tmpf) == EOF && err == NULL)
 			err = got_error_from_errno("fclose");
 	}
 	free(tmppath);
blob - 9eb2d798442973db6cdaca5e079d37834bf0ca46
blob + 987475721d0a49779239dc049fb56d6ac2e2b2fb
--- lib/worktree.c
+++ lib/worktree.c
@@ -111,7 +111,7 @@ update_meta_file(const char *path_got, const char *nam
 	}
 
 done:
-	if (fclose(tmpfile) != 0 && err == NULL)
+	if (fclose(tmpfile) == EOF && err == NULL)
 		err = got_error_from_errno2("fclose", tmppath);
 	free(tmppath);
 	return err;
@@ -763,9 +763,9 @@ check_files_equal(int *same, const char *f1_path, cons
 
 	err = check_file_contents_equal(same, f1, f2);
 done:
-	if (f1 && fclose(f1) != 0 && err == NULL)
+	if (f1 && fclose(f1) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
-	if (f2 && fclose(f2) != 0 && err == NULL)
+	if (f2 && fclose(f2) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 
 	return err;
@@ -916,7 +916,7 @@ done:
 	free(symlink_path);
 	if (merged_fd != -1 && close(merged_fd) != 0 && err == NULL)
 		err = got_error_from_errno("close");
-	if (f_orig && fclose(f_orig) != 0 && err == NULL)
+	if (f_orig && fclose(f_orig) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	free(merged_path);
 	free(base_path);
@@ -1169,7 +1169,7 @@ merge_blob(int *local_changes_subsumed, struct got_wor
 	    ondisk_path, path, st_mode, blob_deriv_path, label_orig,
 	    label_deriv, repo, progress_cb, progress_arg);
 done:
-	if (f_deriv && fclose(f_deriv) != 0 && err == NULL)
+	if (f_deriv && fclose(f_deriv) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	free(base_path);
 	if (blob_deriv_path) {
@@ -2389,7 +2389,7 @@ open_fileindex(struct got_fileindex **fileindex, char 
 			err = got_error_from_errno2("fopen", *fileindex_path);
 	} else {
 		err = got_fileindex_read(*fileindex, index);
-		if (fclose(index) != 0 && err == NULL)
+		if (fclose(index) == EOF && err == NULL)
 			err = got_error_from_errno("fclose");
 	}
 done:
@@ -7694,7 +7694,7 @@ done:
 	if (path_new_staged_content &&
 	    unlink(path_new_staged_content) == -1 && err == NULL)
 		err = got_error_from_errno2("unlink", path_new_staged_content);
-	if (f && fclose(f) != 0 && err == NULL)
+	if (f && fclose(f) == EOF && err == NULL)
 		err = got_error_from_errno2("fclose", path_unstaged_content);
 	free(path_unstaged_content);
 	free(path_new_staged_content);
blob - 7e406576e1b1c9b3b3f5259a819620d83680b7f7
blob + e2a99e9244c1e8aa84a417baa7dee7d96f020631
--- libexec/got-read-blob/got-read-blob.c
+++ libexec/got-read-blob/got-read-blob.c
@@ -164,7 +164,7 @@ main(int argc, char *argv[])
 done:
 		free(buf);
 		if (f) {
-			if (fclose(f) != 0 && err == NULL)
+			if (fclose(f) == EOF && err == NULL)
 				err = got_error_from_errno("fclose");
 		} else if (imsg.fd != -1) {
 			if (close(imsg.fd) != 0 && err == NULL)
blob - 02685f91e98ddcfe9403eec99e73b35f964a30fb
blob + c87a051695b4876e48e59e310d957c7230135fb0
--- libexec/got-read-commit/got-read-commit.c
+++ libexec/got-read-commit/got-read-commit.c
@@ -148,7 +148,7 @@ main(int argc, char *argv[])
 		got_object_commit_close(commit);
 done:
 		if (f) {
-			if (fclose(f) != 0 && err == NULL)
+			if (fclose(f) == EOF && err == NULL)
 				err = got_error_from_errno("fclose");
 		} else if (imsg.fd != -1) {
 			if (close(imsg.fd) != 0 && err == NULL)
blob - 27d10ab755d53e96136938c0a9d1d5a574974686
blob + f753b89137938f9238c2baf1620368646f2ff8c1
--- libexec/got-read-pack/got-read-pack.c
+++ libexec/got-read-pack/got-read-pack.c
@@ -346,11 +346,11 @@ blob_request(struct imsg *imsg, struct imsgbuf *ibuf, 
 	err = got_privsep_send_blob(ibuf, obj->size, obj->hdrlen, buf);
 done:
 	free(buf);
-	if (outfile && fclose(outfile) != 0 && err == NULL)
+	if (outfile && fclose(outfile) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
-	if (basefile && fclose(basefile) != 0 && err == NULL)
+	if (basefile && fclose(basefile) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
-	if (accumfile && fclose(accumfile) != 0 && err == NULL)
+	if (accumfile && fclose(accumfile) == EOF && err == NULL)
 		err = got_error_from_errno("fclose");
 	got_object_close(obj);
 	if (err && err->code != GOT_ERR_PRIVSEP_PIPE)
blob - aad8331a9697582ede82b7f52785bf4c8b173cb8
blob + 69d50c0fc848f0a018c842f5226edd670aa1f4c9
--- libexec/got-read-tag/got-read-tag.c
+++ libexec/got-read-tag/got-read-tag.c
@@ -140,7 +140,7 @@ main(int argc, char *argv[])
 		err = got_privsep_send_tag(&ibuf, tag);
 done:
 		if (f) {
-			if (fclose(f) != 0 && err == NULL)
+			if (fclose(f) == EOF && err == NULL)
 				err = got_error_from_errno("fclose");
 		} else if (imsg.fd != -1) {
 			if (close(imsg.fd) != 0 && err == NULL)
blob - 741d51f94fe1970f533774c6866a6f49965e182f
blob + a2f17b2558df8d398aee3beceb01e40e84812c3f
--- libexec/got-read-tree/got-read-tree.c
+++ libexec/got-read-tree/got-read-tree.c
@@ -146,7 +146,7 @@ done:
 		got_object_parsed_tree_entries_free(&entries);
 		free(buf);
 		if (f) {
-			if (fclose(f) != 0 && err == NULL)
+			if (fclose(f) == EOF && err == NULL)
 				err = got_error_from_errno("fclose");
 		} else if (imsg.fd != -1) {
 			if (close(imsg.fd) != 0 && err == NULL)
blob - 5a34b467d53cdd00972ddb50999b123d4ff69ac9
blob + 984dc73376528f545472d7e802bb1dc495fb001d
--- regress/delta/delta_test.c
+++ regress/delta/delta_test.c
@@ -87,7 +87,7 @@ delta_apply(void)
 
 		err = got_delta_apply(base_file, dt->delta, dt->delta_len,
 		    result_file, &result_len);
-		if (fclose(base_file) != 0 && err == NULL)
+		if (fclose(base_file) == EOF && err == NULL)
 			err = got_error_from_errno("fclose");
 		if (dt->expected == NULL) {
 			/* Invalid delta, expect an error. */
blob - 767893aa64eee3688b73721fe03b7b54ae2f99a8
blob + 915bc83532c216505a96c19f3ac75ac031f66b87
--- tog/tog.c
+++ tog/tog.c
@@ -3252,7 +3252,7 @@ create_diff(struct tog_diff_view_state *s)
 		err = got_error_from_errno("got_opentemp");
 		goto done;
 	}
-	if (s->f && fclose(s->f) != 0) {
+	if (s->f && fclose(s->f) == EOF) {
 		err = got_error_from_errno("fclose");
 		goto done;
 	}
@@ -4163,7 +4163,7 @@ stop_blame(struct tog_blame *blame)
 		blame->thread_args.repo = NULL;
 	}
 	if (blame->f) {
-		if (fclose(blame->f) != 0 && err == NULL)
+		if (fclose(blame->f) == EOF && err == NULL)
 			err = got_error_from_errno("fclose");
 		blame->f = NULL;
 	}