summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/string.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/string.c b/lib/string.c
index b7df79574a57..d50185536bf3 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -87,10 +87,12 @@ char * strncpy(char * dest,const char *src,size_t count)
{
char *tmp = dest;
- while (count-- && (*dest++ = *src++) != '\0')
- /* nothing */;
- while (count-- > 0)
+ while (count && (*dest++ = *src++) != '\0')
+ count--;
+ while (count) {
*dest++ = 0;
+ count--;
+ }
return tmp;
}
#endif