Skip to content

Commit

Permalink
lib/fs/readlink/readlinknul.h: readlinknul(): Silence warning
Browse files Browse the repository at this point in the history
Use a temporary variable to silence a sign-mismatch diagnostic.

Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar authored and hallyn committed Dec 10, 2024
1 parent 205c23b commit b9d00b6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/fs/readlink/readlinknul.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,23 @@ inline int readlinknul(const char *restrict link, char *restrict buf,
inline int
readlinknul(const char *restrict link, char *restrict buf, size_t size)
{
ssize_t len;
size_t ulen;
ssize_t slen;

len = readlink(link, buf, size);
if (len == -1)
slen = readlink(link, buf, size);
if (slen == -1)
return -1;

if (len == size) {
ulen = slen;
if (ulen == size) {
stpcpy(&buf[size-1], "");
errno = E2BIG;
return -1;
}

stpcpy(&buf[len], "");
return len;
stpcpy(&buf[ulen], "");

return slen;
}


Expand Down

0 comments on commit b9d00b6

Please sign in to comment.