summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2006-05-05 15:27:39 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2006-05-05 15:27:39 +0000
commitfded76b603159686e912195d2de81fc4ed6ecfbd (patch)
treef7f4cf4756db65353800f4fb6ce9b55c78878af0 /lib/libc
parent547a14de341d3e5dbe02976d287bb549b6ff67a3 (diff)
Convert do {} while loop -> while {} for clarity. No binary change
on most architectures. From Oliver Smith. OK deraadt@ and henning@
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/string/strlcpy.c10
-rw-r--r--lib/libc/string/wcslcpy.c10
2 files changed, 10 insertions, 10 deletions
diff --git a/lib/libc/string/strlcpy.c b/lib/libc/string/strlcpy.c
index 110155f76fa..d32b6590f1e 100644
--- a/lib/libc/string/strlcpy.c
+++ b/lib/libc/string/strlcpy.c
@@ -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>
@@ -32,11 +32,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 */
diff --git a/lib/libc/string/wcslcpy.c b/lib/libc/string/wcslcpy.c
index 4a9afffd98c..85f51df35f8 100644
--- a/lib/libc/string/wcslcpy.c
+++ b/lib/libc/string/wcslcpy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wcslcpy.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */
+/* $OpenBSD: wcslcpy.c,v 1.4 2006/05/05 15:27:38 millert Exp $ */
/* $NetBSD: wcslcpy.c,v 1.2 2001/01/03 14:33:02 lukem Exp $ */
/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */
@@ -45,11 +45,11 @@ wcslcpy(wchar_t *dst, const wchar_t *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 */