summaryrefslogtreecommitdiff
path: root/components/drivers/src/pipe.c
diff options
context:
space:
mode:
authorWayne Lin <[email protected]>2020-05-15 09:41:27 +0800
committerWayne Lin <[email protected]>2020-05-15 09:41:27 +0800
commit5d65fe074f0e0ba53673ffef6205aab6baa76d0a (patch)
tree9847ae8364cbd3c7cec8168ba75e2c5cb15a8a41 /components/drivers/src/pipe.c
parent39431f5a702f3dcec843cb8884064953594243ec (diff)
parentdab737f6375f5cdd86ad3bc6d166657b17364948 (diff)
Merge branch 'master' of https://github.com/rt-thread/rt-thread into rtt_issues
Diffstat (limited to 'components/drivers/src/pipe.c')
-rw-r--r--components/drivers/src/pipe.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/components/drivers/src/pipe.c b/components/drivers/src/pipe.c
index ae87b6f5f2..2a7e143f6c 100644
--- a/components/drivers/src/pipe.c
+++ b/components/drivers/src/pipe.c
@@ -323,18 +323,29 @@ static const struct dfs_file_ops pipe_fops =
rt_err_t rt_pipe_open (rt_device_t device, rt_uint16_t oflag)
{
rt_pipe_t *pipe = (rt_pipe_t *)device;
+ rt_err_t ret = RT_EOK;
- if (device == RT_NULL) return -RT_EINVAL;
+ if (device == RT_NULL)
+ {
+ ret = -RT_EINVAL;
+ goto __exit;
+ }
+
rt_mutex_take(&(pipe->lock), RT_WAITING_FOREVER);
if (pipe->fifo == RT_NULL)
{
pipe->fifo = rt_ringbuffer_create(pipe->bufsz);
+ if (pipe->fifo == RT_NULL)
+ {
+ ret = -RT_ENOMEM;
+ }
}
rt_mutex_release(&(pipe->lock));
- return RT_EOK;
+__exit:
+ return ret;
}
rt_err_t rt_pipe_close (rt_device_t device)