[openbsd-compat/strlcpy.c]
     Convert do {} while loop -> while {} for clarity.  No binary change
     on most architectures.  From Oliver Smith.  OK deraadt@ and henning@
This commit is contained in:
Damien Miller 2011-09-23 10:38:11 +10:00
parent add1e20802
commit b9cd0491f7
1 changed files with 5 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $ */
/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
@ -37,11 +37,11 @@ strlcpy(char *dst, const char *src, size_t siz)
size_t n = siz;
/* Copy as many bytes as will fit */
if (n != 0 && --n != 0) {
do {
if ((*d++ = *s++) == 0)
if (n != 0) {
while (--n != 0) {
if ((*d++ = *s++) == '\0')
break;
} while (--n != 0);
}
}
/* Not enough room in dst, add NUL and traverse rest of src */