Re: [PATCH v2 4/7] pkt-line: extern packet_length()
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- May 18, 2020, 17:50 UTC
- Message-ID
- <CAPig+cQhZyyQ05B3xF1EkK0hpF8bXMbbPEJXGUdTkoZ5JaHO=Q@mail.gmail.com>
- In-Reply-To
- <20200518160425.GA42240@coredump.intra.peff.net>
On Mon, May 18, 2020 at 12:04 PM Jeff King <peff@peff.net> wrote:
Show 12 quoted lines
> On Mon, May 18, 2020 at 11:47:21AM -0400, Denton Liu wrote: > > 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. > > > +/* > > + * 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..."?
I had the exact same reaction when reading "...should not be null-terminated", however, I'd prefer to drop mention of NUL-termination altogether since talking about it merely confuses the issue since it is quite clear both from the declaration (const char[4]) and the documentation "four hex digits" that 'linelen' is expected to contain exactly four hex digits and no NUL character(s).
By the way, I find the argument name "linelen" highly confusing; every time I read it, I think it is an integral type, not a string or character array. I'd very much prefer to see it renamed to "s" (or something) or dropped altogether:
int packet_length(const char[4]);