path: root/pkt-line.c
diff options
authorDenton Liu <>2020-05-19 10:53:57 (GMT)
committerJunio C Hamano <>2020-05-19 22:40:26 (GMT)
commit101736a14c9ad734fe24efed7513189849cd22eb (patch)
treef1c6dbb47c3997920415831dd8264282efddafb4 /pkt-line.c
parentdde72f94bcba8f84f4ea6523b67302df6638c9c0 (diff)
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 <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'pkt-line.c')
1 files changed, 3 insertions, 3 deletions
diff --git a/pkt-line.c b/pkt-line.c
index a0e87b1..3beab1d 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,