Skip to content

Commit ec9a37d

Browse files
avargitster
authored andcommitted
pkt-line.[ch]: remove unused packet_read_line_buf()
This function was added in 4981fe7 (pkt-line: share buffer/descriptor reading implementation, 2013-02-23), but in 01f9ec6 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4f1d3e3 commit ec9a37d

File tree

6 files changed

+13
-36
lines changed

6 files changed

+13
-36
lines changed

builtin/checkout--worker.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ static void worker_loop(struct checkout *state)
8282
size_t i, nr = 0, alloc = 0;
8383

8484
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);
8787

8888
if (len < 0)
8989
BUG("packet_read() returned negative value");

daemon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ static int execute(void)
770770

771771
set_keep_alive(0);
772772
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);
774774
alarm(0);
775775

776776
len = strlen(line);

parallel-checkout.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,7 @@ static void gather_results_from_workers(struct pc_worker *workers,
603603
continue;
604604

605605
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,
608607
sizeof(packet_buffer), 0);
609608

610609
if (len < 0) {

pkt-line.c

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -400,38 +400,28 @@ enum packet_read_status packet_read_with_status(int fd, char **src_buffer,
400400
return PACKET_READ_NORMAL;
401401
}
402402

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)
405404
{
406405
int pktlen = -1;
407406

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);
410409

411410
return pktlen;
412411
}
413412

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)
417414
{
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),
420416
PACKET_READ_CHOMP_NEWLINE);
421417
if (dst_len)
422418
*dst_len = len;
423419
return (len > 0) ? packet_buffer : NULL;
424420
}
425421

426-
char *packet_read_line(int fd, int *len_p)
427-
{
428-
return packet_read_line_generic(fd, NULL, NULL, len_p);
429-
}
430-
431422
int packet_read_line_gently(int fd, int *dst_len, char **dst_line)
432423
{
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),
435425
PACKET_READ_CHOMP_NEWLINE|PACKET_READ_GENTLE_ON_EOF);
436426
if (dst_len)
437427
*dst_len = len;
@@ -440,11 +430,6 @@ int packet_read_line_gently(int fd, int *dst_len, char **dst_line)
440430
return len;
441431
}
442432

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-
448433
ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out, int options)
449434
{
450435
int packet_len;
@@ -454,7 +439,7 @@ ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out, int options)
454439

455440
for (;;) {
456441
strbuf_grow(sb_out, LARGE_PACKET_DATA_MAX);
457-
packet_len = packet_read(fd_in, NULL, NULL,
442+
packet_len = packet_read(fd_in,
458443
/* strbuf_grow() above always allocates one extra byte to
459444
* store a '\0' at the end of the string. packet_read()
460445
* writes a '\0' extra byte at the end, too. Let it know

pkt-line.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ int write_packetized_from_buf_no_flush(const char *src_in, size_t len, int fd_ou
7676
#define PACKET_READ_CHOMP_NEWLINE (1u<<1)
7777
#define PACKET_READ_DIE_ON_ERR_PACKET (1u<<2)
7878
#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);
8180

8281
/*
8382
* Convert a four hex digit packet line length header into its numeric
@@ -126,12 +125,6 @@ char *packet_read_line(int fd, int *size);
126125
*/
127126
int packet_read_line_gently(int fd, int *size, char **dst_line);
128127

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-
135128
/*
136129
* Reads a stream of variable sized packets until a flush packet is detected.
137130
*/

remote-curl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads,
10911091
rpc->protocol_header = NULL;
10921092

10931093
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);
10951095
if (!n)
10961096
break;
10971097
rpc->pos = 0;

0 commit comments

Comments
 (0)