Clean up some naming: fd vs. fildes vs. filedes and filep vs filp

This commit is contained in:
Gregory Nutt 2013-09-28 16:50:07 -06:00
parent 5f16a8c304
commit 59a89b687d
3 changed files with 31 additions and 31 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -133,7 +133,7 @@ static inline int readline_rawgetc(int infd)
nread = read(infd, &buffer, 1);
/* Check for end-of-file. */
if (nread == 0)
{
/* Return EOF on end-of-file */
@ -186,7 +186,7 @@ static inline void readline_consoleputc(int ch, int outfd)
nwritten = write(outfd, &buffer, 1);
/* Check for irrecoverable write errors. */
if (nwritten < 0 && errno != EINTR)
{
break;
@ -264,8 +264,8 @@ ssize_t readline(FAR char *buf, int buflen, FILE *instream, FILE *outstream)
* standard)
*/
infd = instream->fs_filedes;
outfd = outstream->fs_filedes;
infd = instream->fs_fd;
outfd = outstream->fs_fd;
/* <esc>[K is the VT100 command that erases to the end of the line. */