]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pkt-line.[ch]: remove unused packet_read_line_buf()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Thu, 14 Oct 2021 20:15:12 +0000 (22:15 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 15 Oct 2021 20:09:40 +0000 (13:09 -0700)
This function was added in 4981fe750b1 (pkt-line: share
buffer/descriptor reading implementation, 2013-02-23), but in
01f9ec64c8a (Use packet_reader instead of packet_read_line,
2018-12-29) the code that was using it was removed.

Since it's being removed we can in turn remove the "src" and "src_len"
arguments to packet_read(), all the remaining users just passed a
NULL/NULL pair to it.

That function is only a thin wrapper for packet_read_with_status()
which still needs those arguments, but for the thin packet_read()
convenience wrapper we can do away with it for now.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout--worker.c
daemon.c
parallel-checkout.c
pkt-line.c
pkt-line.h
remote-curl.c

index fb9fd13b73c4f8af3f5c9e745ab3e20f30a5f77f..ede7dc32a43c01a78a0074e1bddd5ba18b487568 100644 (file)
@@ -82,8 +82,8 @@ static void worker_loop(struct checkout *state)
        size_t i, nr = 0, alloc = 0;
 
        while (1) {
-               int len = packet_read(0, NULL, NULL, packet_buffer,
-                                     sizeof(packet_buffer), 0);
+               int len = packet_read(0, packet_buffer, sizeof(packet_buffer),
+                                     0);
 
                if (len < 0)
                        BUG("packet_read() returned negative value");
index 5c4cbad62d0caa723a874392097512a0df5933cd..3b5f9a41ab23adfd03be3e13590aedb899fbf9b4 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -770,7 +770,7 @@ static int execute(void)
 
        set_keep_alive(0);
        alarm(init_timeout ? init_timeout : timeout);
-       pktlen = packet_read(0, NULL, NULL, packet_buffer, sizeof(packet_buffer), 0);
+       pktlen = packet_read(0, packet_buffer, sizeof(packet_buffer), 0);
        alarm(0);
 
        len = strlen(line);
index ddc0ff3c0646aed54724fe1b39753c28e50da3fc..ed9c999520703be35f3e022966b496943ef9c3f5 100644 (file)
@@ -603,8 +603,7 @@ static void gather_results_from_workers(struct pc_worker *workers,
                                continue;
 
                        if (pfd->revents & POLLIN) {
-                               int len = packet_read(pfd->fd, NULL, NULL,
-                                                     packet_buffer,
+                               int len = packet_read(pfd->fd, packet_buffer,
                                                      sizeof(packet_buffer), 0);
 
                                if (len < 0) {
index 2c536e7f162dcea50123b8eb5153ac2d044359b1..80f48e4cd3d4a18185b5128896c7cc9d45500d8f 100644 (file)
@@ -400,38 +400,28 @@ enum packet_read_status packet_read_with_status(int fd, char **src_buffer,
        return PACKET_READ_NORMAL;
 }
 
-int packet_read(int fd, char **src_buffer, size_t *src_len,
-               char *buffer, unsigned size, int options)
+int packet_read(int fd, char *buffer, unsigned size, int options)
 {
        int pktlen = -1;
 
-       packet_read_with_status(fd, src_buffer, src_len, buffer, size,
-                               &pktlen, options);
+       packet_read_with_status(fd, NULL, NULL, buffer, size, &pktlen,
+                               options);
 
        return pktlen;
 }
 
-static char *packet_read_line_generic(int fd,
-                                     char **src, size_t *src_len,
-                                     int *dst_len)
+char *packet_read_line(int fd, int *dst_len)
 {
-       int len = packet_read(fd, src, src_len,
-                             packet_buffer, sizeof(packet_buffer),
+       int len = packet_read(fd, packet_buffer, sizeof(packet_buffer),
                              PACKET_READ_CHOMP_NEWLINE);
        if (dst_len)
                *dst_len = len;
        return (len > 0) ? packet_buffer : NULL;
 }
 
-char *packet_read_line(int fd, int *len_p)
-{
-       return packet_read_line_generic(fd, NULL, NULL, len_p);
-}
-
 int packet_read_line_gently(int fd, int *dst_len, char **dst_line)
 {
-       int len = packet_read(fd, NULL, NULL,
-                             packet_buffer, sizeof(packet_buffer),
+       int len = packet_read(fd, packet_buffer, sizeof(packet_buffer),
                              PACKET_READ_CHOMP_NEWLINE|PACKET_READ_GENTLE_ON_EOF);
        if (dst_len)
                *dst_len = len;
@@ -440,11 +430,6 @@ int packet_read_line_gently(int fd, int *dst_len, char **dst_line)
        return len;
 }
 
-char *packet_read_line_buf(char **src, size_t *src_len, int *dst_len)
-{
-       return packet_read_line_generic(-1, src, src_len, dst_len);
-}
-
 ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out, int options)
 {
        int packet_len;
@@ -454,7 +439,7 @@ ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out, int options)
 
        for (;;) {
                strbuf_grow(sb_out, LARGE_PACKET_DATA_MAX);
-               packet_len = packet_read(fd_in, NULL, NULL,
+               packet_len = packet_read(fd_in,
                        /* strbuf_grow() above always allocates one extra byte to
                         * store a '\0' at the end of the string. packet_read()
                         * writes a '\0' extra byte at the end, too. Let it know
index 25dcb6a1fbc18ee8cc707dfc228204fb7c21291d..f8e01c231d31b84b5511dcd6c8eef95e3671d90e 100644 (file)
@@ -76,8 +76,7 @@ int write_packetized_from_buf_no_flush(const char *src_in, size_t len, int fd_ou
 #define PACKET_READ_CHOMP_NEWLINE        (1u<<1)
 #define PACKET_READ_DIE_ON_ERR_PACKET    (1u<<2)
 #define PACKET_READ_GENTLE_ON_READ_ERROR (1u<<3)
-int packet_read(int fd, char **src_buffer, size_t *src_len, char
-               *buffer, unsigned size, int options);
+int packet_read(int fd, char *buffer, unsigned size, int options);
 
 /*
  * Convert a four hex digit packet line length header into its numeric
@@ -126,12 +125,6 @@ char *packet_read_line(int fd, int *size);
  */
 int packet_read_line_gently(int fd, int *size, char **dst_line);
 
-/*
- * Same as packet_read_line, but read from a buf rather than a descriptor;
- * see packet_read for details on how src_* is used.
- */
-char *packet_read_line_buf(char **src_buf, size_t *src_len, int *size);
-
 /*
  * Reads a stream of variable sized packets until a flush packet is detected.
  */
index 6c320d5704598e4f0025af9c35dcc407c4cba980..3b674ef7a11a002663e0a4f59188904c22243fcb 100644 (file)
@@ -1091,7 +1091,7 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads,
                rpc->protocol_header = NULL;
 
        while (!err) {
-               int n = packet_read(rpc->out, NULL, NULL, rpc->buf, rpc->alloc, 0);
+               int n = packet_read(rpc->out, rpc->buf, rpc->alloc, 0);
                if (!n)
                        break;
                rpc->pos = 0;