OSDN Git Service

sideband.c: make send_sideband() return void
authorLukas Fleischer <lfleischer@lfos.de>
Tue, 14 Jun 2016 14:49:16 +0000 (16:49 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Jun 2016 18:40:19 +0000 (11:40 -0700)
The send_sideband() function uses write_or_die() for writing data which
immediately terminates the process on errors. If no such error occurred,
send_sideband() always returned the value that was passed as fourth
parameter prior to this commit. This value is already known to the
caller in any case, so let's turn send_sideband() into a void function
instead.

Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sideband.c
sideband.h
upload-pack.c

index fde8adc..c09929d 100644 (file)
@@ -124,9 +124,8 @@ int recv_sideband(const char *me, int in_stream, int out)
  * fd is connected to the remote side; send the sideband data
  * over multiplexed packet stream.
  */
-ssize_t send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max)
+void send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max)
 {
-       ssize_t ssz = sz;
        const char *p = data;
 
        while (sz) {
@@ -148,5 +147,4 @@ ssize_t send_sideband(int fd, int band, const char *data, ssize_t sz, int packet
                p += n;
                sz -= n;
        }
-       return ssz;
 }
index e46bed0..7a8146f 100644 (file)
@@ -5,6 +5,6 @@
 #define SIDEBAND_REMOTE_ERROR -1
 
 int recv_sideband(const char *me, int in_stream, int out);
-ssize_t send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max);
+void send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max);
 
 #endif
index f19444d..f9d6410 100644 (file)
@@ -60,8 +60,10 @@ static void reset_timeout(void)
 
 static ssize_t send_client_data(int fd, const char *data, ssize_t sz)
 {
-       if (use_sideband)
-               return send_sideband(1, fd, data, sz, use_sideband);
+       if (use_sideband) {
+               send_sideband(1, fd, data, sz, use_sideband);
+               return sz;
+       }
        if (fd == 3)
                /* emergency quit */
                fd = 2;