diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-12-28 16:36:08 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2009-12-28 16:36:08 +0000 |
commit | 44be50c22f5bb8d9a3c00bd0ff6bcdf97e0da22f (patch) | |
tree | 7727045fe5bc27127acf9b28ae8a10a7565a800b /cpukit/libfs | |
parent | 2009-12-23 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-44be50c22f5bb8d9a3c00bd0ff6bcdf97e0da22f.tar.bz2 |
2009-12-28 Shrikant Gaikwad <n3oo3n@gmail.com>
* cpukit/libfs/src/pipe/pipe.c Restructured code to remove the
goto statements.
Diffstat (limited to 'cpukit/libfs')
-rw-r--r-- | cpukit/libfs/src/pipe/pipe.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/cpukit/libfs/src/pipe/pipe.c b/cpukit/libfs/src/pipe/pipe.c index 54628898ac..cf38c45e95 100644 --- a/cpukit/libfs/src/pipe/pipe.c +++ b/cpukit/libfs/src/pipe/pipe.c @@ -28,7 +28,6 @@ int pipe_create( rtems_filesystem_location_info_t loc; rtems_libio_t *iop; int err = 0; - /* Create /tmp if not exists */ if (rtems_filesystem_evaluate_path("/tmp", 3, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE) != 0) { @@ -47,8 +46,9 @@ int pipe_create( /* Try creating FIFO file until find an available file name */ while (mkfifo(fifopath, S_IRUSR|S_IWUSR) != 0) { - if (errno != EEXIST) + if (errno != EEXIST){ return -1; + } /* Just try once... */ return -1; sprintf(fifopath + 10, "%04x", rtems_pipe_no ++); @@ -58,26 +58,24 @@ int pipe_create( filsdes[0] = open(fifopath, O_RDONLY | O_NONBLOCK); if (filsdes[0] < 0) { err = errno; - goto out; + /* Delete file at errors, or else if pipe is successfully created + the file node will be deleted after it is closed by all. */ + unlink(fifopath); } - + else { /* Reset open file to blocking mode */ - iop = rtems_libio_iop(filsdes[0]); - iop->flags &= ~LIBIO_FLAGS_NO_DELAY; + iop = rtems_libio_iop(filsdes[0]); + iop->flags &= ~LIBIO_FLAGS_NO_DELAY; - filsdes[1] = open(fifopath, O_WRONLY); + filsdes[1] = open(fifopath, O_WRONLY); - if (filsdes[1] < 0) { + if (filsdes[1] < 0) { err = errno; close(filsdes[0]); - } - -out: - /* Delete file at errors, or else if pipe is successfully created - the file node will be deleted after it is closed by all. */ + } unlink(fifopath); + } - if (! err) - return 0; rtems_set_errno_and_return_minus_one(err); } + |