Use lib_get_pathbuffer instead of stack variables

Summary:
  Modified the usage logic, mainly introduced lib_get_pathbuffer and lib_put_pathbuffer

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
chenrun1
2024-10-09 12:14:18 +08:00
committed by Xiang Xiao
parent 0c9203b48e
commit 2cf26036a5
33 changed files with 545 additions and 111 deletions
+17 -4
View File
@@ -66,20 +66,33 @@
int utimensat(int dirfd, FAR const char *path,
const struct timespec times[2], int flags)
{
char fullpath[PATH_MAX];
FAR char *fullpath;
int ret;
ret = lib_getfullpath(dirfd, path, fullpath, sizeof(fullpath));
fullpath = lib_get_pathbuffer();
if (fullpath == NULL)
{
set_errno(ENOMEM);
return ERROR;
}
ret = lib_getfullpath(dirfd, path, fullpath, PATH_MAX);
if (ret < 0)
{
lib_put_pathbuffer(fullpath);
set_errno(-ret);
return ERROR;
}
if ((flags & AT_SYMLINK_NOFOLLOW) != 0)
{
return lutimens(fullpath, times);
ret = lutimens(fullpath, times);
}
else
{
ret = utimens(fullpath, times);
}
return utimens(fullpath, times);
lib_put_pathbuffer(fullpath);
return ret;
}