calling function fd_put() before rt_set_errno()
then tid->error can avoid being changed unexpectedly git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1940 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
4f458c68d2
commit
48a170f861
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* File : dfs_posix.c
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2004-2011, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2004-2012, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
|
@ -44,12 +44,12 @@ int open(const char *file, int flags, int mode)
|
|||
result = dfs_file_open(d, file, flags);
|
||||
if (result < 0)
|
||||
{
|
||||
rt_set_errno(result);
|
||||
|
||||
/* release the ref-count of fd */
|
||||
fd_put(d);
|
||||
fd_put(d);
|
||||
|
||||
rt_set_errno(result);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -117,8 +117,8 @@ int read(int fd, void *buf, size_t len)
|
|||
result = dfs_file_read(d, buf, len);
|
||||
if (result < 0)
|
||||
{
|
||||
rt_set_errno(result);
|
||||
fd_put(d);
|
||||
rt_set_errno(result);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -154,8 +154,8 @@ int write(int fd, const void *buf, size_t len)
|
|||
result = dfs_file_write(d, buf, len);
|
||||
if (result < 0)
|
||||
{
|
||||
rt_set_errno(result);
|
||||
fd_put(d);
|
||||
rt_set_errno(result);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ off_t lseek(int fd, off_t offset, int whence)
|
|||
break;
|
||||
}
|
||||
|
||||
if(offset < 0)
|
||||
if (offset < 0)
|
||||
{
|
||||
rt_set_errno(DFS_STATUS_EINVAL);
|
||||
return -1;
|
||||
|
@ -209,8 +209,8 @@ off_t lseek(int fd, off_t offset, int whence)
|
|||
result = dfs_file_lseek(d, offset);
|
||||
if (result < 0)
|
||||
{
|
||||
rt_set_errno(result);
|
||||
fd_put(d);
|
||||
rt_set_errno(result);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -354,7 +354,7 @@ int statfs(const char *path, struct statfs *buf)
|
|||
*
|
||||
* @return 0 on successful, others on failed.
|
||||
*/
|
||||
int mkdir (const char *path, mode_t mode)
|
||||
int mkdir(const char *path, mode_t mode)
|
||||
{
|
||||
int fd;
|
||||
struct dfs_fd *d;
|
||||
|
@ -373,8 +373,8 @@ int mkdir (const char *path, mode_t mode)
|
|||
|
||||
if (result < 0)
|
||||
{
|
||||
rt_set_errno(result);
|
||||
fd_put(d);
|
||||
rt_set_errno(result);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -436,7 +436,7 @@ DIR *opendir(const char *name)
|
|||
if (result >= 0)
|
||||
{
|
||||
/* open successfully */
|
||||
t = (DIR *) rt_malloc (sizeof(DIR));
|
||||
t = (DIR *) rt_malloc(sizeof(DIR));
|
||||
if (t == RT_NULL)
|
||||
{
|
||||
dfs_file_close(d);
|
||||
|
@ -486,8 +486,8 @@ struct dirent *readdir(DIR *d)
|
|||
result = dfs_file_getdents(fd, (struct dirent*)d->buf, sizeof(d->buf) - 1);
|
||||
if (result <= 0)
|
||||
{
|
||||
rt_set_errno(result);
|
||||
fd_put(fd);
|
||||
rt_set_errno(result);
|
||||
|
||||
return RT_NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue