On Thu, Aug 25, 2016 at 11:15 AM, Todd C. Miller <todd.mil...@courtesan.com> wrote: > This is what strnlen(3) is for, let's use it... > > Alternately, we could unify things like: > > len = prec >= 0 ? strnlen(cp, prec) : strlen(cp); > if (len > INT_MAX) > goto overflow; > size = (int)len; > > but that means declaring "size_t len" at the top of the for(;;) loop.
This: if (blah) { size_t len; ... } else { size_t len; ... } looks noisy to me, so I would lean towards your latter idea. Philip