Skip to content

Commit 5e891e1

Browse files
authored
Merge pull request #4 from Damien-Chen/strlen
Correct return type of strlen function
2 parents 7af2982 + f95a700 commit 5e891e1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/libc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ static inline int byte_is_match(uint32_t w, uint32_t pat)
2020
}
2121

2222
/* strlen that scans by words whenever possible for efficiency. */
23-
int32_t strlen(const char *s)
23+
size_t strlen(const char *s)
2424
{
2525
const char *p = s;
2626

2727
/* Align pointer to word boundary (4 bytes) */
2828
while ((uint32_t) p & 3) {
2929
if (!*p) /* If null terminator is found byte-by-byte */
30-
return (int32_t) (p - s);
30+
return (size_t) (p - s);
3131
p++;
3232
}
3333

@@ -42,7 +42,7 @@ int32_t strlen(const char *s)
4242
p = (const char *) w;
4343
while (*p) /* Scan byte-by-byte until the null terminator. */
4444
p++;
45-
return (int32_t) (p - s); /* Return total length. */
45+
return (size_t) (p - s); /* Return total length. */
4646
}
4747

4848
void *memcpy(void *dst, const void *src, uint32_t len)

0 commit comments

Comments
 (0)