Commit Diff


commit - 41d2888bab776a1275b697b9eb293b81045bfee7
commit + 202329ae1b4393a9093c61915de94a5a9a51555a
blob - 32d933f695c149153b60e1f90ede46c6fbb4a444
blob + eb235b008a747da54825c94d958d96e8f0080399
--- lib/buf.c
+++ lib/buf.c
@@ -294,10 +294,11 @@ buf_write(BUF *b, const char *path, mode_t mode)
 	int fd;
  open:
 	if ((fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)) == -1) {
+		err = got_error_from_errno2("open", path);
 		if (errno == EACCES && unlink(path) != -1)
 			goto open;
 		else
-			return got_error_from_errno2("open", path);
+			return err;
 	}
 
 	if (buf_write_fd(b, fd) == -1) {
blob - 05aa9d3b001104a9b0383a1b83f76f77924f6916
blob + 9b907af2dab638d435d58c69188bb1ce33f7d641
--- lib/commit_graph.c
+++ lib/commit_graph.c
@@ -404,8 +404,9 @@ got_commit_graph_open(struct got_commit_graph **graph,
 
 	*graph = alloc_graph(path);
 	if (*graph == NULL) {
+		err = got_error_from_errno("alloc_graph");
 		got_object_commit_close(commit);
-		return got_error_from_errno("alloc_graph");
+		return err;
 	}
 
 	if (first_parent_traversal)
blob - a8c3780fee9346711ff6e8f74e29bd38320d307c
blob + 8ae1c968c45c54f7fc96908130daa2dd453393d3
--- lib/path.c
+++ lib/path.c
@@ -401,6 +401,7 @@ got_path_strip_trailing_slashes(char *path)
 const struct got_error *
 got_path_find_prog(char **filename, const char *prog)
 {
+	const struct got_error *err = NULL;
 	char *p;
 	int len;
 	struct stat sbuf;
@@ -436,8 +437,9 @@ got_path_find_prog(char **filename, const char *prog)
 			p[--len] = '\0';	/* strip trailing '/' */
 
 		if (asprintf(filename, "%s/%s", p, prog) == -1) {
+			err = got_error_from_errno("asprintf");
 			free(path);
-			return got_error_from_errno("asprintf");
+			return err;
 		}
 		if ((stat(*filename, &sbuf) == 0) && S_ISREG(sbuf.st_mode) &&
 		    access(*filename, X_OK) == 0) {