Define strnlen when it is not in libc

Chi-Hua Chen via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 29 09:15:08 PST 2016


On Mon, Nov 28, 2016 at 9:16 PM, Hubert Tong
<hubert.reinterpretcast at gmail.com> wrote:
> This implementation of strnlen reads one more byte than is allowed by the
> specification at
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/strlen.html.

Thanks. Changed the condition from
  while (*s++ && maxlen-- > 0)
to
  while (maxlen-- > 0 && *s++)

- Chi-Hua


More information about the llvm-commits mailing list