4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-02-28 03:47:11 +08:00

Update pipe.c

This commit is contained in:
David Lin 2020-04-13 07:20:29 +08:00 committed by GitHub
parent ff09587d23
commit e9d930070d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -323,8 +323,14 @@ static const struct dfs_file_ops pipe_fops =
rt_err_t rt_pipe_open (rt_device_t device, rt_uint16_t oflag) rt_err_t rt_pipe_open (rt_device_t device, rt_uint16_t oflag)
{ {
rt_pipe_t *pipe = (rt_pipe_t *)device; 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); rt_mutex_take(&(pipe->lock), RT_WAITING_FOREVER);
if (pipe->fifo == RT_NULL) if (pipe->fifo == RT_NULL)
@ -332,14 +338,14 @@ rt_err_t rt_pipe_open (rt_device_t device, rt_uint16_t oflag)
pipe->fifo = rt_ringbuffer_create(pipe->bufsz); pipe->fifo = rt_ringbuffer_create(pipe->bufsz);
if (pipe->fifo == RT_NULL) if (pipe->fifo == RT_NULL)
{ {
rt_mutex_release(&(pipe->lock)); ret = -RT_ENOMEM;
return -RT_ENOMEM;
} }
} }
rt_mutex_release(&(pipe->lock)); rt_mutex_release(&(pipe->lock));
return RT_EOK; __exit:
return ret;
} }
rt_err_t rt_pipe_close (rt_device_t device) rt_err_t rt_pipe_close (rt_device_t device)