summaryrefslogtreecommitdiff
path: root/apps/examples/pipe
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-09-28 16:50:07 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-09-28 16:50:07 -0600
commit4c24c7c4a741eaeffc76339f07076cdad7a36c56 (patch)
tree337a94000f0e849884e81e8ac2ee188bf0a38179 /apps/examples/pipe
parente735773fe5ea269b43dbecb246cec846b3a0368e (diff)
downloadnuttx-4c24c7c4a741eaeffc76339f07076cdad7a36c56.tar.gz
nuttx-4c24c7c4a741eaeffc76339f07076cdad7a36c56.tar.bz2
nuttx-4c24c7c4a741eaeffc76339f07076cdad7a36c56.zip
Clean up some naming: fd vs. fildes vs. filedes and filep vs filp
Diffstat (limited to 'apps/examples/pipe')
-rw-r--r--apps/examples/pipe/pipe_main.c28
-rw-r--r--apps/examples/pipe/redirect_test.c26
2 files changed, 27 insertions, 27 deletions
diff --git a/apps/examples/pipe/pipe_main.c b/apps/examples/pipe/pipe_main.c
index 63a4f283f..9ada9af5f 100644
--- a/apps/examples/pipe/pipe_main.c
+++ b/apps/examples/pipe/pipe_main.c
@@ -1,7 +1,7 @@
/****************************************************************************
* examples/pipe/pipe_main.c
*
- * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2011, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -74,7 +74,7 @@
int pipe_main(int argc, char *argv[])
{
- int filedes[2];
+ int fd[2];
int ret;
/* Test FIFO logic */
@@ -93,20 +93,20 @@ int pipe_main(int argc, char *argv[])
* only on open for read-only (see interlock_test()).
*/
- filedes[1] = open(FIFO_PATH1, O_WRONLY);
- if (filedes[1] < 0)
+ fd[1] = open(FIFO_PATH1, O_WRONLY);
+ if (fd[1] < 0)
{
fprintf(stderr, "pipe_main: Failed to open FIFO %s for writing, errno=%d\n",
FIFO_PATH1, errno);
return 2;
}
- filedes[0] = open(FIFO_PATH1, O_RDONLY);
- if (filedes[0] < 0)
+ fd[0] = open(FIFO_PATH1, O_RDONLY);
+ if (fd[0] < 0)
{
fprintf(stderr, "pipe_main: Failed to open FIFO %s for reading, errno=%d\n",
FIFO_PATH1, errno);
- if (close(filedes[1]) != 0)
+ if (close(fd[1]) != 0)
{
fprintf(stderr, "pipe_main: close failed: %d\n", errno);
}
@@ -115,12 +115,12 @@ int pipe_main(int argc, char *argv[])
/* Then perform the test using those file descriptors */
- ret = transfer_test(filedes[0], filedes[1]);
- if (close(filedes[0]) != 0)
+ ret = transfer_test(fd[0], fd[1]);
+ if (close(fd[0]) != 0)
{
fprintf(stderr, "pipe_main: close failed: %d\n", errno);
}
- if (close(filedes[1]) != 0)
+ if (close(fd[1]) != 0)
{
fprintf(stderr, "pipe_main: close failed: %d\n", errno);
}
@@ -136,7 +136,7 @@ int pipe_main(int argc, char *argv[])
/* Test PIPE logic */
printf("\npipe_main: Performing pipe test\n");
- ret = pipe(filedes);
+ ret = pipe(fd);
if (ret < 0)
{
fprintf(stderr, "pipe_main: pipe failed with errno=%d\n", errno);
@@ -145,12 +145,12 @@ int pipe_main(int argc, char *argv[])
/* Then perform the test using those file descriptors */
- ret = transfer_test(filedes[0], filedes[1]);
- if (close(filedes[0]) != 0)
+ ret = transfer_test(fd[0], fd[1]);
+ if (close(fd[0]) != 0)
{
fprintf(stderr, "pipe_main: close failed: %d\n", errno);
}
- if (close(filedes[1]) != 0)
+ if (close(fd[1]) != 0)
{
fprintf(stderr, "pipe_main: close failed: %d\n", errno);
}
diff --git a/apps/examples/pipe/redirect_test.c b/apps/examples/pipe/redirect_test.c
index 26fe9bcaa..ddce093f1 100644
--- a/apps/examples/pipe/redirect_test.c
+++ b/apps/examples/pipe/redirect_test.c
@@ -79,7 +79,7 @@ static int redirect_reader(int argc, char *argv[])
int fdout;
int ret;
int nbytes = 0;
-
+
printf("redirect_reader: started with fdin=%s\n", argv[1]);
/* Convert the fdin to binary */
@@ -135,7 +135,7 @@ static int redirect_reader(int argc, char *argv[])
nbytes += ret;
/* Echo to stdout */
-
+
ret = write(1, buffer, ret);
if (ret < 0)
{
@@ -167,9 +167,9 @@ static int redirect_writer(int argc, char *argv[])
int fdout;
int nbytes = 0;
int ret;
-
+
fprintf(stderr, "redirect_writer: started with fdout=%s\n", argv[2]);
-
+
/* Convert the fdout to binary */
fdin = atoi(argv[1]);
@@ -252,29 +252,29 @@ int redirection_test(void)
char buffer2[8];
int readerid;
int writerid;
- int filedes[2];
+ int fd[2];
int ret;
sem_init(&g_rddone, 0, 0);
/* Create the pipe */
- ret = pipe(filedes);
+ ret = pipe(fd);
if (ret < 0)
{
fprintf(stderr, "redirection_test: pipe failed with errno=%d\n", errno);
return 5;
}
-
- sprintf(buffer1, "%d", filedes[0]);
+
+ sprintf(buffer1, "%d", fd[0]);
argv[0] = buffer1;
- sprintf(buffer2, "%d", filedes[1]);
+ sprintf(buffer2, "%d", fd[1]);
argv[1] = buffer2;
argv[2] = NULL;
/* Start redirect_reader thread */
- printf("redirection_test: Starting redirect_reader task with fd=%d\n", filedes[0]);
+ printf("redirection_test: Starting redirect_reader task with fd=%d\n", fd[0]);
readerid = task_create("redirect_reader", 50, CONFIG_EXAMPLES_PIPE_STACKSIZE, redirect_reader, argv);
if (readerid < 0)
{
@@ -284,7 +284,7 @@ int redirection_test(void)
/* Start redirect_writer task */
- printf("redirection_test: Starting redirect_writer task with fd=%d\n", filedes[1]);
+ printf("redirection_test: Starting redirect_writer task with fd=%d\n", fd[1]);
writerid = task_create("redirect_writer", 50, CONFIG_EXAMPLES_PIPE_STACKSIZE, redirect_writer, argv);
if (writerid < 0)
{
@@ -299,11 +299,11 @@ int redirection_test(void)
/* We should be able to close the pipe file descriptors now. */
- if (close(filedes[0]) != 0)
+ if (close(fd[0]) != 0)
{
fprintf(stderr, "pipe_main: close failed: %d\n", errno);
}
- if (close(filedes[1]) != 0)
+ if (close(fd[1]) != 0)
{
fprintf(stderr, "pipe_main: close failed: %d\n", errno);
}