Skip to content

Commit e9d9300

Browse files
authored
Update pipe.c
1 parent ff09587 commit e9d9300

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

components/drivers/src/pipe.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,23 +323,29 @@ static const struct dfs_file_ops pipe_fops =
323323
rt_err_t rt_pipe_open (rt_device_t device, rt_uint16_t oflag)
324324
{
325325
rt_pipe_t *pipe = (rt_pipe_t *)device;
326+
rt_err_t ret = RT_EOK;
326327

327-
if (device == RT_NULL) return -RT_EINVAL;
328+
if (device == RT_NULL)
329+
{
330+
ret = -RT_EINVAL;
331+
goto __exit;
332+
}
333+
328334
rt_mutex_take(&(pipe->lock), RT_WAITING_FOREVER);
329335

330336
if (pipe->fifo == RT_NULL)
331337
{
332338
pipe->fifo = rt_ringbuffer_create(pipe->bufsz);
333339
if (pipe->fifo == RT_NULL)
334340
{
335-
rt_mutex_release(&(pipe->lock));
336-
return -RT_ENOMEM;
341+
ret = -RT_ENOMEM;
337342
}
338343
}
339344

340345
rt_mutex_release(&(pipe->lock));
341346

342-
return RT_EOK;
347+
__exit:
348+
return ret;
343349
}
344350

345351
rt_err_t rt_pipe_close (rt_device_t device)

0 commit comments

Comments
 (0)