mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 13:18:50 +08:00
Merged in raiden00/nuttx_sim (pull request #1047)
drivers/pipes/fifo.c: mkfifo should return -1 and set errno on failure Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
parent
6a683b0b54
commit
df1bcc4229
1 changed files with 10 additions and 2 deletions
|
@ -110,6 +110,7 @@ static const struct file_operations fifo_fops =
|
||||||
int mkfifo2(FAR const char *pathname, mode_t mode, size_t bufsize)
|
int mkfifo2(FAR const char *pathname, mode_t mode, size_t bufsize)
|
||||||
{
|
{
|
||||||
FAR struct pipe_dev_s *dev;
|
FAR struct pipe_dev_s *dev;
|
||||||
|
int errcode;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Allocate and initialize a new device structure instance */
|
/* Allocate and initialize a new device structure instance */
|
||||||
|
@ -117,16 +118,23 @@ int mkfifo2(FAR const char *pathname, mode_t mode, size_t bufsize)
|
||||||
dev = pipecommon_allocdev(bufsize);
|
dev = pipecommon_allocdev(bufsize);
|
||||||
if (!dev)
|
if (!dev)
|
||||||
{
|
{
|
||||||
return -ENOMEM;
|
errcode = ENOMEM;
|
||||||
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = register_driver(pathname, &fifo_fops, mode, (FAR void *)dev);
|
ret = register_driver(pathname, &fifo_fops, mode, (FAR void *)dev);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
pipecommon_freedev(dev);
|
pipecommon_freedev(dev);
|
||||||
|
errcode = -ret;
|
||||||
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return OK;
|
||||||
|
|
||||||
|
errout:
|
||||||
|
set_errno(errcode);
|
||||||
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_DEV_FIFO_SIZE > 0 */
|
#endif /* CONFIG_DEV_FIFO_SIZE > 0 */
|
||||||
|
|
Loading…
Reference in a new issue