Skip to content

Commit

Permalink
Fix warn_unused_result issued for asprintf()
Browse files Browse the repository at this point in the history
  • Loading branch information
sonertari committed Oct 28, 2018
1 parent fa3773c commit 64b5269
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ char *
sys_realdir(const char *path)
{
char *sep, *udir, *rdir, *p;
int rerrno;
int rerrno, rv;

if (path[0] == '\0') {
errno = EINVAL;
Expand All @@ -650,8 +650,8 @@ sys_realdir(const char *path)
sep = strrchr(udir, '/');
if (!sep) {
free(udir);
(void)asprintf(&udir, "./%s", path);
if (!udir)
rv = asprintf(&udir, "./%s", path);
if (rv == -1)
return NULL;
sep = udir + 1;
} else if (sep == udir) {
Expand All @@ -665,11 +665,13 @@ sys_realdir(const char *path)
errno = rerrno;
return NULL;
}
(void)asprintf(&p, "%s/%s", rdir, sep + 1);
rv = asprintf(&p, "%s/%s", rdir, sep + 1);
rerrno = errno;
free(rdir);
free(udir);
errno = rerrno;
if (rv == -1)
return NULL;
return p;
}

Expand Down

0 comments on commit 64b5269

Please sign in to comment.