{"thread":{"id":"42606","subject":"[PATCH 2/2] Make send_client_data() return void","startedAt":"2016-06-16T06:55:52Z","lastAt":"2016-06-16T06:55:52Z","messageCount":2,"participants":["Lukas Fleischer"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"289217","messageId":"20160614144917.14163-2-lfleischer@lfos.de","threadId":"42606","inReplyTo":"20160614144917.14163-1-lfleischer@lfos.de","subject":"[PATCH 2/2] Make send_client_data() return void","fromName":"Lukas Fleischer","fromEmail":"lfleischer@lfos.de","sentAt":"2016-06-14T14:49:17Z","receivedAt":"2016-06-16T06:55:52Z","isPatch":true,"sender":{"key":"lfleischer@lfos.de","avatar":"https://avatars.githubusercontent.com/u/5530842?v=4"},"body":"The send_client_data() function uses write_or_die() for writing data\nwhich immediately terminates the process on errors. If no such error\noccurred, send_client_data() always returned the value that was passed\nas third parameter prior to this commit. This value is already known to\nthe caller in any case, so let's turn send_client_data() into a void\nfunction instead.\n\nSigned-off-by: Lukas Fleischer <lfleischer@lfos.de>\n---\n upload-pack.c | 15 +++++----------\n 1 file changed, 5 insertions(+), 10 deletions(-)\n\ndiff --git a/upload-pack.c b/upload-pack.c\nindex cab71b1..432d585 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -65,11 +65,11 @@ static void reset_timeout(void)\n \talarm(timeout);\n }\n \n-static ssize_t send_client_data(int fd, const char *data, ssize_t sz)\n+static void send_client_data(int fd, const char *data, ssize_t sz)\n {\n \tif (use_sideband) {\n \t\tsend_sideband(1, fd, data, sz, use_sideband);\n-\t\treturn sz;\n+\t\treturn;\n \t}\n \tif (fd == 3)\n \t\t/* emergency quit */\n@@ -77,10 +77,9 @@ static ssize_t send_client_data(int fd, const char *data, ssize_t sz)\n \tif (fd == 2) {\n \t\t/* XXX: are we happy to lose stuff here? */\n \t\txwrite(fd, data, sz);\n-\t\treturn sz;\n+\t\treturn;\n \t}\n \twrite_or_die(fd, data, sz);\n-\treturn sz;\n }\n \n static int write_one_shallow(const struct commit_graft *graft, void *cb_data)\n@@ -245,9 +244,7 @@ static void create_pack_file(void)\n \t\t\t}\n \t\t\telse\n \t\t\t\tbuffered = -1;\n-\t\t\tsz = send_client_data(1, data, sz);\n-\t\t\tif (sz < 0)\n-\t\t\t\tgoto fail;\n+\t\t\tsend_client_data(1, data, sz);\n \t\t}\n \n \t\t/*\n@@ -274,9 +271,7 @@ static void create_pack_file(void)\n \t/* flush the data */\n \tif (0 <= buffered) {\n \t\tdata[0] = buffered;\n-\t\tsz = send_client_data(1, data, 1);\n-\t\tif (sz < 0)\n-\t\t\tgoto fail;\n+\t\tsend_client_data(1, data, 1);\n \t\tfprintf(stderr, \"flushed.\\n\");\n \t}\n \tif (use_sideband)\n-- \n2.8.3\n"},{"id":"289218","messageId":"20160614144917.14163-1-lfleischer@lfos.de","threadId":"42606","inReplyTo":null,"subject":"[PATCH 1/2] Make send_sideband() return void","fromName":"Lukas Fleischer","fromEmail":"lfleischer@lfos.de","sentAt":"2016-06-14T14:49:16Z","receivedAt":"2016-06-16T06:55:52Z","isPatch":true,"sender":{"key":"lfleischer@lfos.de","avatar":"https://avatars.githubusercontent.com/u/5530842?v=4"},"body":"The send_sideband() function uses write_or_die() for writing data which\nimmediately terminates the process on errors. If no such error occurred,\nsend_sideband() always returned the value that was passed as fourth\nparameter prior to this commit. This value is already known to the\ncaller in any case, so let's turn send_sideband() into a void function\ninstead.\n\nSigned-off-by: Lukas Fleischer <lfleischer@lfos.de>\n---\n sideband.c    | 4 +---\n sideband.h    | 2 +-\n upload-pack.c | 6 ++++--\n 3 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/sideband.c b/sideband.c\nindex 0a078c3..9504429 100644\n--- a/sideband.c\n+++ b/sideband.c\n@@ -90,9 +90,8 @@ int recv_sideband(const char *me, int in_stream, int out)\n  * fd is connected to the remote side; send the sideband data\n  * over multiplexed packet stream.\n  */\n-ssize_t send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max)\n+void send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max)\n {\n-\tssize_t ssz = sz;\n \tconst char *p = data;\n \n \twhile (sz) {\n@@ -114,5 +113,4 @@ ssize_t send_sideband(int fd, int band, const char *data, ssize_t sz, int packet\n \t\tp += n;\n \t\tsz -= n;\n \t}\n-\treturn ssz;\n }\ndiff --git a/sideband.h b/sideband.h\nindex e46bed0..7a8146f 100644\n--- a/sideband.h\n+++ b/sideband.h\n@@ -5,6 +5,6 @@\n #define SIDEBAND_REMOTE_ERROR -1\n \n int recv_sideband(const char *me, int in_stream, int out);\n-ssize_t send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max);\n+void send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max);\n \n #endif\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 56d101f..cab71b1 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -67,8 +67,10 @@ static void reset_timeout(void)\n \n static ssize_t send_client_data(int fd, const char *data, ssize_t sz)\n {\n-\tif (use_sideband)\n-\t\treturn send_sideband(1, fd, data, sz, use_sideband);\n+\tif (use_sideband) {\n+\t\tsend_sideband(1, fd, data, sz, use_sideband);\n+\t\treturn sz;\n+\t}\n \tif (fd == 3)\n \t\t/* emergency quit */\n \t\tfd = 2;\n-- \n2.8.3\n"}]}