diff options
author | Denton Liu <liu.denton@gmail.com> | 2020-05-19 12:53:57 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-05-20 00:40:26 +0200 |
commit | 101736a14c9ad734fe24efed7513189849cd22eb (patch) | |
tree | f1c6dbb47c3997920415831dd8264282efddafb4 /pkt-line.c | |
parent | transport: extract common fetch_pack() call (diff) | |
download | git-101736a14c9ad734fe24efed7513189849cd22eb.tar.xz git-101736a14c9ad734fe24efed7513189849cd22eb.zip |
pkt-line: extern packet_length()
In a future commit, we will be manually processing packets and we will
need to access the length header. In order to simplify this, extern
packet_length() so that the logic can be reused.
Change the function parameter from `const char *linelen` to
`const char lenbuf_hex[4]`. Even though these two types behave
identically as function parameters, use the array notation to
semantically indicate exactly what this function is expecting as an
argument. Also, rename it from linelen to lenbuf_hex as the former
sounds like it should be an integral type which is misleading.
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pkt-line.c')
-rw-r--r-- | pkt-line.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pkt-line.c b/pkt-line.c index a0e87b1e81..3beab1dc6b 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -306,10 +306,10 @@ static int get_packet_data(int fd, char **src_buf, size_t *src_size, return ret; } -static int packet_length(const char *linelen) +int packet_length(const char lenbuf_hex[4]) { - int val = hex2chr(linelen); - return (val < 0) ? val : (val << 8) | hex2chr(linelen + 2); + int val = hex2chr(lenbuf_hex); + return (val < 0) ? val : (val << 8) | hex2chr(lenbuf_hex + 2); } enum packet_read_status packet_read_with_status(int fd, char **src_buffer, |