Skip to content
Snippets Groups Projects
Commit 59a89b68 authored by Gregory Nutt's avatar Gregory Nutt
Browse files

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

parent 5f16a8c3
No related branches found
No related tags found
No related merge requests found
/**************************************************************************** /****************************************************************************
* examples/pipe/pipe_main.c * 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> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
int pipe_main(int argc, char *argv[]) int pipe_main(int argc, char *argv[])
{ {
int filedes[2]; int fd[2];
int ret; int ret;
/* Test FIFO logic */ /* Test FIFO logic */
...@@ -93,20 +93,20 @@ int pipe_main(int argc, char *argv[]) ...@@ -93,20 +93,20 @@ int pipe_main(int argc, char *argv[])
* only on open for read-only (see interlock_test()). * only on open for read-only (see interlock_test()).
*/ */
filedes[1] = open(FIFO_PATH1, O_WRONLY); fd[1] = open(FIFO_PATH1, O_WRONLY);
if (filedes[1] < 0) if (fd[1] < 0)
{ {
fprintf(stderr, "pipe_main: Failed to open FIFO %s for writing, errno=%d\n", fprintf(stderr, "pipe_main: Failed to open FIFO %s for writing, errno=%d\n",
FIFO_PATH1, errno); FIFO_PATH1, errno);
return 2; return 2;
} }
filedes[0] = open(FIFO_PATH1, O_RDONLY); fd[0] = open(FIFO_PATH1, O_RDONLY);
if (filedes[0] < 0) if (fd[0] < 0)
{ {
fprintf(stderr, "pipe_main: Failed to open FIFO %s for reading, errno=%d\n", fprintf(stderr, "pipe_main: Failed to open FIFO %s for reading, errno=%d\n",
FIFO_PATH1, errno); FIFO_PATH1, errno);
if (close(filedes[1]) != 0) if (close(fd[1]) != 0)
{ {
fprintf(stderr, "pipe_main: close failed: %d\n", errno); fprintf(stderr, "pipe_main: close failed: %d\n", errno);
} }
...@@ -115,12 +115,12 @@ int pipe_main(int argc, char *argv[]) ...@@ -115,12 +115,12 @@ int pipe_main(int argc, char *argv[])
/* Then perform the test using those file descriptors */ /* Then perform the test using those file descriptors */
ret = transfer_test(filedes[0], filedes[1]); ret = transfer_test(fd[0], fd[1]);
if (close(filedes[0]) != 0) if (close(fd[0]) != 0)
{ {
fprintf(stderr, "pipe_main: close failed: %d\n", errno); 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); fprintf(stderr, "pipe_main: close failed: %d\n", errno);
} }
...@@ -136,7 +136,7 @@ int pipe_main(int argc, char *argv[]) ...@@ -136,7 +136,7 @@ int pipe_main(int argc, char *argv[])
/* Test PIPE logic */ /* Test PIPE logic */
printf("\npipe_main: Performing pipe test\n"); printf("\npipe_main: Performing pipe test\n");
ret = pipe(filedes); ret = pipe(fd);
if (ret < 0) if (ret < 0)
{ {
fprintf(stderr, "pipe_main: pipe failed with errno=%d\n", errno); fprintf(stderr, "pipe_main: pipe failed with errno=%d\n", errno);
...@@ -145,12 +145,12 @@ int pipe_main(int argc, char *argv[]) ...@@ -145,12 +145,12 @@ int pipe_main(int argc, char *argv[])
/* Then perform the test using those file descriptors */ /* Then perform the test using those file descriptors */
ret = transfer_test(filedes[0], filedes[1]); ret = transfer_test(fd[0], fd[1]);
if (close(filedes[0]) != 0) if (close(fd[0]) != 0)
{ {
fprintf(stderr, "pipe_main: close failed: %d\n", errno); 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); fprintf(stderr, "pipe_main: close failed: %d\n", errno);
} }
......
...@@ -79,7 +79,7 @@ static int redirect_reader(int argc, char *argv[]) ...@@ -79,7 +79,7 @@ static int redirect_reader(int argc, char *argv[])
int fdout; int fdout;
int ret; int ret;
int nbytes = 0; int nbytes = 0;
printf("redirect_reader: started with fdin=%s\n", argv[1]); printf("redirect_reader: started with fdin=%s\n", argv[1]);
/* Convert the fdin to binary */ /* Convert the fdin to binary */
...@@ -135,7 +135,7 @@ static int redirect_reader(int argc, char *argv[]) ...@@ -135,7 +135,7 @@ static int redirect_reader(int argc, char *argv[])
nbytes += ret; nbytes += ret;
/* Echo to stdout */ /* Echo to stdout */
ret = write(1, buffer, ret); ret = write(1, buffer, ret);
if (ret < 0) if (ret < 0)
{ {
...@@ -167,9 +167,9 @@ static int redirect_writer(int argc, char *argv[]) ...@@ -167,9 +167,9 @@ static int redirect_writer(int argc, char *argv[])
int fdout; int fdout;
int nbytes = 0; int nbytes = 0;
int ret; int ret;
fprintf(stderr, "redirect_writer: started with fdout=%s\n", argv[2]); fprintf(stderr, "redirect_writer: started with fdout=%s\n", argv[2]);
/* Convert the fdout to binary */ /* Convert the fdout to binary */
fdin = atoi(argv[1]); fdin = atoi(argv[1]);
...@@ -252,29 +252,29 @@ int redirection_test(void) ...@@ -252,29 +252,29 @@ int redirection_test(void)
char buffer2[8]; char buffer2[8];
int readerid; int readerid;
int writerid; int writerid;
int filedes[2]; int fd[2];
int ret; int ret;
sem_init(&g_rddone, 0, 0); sem_init(&g_rddone, 0, 0);
/* Create the pipe */ /* Create the pipe */
ret = pipe(filedes); ret = pipe(fd);
if (ret < 0) if (ret < 0)
{ {
fprintf(stderr, "redirection_test: pipe failed with errno=%d\n", errno); fprintf(stderr, "redirection_test: pipe failed with errno=%d\n", errno);
return 5; return 5;
} }
sprintf(buffer1, "%d", filedes[0]); sprintf(buffer1, "%d", fd[0]);
argv[0] = buffer1; argv[0] = buffer1;
sprintf(buffer2, "%d", filedes[1]); sprintf(buffer2, "%d", fd[1]);
argv[1] = buffer2; argv[1] = buffer2;
argv[2] = NULL; argv[2] = NULL;
/* Start redirect_reader thread */ /* 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); readerid = task_create("redirect_reader", 50, CONFIG_EXAMPLES_PIPE_STACKSIZE, redirect_reader, argv);
if (readerid < 0) if (readerid < 0)
{ {
...@@ -284,7 +284,7 @@ int redirection_test(void) ...@@ -284,7 +284,7 @@ int redirection_test(void)
/* Start redirect_writer task */ /* 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); writerid = task_create("redirect_writer", 50, CONFIG_EXAMPLES_PIPE_STACKSIZE, redirect_writer, argv);
if (writerid < 0) if (writerid < 0)
{ {
...@@ -299,11 +299,11 @@ int redirection_test(void) ...@@ -299,11 +299,11 @@ int redirection_test(void)
/* We should be able to close the pipe file descriptors now. */ /* 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); 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); fprintf(stderr, "pipe_main: close failed: %d\n", errno);
} }
......
...@@ -133,7 +133,7 @@ static inline int readline_rawgetc(int infd) ...@@ -133,7 +133,7 @@ static inline int readline_rawgetc(int infd)
nread = read(infd, &buffer, 1); nread = read(infd, &buffer, 1);
/* Check for end-of-file. */ /* Check for end-of-file. */
if (nread == 0) if (nread == 0)
{ {
/* Return EOF on end-of-file */ /* Return EOF on end-of-file */
...@@ -186,7 +186,7 @@ static inline void readline_consoleputc(int ch, int outfd) ...@@ -186,7 +186,7 @@ static inline void readline_consoleputc(int ch, int outfd)
nwritten = write(outfd, &buffer, 1); nwritten = write(outfd, &buffer, 1);
/* Check for irrecoverable write errors. */ /* Check for irrecoverable write errors. */
if (nwritten < 0 && errno != EINTR) if (nwritten < 0 && errno != EINTR)
{ {
break; break;
...@@ -264,8 +264,8 @@ ssize_t readline(FAR char *buf, int buflen, FILE *instream, FILE *outstream) ...@@ -264,8 +264,8 @@ ssize_t readline(FAR char *buf, int buflen, FILE *instream, FILE *outstream)
* standard) * standard)
*/ */
infd = instream->fs_filedes; infd = instream->fs_fd;
outfd = outstream->fs_filedes; outfd = outstream->fs_fd;
/* <esc>[K is the VT100 command that erases to the end of the line. */ /* <esc>[K is the VT100 command that erases to the end of the line. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment