mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 04:19:37 +08:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user