From 4f1d3e3e3b35b7fef1763a59f59b369b9674cfc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 14 Oct 2021 22:15:11 +0200 Subject: pkt-line.[ch]: remove unused packet_buf_write_len() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This function was added in f1f4d8acf40 (pkt-line: add packet_buf_write_len function, 2018-03-15) for use in 0f1dc53f45d (remote-curl: implement stateless-connect command, 2018-03-15). In a97d00799a1 (remote-curl: use post_rpc() for protocol v2 also, 2019-02-21) that only user of it went away, let's remove it. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- pkt-line.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'pkt-line.c') diff --git a/pkt-line.c b/pkt-line.c index 9f63eae2e6..2c536e7f16 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -252,22 +252,6 @@ void packet_buf_write(struct strbuf *buf, const char *fmt, ...) va_end(args); } -void packet_buf_write_len(struct strbuf *buf, const char *data, size_t len) -{ - size_t orig_len, n; - - orig_len = buf->len; - strbuf_addstr(buf, "0000"); - strbuf_add(buf, data, len); - n = buf->len - orig_len; - - if (n > LARGE_PACKET_MAX) - die(_("protocol error: impossibly long line")); - - set_packet_header(&buf->buf[orig_len], n); - packet_trace(data, len, 1); -} - int write_packetized_from_fd_no_flush(int fd_in, int fd_out) { char *buf = xmalloc(LARGE_PACKET_DATA_MAX); -- cgit v1.2.3 From ec9a37d69b4b327c08668bb897f27f25276a5b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 14 Oct 2021 22:15:12 +0200 Subject: pkt-line.[ch]: remove unused packet_read_line_buf() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- pkt-line.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'pkt-line.c') diff --git a/pkt-line.c b/pkt-line.c index 2c536e7f16..80f48e4cd3 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -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 -- cgit v1.2.3