If successful, asprintf() returns the number of characters written. Due
to the format strings this will always be >0. On error, asprintf()
returns -1, which means the return value will in any case be non-zero,
always leading to a (false) ENOMEM.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Rares Miculescu <miculescur@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #865
if (!pathname)
return EFAULT;
error = asprintf(&ap, "%s/%s", main_task->t_cwd, pathname);
- if (error || !ap)
+ if (unlikely(error == -1))
return ENOMEM;
-
} else {
struct vfscore_file *fp;
else
error = asprintf(&ap, "%s/%s", fp->f_dentry->d_mount->m_path,
fp->f_dentry->d_path);
- if (error || !ap)
+ if (unlikely(error == -1))
return ENOMEM;
}