pkt-line.[ch]: remove unused packet_read_line_buf()
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>
Ævar Arnfjörð Bjarmason committed
Oct 14, 2021 at 22:15 UTC
ec9a37d69b4b327c08668bb897f27f25276a5b1c
6 files changed
+13
-36
builtin/checkout--worker.c
+2
-2
@@ -82,8 +82,8 @@ static void worker_loop(struct checkout *state)
82
size_t i, nr = 0, alloc = 0;
83
84
while (1) {
85
- int len = packet_read(0, NULL, NULL, packet_buffer,
86
- sizeof(packet_buffer), 0);
85
+ int len = packet_read(0, packet_buffer, sizeof(packet_buffer),
86
+ 0);
87
88
if (len < 0)
89
BUG("packet_read() returned negative value");
daemon.c
+1
-1
@@ -770,7 +770,7 @@ static int execute(void)
770
771
set_keep_alive(0);
772
alarm(init_timeout ? init_timeout : timeout);
773
- pktlen = packet_read(0, NULL, NULL, packet_buffer, sizeof(packet_buffer), 0);
773
+ pktlen = packet_read(0, packet_buffer, sizeof(packet_buffer), 0);
774
alarm(0);
775
776
len = strlen(line);
parallel-checkout.c
+1
-2
@@ -603,8 +603,7 @@ static void gather_results_from_workers(struct pc_worker *workers,
603
continue;
604
605
if (pfd->revents & POLLIN) {
606
- int len = packet_read(pfd->fd, NULL, NULL,
607
- packet_buffer,
606
+ int len = packet_read(pfd->fd, packet_buffer,
607
sizeof(packet_buffer), 0);
608
609
if (len < 0) {
pkt-line.c
+7
-22
@@ -400,38 +400,28 @@ enum packet_read_status packet_read_with_status(int fd, char **src_buffer,
400
return PACKET_READ_NORMAL;
401
}
402
403
-int packet_read(int fd, char **src_buffer, size_t *src_len,
404
- char *buffer, unsigned size, int options)
403
+int packet_read(int fd, char *buffer, unsigned size, int options)
404
{
405
int pktlen = -1;
406
408
- packet_read_with_status(fd, src_buffer, src_len, buffer, size,
409
- &pktlen, options);
407
+ packet_read_with_status(fd, NULL, NULL, buffer, size, &pktlen,
408
+ options);
409
410
return pktlen;
411
}
412
414
-static char *packet_read_line_generic(int fd,
415
- char **src, size_t *src_len,
416
- int *dst_len)
413
+char *packet_read_line(int fd, int *dst_len)
414
{
418
- int len = packet_read(fd, src, src_len,
419
- packet_buffer, sizeof(packet_buffer),
415
+ int len = packet_read(fd, packet_buffer, sizeof(packet_buffer),
416
PACKET_READ_CHOMP_NEWLINE);
417
if (dst_len)
418
*dst_len = len;
419
return (len > 0) ? packet_buffer : NULL;
420
}
421
426
-char *packet_read_line(int fd, int *len_p)
427
-{
428
- return packet_read_line_generic(fd, NULL, NULL, len_p);
429
-}
430
-
422
int packet_read_line_gently(int fd, int *dst_len, char **dst_line)
423
{
433
- int len = packet_read(fd, NULL, NULL,
434
- packet_buffer, sizeof(packet_buffer),
424
+ int len = packet_read(fd, packet_buffer, sizeof(packet_buffer),
425
PACKET_READ_CHOMP_NEWLINE|PACKET_READ_GENTLE_ON_EOF);
426
if (dst_len)
427
*dst_len = len;
@@ -440,11 +430,6 @@ int packet_read_line_gently(int fd, int *dst_len, char **dst_line)
430
return len;
431
}
432
443
-char *packet_read_line_buf(char **src, size_t *src_len, int *dst_len)
444
-{
445
- return packet_read_line_generic(-1, src, src_len, dst_len);
446
-}
447
-
433
ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out, int options)
434
{
435
int packet_len;
@@ -454,7 +439,7 @@ ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out, int options)
439
440
for (;;) {
441
strbuf_grow(sb_out, LARGE_PACKET_DATA_MAX);
457
- packet_len = packet_read(fd_in, NULL, NULL,
442
+ packet_len = packet_read(fd_in,
443
/* strbuf_grow() above always allocates one extra byte to
444
* store a '\0' at the end of the string. packet_read()
445
* writes a '\0' extra byte at the end, too. Let it know
pkt-line.h
+1
-8
@@ -76,8 +76,7 @@ int write_packetized_from_buf_no_flush(const char *src_in, size_t len, int fd_ou
76
#define PACKET_READ_CHOMP_NEWLINE (1u<<1)
77
#define PACKET_READ_DIE_ON_ERR_PACKET (1u<<2)
78
#define PACKET_READ_GENTLE_ON_READ_ERROR (1u<<3)
79
-int packet_read(int fd, char **src_buffer, size_t *src_len, char
80
- *buffer, unsigned size, int options);
79
+int packet_read(int fd, char *buffer, unsigned size, int options);
80
81
/*
82
* Convert a four hex digit packet line length header into its numeric
@@ -126,12 +125,6 @@ char *packet_read_line(int fd, int *size);
125
*/
126
int packet_read_line_gently(int fd, int *size, char **dst_line);
127
129
-/*
130
- * Same as packet_read_line, but read from a buf rather than a descriptor;
131
- * see packet_read for details on how src_* is used.
132
- */
133
-char *packet_read_line_buf(char **src_buf, size_t *src_len, int *size);
134
-
128
/*
129
* Reads a stream of variable sized packets until a flush packet is detected.
130
*/
remote-curl.c
+1
-1
@@ -1091,7 +1091,7 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads,
1091
rpc->protocol_header = NULL;
1092
1093
while (!err) {
1094
- int n = packet_read(rpc->out, NULL, NULL, rpc->buf, rpc->alloc, 0);
1094
+ int n = packet_read(rpc->out, rpc->buf, rpc->alloc, 0);
1095
if (!n)
1096
break;
1097
rpc->pos = 0;