git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] Make send_client_data() return void

From
Lukas Fleischer <lfleischer@lfos.de>
Date
Jun 14, 2016, 14:49 UTC
Message-ID
<20160614144917.14163-2-lfleischer@lfos.de>
In-Reply-To
<20160614144917.14163-1-lfleischer@lfos.de>

The send_client_data() function uses write_or_die() for writing data which immediately terminates the process on errors. If no such error occurred, send_client_data() always returned the value that was passed as third parameter prior to this commit. This value is already known to the caller in any case, so let's turn send_client_data() into a void function instead.

Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
---
 upload-pack.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/upload-pack.c b/upload-pack.c
index cab71b1..432d585 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -65,11 +65,11 @@ static void reset_timeout(void)
 	alarm(timeout);
 }
 
-static ssize_t send_client_data(int fd, const char *data, ssize_t sz)
+static void send_client_data(int fd, const char *data, ssize_t sz)
 {
 	if (use_sideband) {
 		send_sideband(1, fd, data, sz, use_sideband);
-		return sz;
+		return;
 	}
 	if (fd == 3)
 		/* emergency quit */
@@ -77,10 +77,9 @@ static ssize_t send_client_data(int fd, const char *data, ssize_t sz)
 	if (fd == 2) {
 		/* XXX: are we happy to lose stuff here? */
 		xwrite(fd, data, sz);
-		return sz;
+		return;
 	}
 	write_or_die(fd, data, sz);
-	return sz;
 }
 
 static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
@@ -245,9 +244,7 @@ static void create_pack_file(void)
 			}
 			else
 				buffered = -1;
-			sz = send_client_data(1, data, sz);
-			if (sz < 0)
-				goto fail;
+			send_client_data(1, data, sz);
 		}
 
 		/*
@@ -274,9 +271,7 @@ static void create_pack_file(void)
 	/* flush the data */
 	if (0 <= buffered) {
 		data[0] = buffered;
-		sz = send_client_data(1, data, 1);
-		if (sz < 0)
-			goto fail;
+		send_client_data(1, data, 1);
 		fprintf(stderr, "flushed.\n");
 	}
 	if (use_sideband)
-- 
2.8.3
Previous: Lukas Fleischer
Message 2 of 2 in “Make send_sideband() return void”
  1. 1/2 Make send_sideband() return voidLukas Fleischer, Jun 14, 2016
  2. 2/2 Make send_client_data() return voidLukas Fleischer, Jun 14, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.