Thread (227 messages) 227 messages, 10 authors, 2019-01-07

Re: [PATCH v15 22/27] bisect--helper: `bisect_log` shell function in C

From: Stephan Beyer <hidden>
Date: 2016-11-17 21:47:39

Hi,

On 10/14/2016 04:14 PM, Pranit Bauva wrote:
quoted hunk ↗ jump to hunk
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 493034c..c18ca07 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -858,6 +858,23 @@ static int bisect_state(struct bisect_terms *terms, const char **argv,
 	return -1;
 }
 
+static int bisect_log(void)
+{
+	int fd, status;
+	fd = open(git_path_bisect_log(), O_RDONLY);
+	if (fd < 0)
+		return -1;
+
+	status = copy_fd(fd, 1);
Perhaps

	status = copy_fd(fd, STDOUT_FILENO);
+	if (status) {
+		close(fd);
+		return -1;
+	}
+
+	close(fd);
+	return status;
+}
That's weird.
Either get rid of the if() and actually use status:

	status = copy_fd(fd, STDOUT_FILENO);

	close(fd);
	return status ? -1 : 0;

or get rid of status and use the if:

	if (copy_fd(fd, STDOUT_FILENO)) {
		close(fd);
		return -1;
	}

	close(fd);
	return 0;

I'd recommend the shorter variant ;)

~Stephan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help