Skip to content

Commit

Permalink
Merge pull request #505 from pa3fwm/fix-strcpy-return-value
Browse files Browse the repository at this point in the history
Fix return value of strcpy() and strncpy(): they should return a poin…
  • Loading branch information
cnlohr authored Feb 2, 2025
2 parents ec727ff + bcbe979 commit 1e097b8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ch32v003fun/ch32v003fun.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,15 @@ WEAK size_t strnlen(const char *s, size_t n) { const char *p = memchr(s, 0, n);
WEAK void *memset(void *dest, int c, size_t n) { unsigned char *s = dest; for (; n; n--, s++) *s = c; return dest; }
WEAK char *strcpy(char *d, const char *s)
{
char *d0=d;
for (; (*d=*s); s++, d++);
return d;
return d0;
}
WEAK char *strncpy(char *d, const char *s, size_t n)
{
char *d0=d;
for (; n && (*d=*s); n--, s++, d++);
return d;
return d0;
}
WEAK int strcmp(const char *l, const char *r)
{
Expand Down

0 comments on commit 1e097b8

Please sign in to comment.