Re: [PATCH v2 4/7] pkt-line: extern packet_length()
- From
Jeff King <peff@peff.net>
- Date
- May 18, 2020, 16:04 UTC
- Message-ID
- <20200518160425.GA42240@coredump.intra.peff.net>
- In-Reply-To
- <c2b9d033bb774d3bccb572802c3ae114cad8d830.1589816719.git.liu.denton@gmail.com>
On Mon, May 18, 2020 at 11:47:21AM -0400, Denton Liu wrote:
Show 8 quoted lines
> 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 a `const char *` to > `const char linelen[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.
OK. I double-checked that we will not run into any problems with passing pointers or arrays of other sizes (sadly compilers would not tell us if we passed a too-small array, but at least it's documented for humans).
> +/* > + * Convert a four hex digit packet line length header into its numeric > + * representation. linelen should not be null-terminated.
Minor nit, but it is perfectly fine if there is a NUL. Maybe "linelen does not need to be..."?
-Peff