Re: [PATCH v2 1/1] zlib.c: use size_t for size
- From
Jeff King <peff@peff.net>
- Date
- Oct 15, 2018, 00:01 UTC
- Message-ID
- <20181015000147.GB13510@sigill.intra.peff.net>
- In-Reply-To
- <1e3233f4-ea40-6fff-0951-6b4885f88445@ramsayjones.plus.com>
On Sun, Oct 14, 2018 at 04:03:48PM +0100, Ramsay Jones wrote:
Show 15 quoted lines
> > So I kind of wonder if a comment would be better than xsize_t here.
> > Something like:
> >
> > if (avail > len) {
> > /*
> > * This can never truncate because we know that len is smaller
> > * than avail, which is already a size_t.
> > */
> > avail = (size_t)len;
> > }
>
> Heh, you are, of course, correct! (that will learn me[1]). :-D
>
> Hmm, let's see if I can muster the enthusiasm to do all that
> testing again!For the record, I am not opposed to including the comment _and_ using xsize_t() to do the cast, giving us an assertion that the comment is correct.
-Peff