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:
raiden00pl 2019-10-11 08:03:44 +00:00 committed by Gregory Nutt
parent 6a683b0b54
commit df1bcc4229

View file

@ -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 */