Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nuttx-apps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
nuttx-apps
Commits
59a89b68
Commit
59a89b68
authored
11 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
Clean up some naming: fd vs. fildes vs. filedes and filep vs filp
parent
5f16a8c3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/pipe/pipe_main.c
+14
-14
14 additions, 14 deletions
examples/pipe/pipe_main.c
examples/pipe/redirect_test.c
+13
-13
13 additions, 13 deletions
examples/pipe/redirect_test.c
system/readline/readline.c
+4
-4
4 additions, 4 deletions
system/readline/readline.c
with
31 additions
and
31 deletions
examples/pipe/pipe_main.c
+
14
−
14
View file @
59a89b68
/****************************************************************************
/****************************************************************************
* 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
f
iledes
[
2
];
int
f
d
[
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()).
*/
*/
f
iledes
[
1
]
=
open
(
FIFO_PATH1
,
O_WRONLY
);
f
d
[
1
]
=
open
(
FIFO_PATH1
,
O_WRONLY
);
if
(
f
iledes
[
1
]
<
0
)
if
(
f
d
[
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
;
}
}
f
iledes
[
0
]
=
open
(
FIFO_PATH1
,
O_RDONLY
);
f
d
[
0
]
=
open
(
FIFO_PATH1
,
O_RDONLY
);
if
(
f
iledes
[
0
]
<
0
)
if
(
f
d
[
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
(
f
iledes
[
1
])
!=
0
)
if
(
close
(
f
d
[
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
(
f
iledes
[
0
],
filedes
[
1
]);
ret
=
transfer_test
(
f
d
[
0
],
fd
[
1
]);
if
(
close
(
f
iledes
[
0
])
!=
0
)
if
(
close
(
f
d
[
0
])
!=
0
)
{
{
fprintf
(
stderr
,
"pipe_main: close failed: %d
\n
"
,
errno
);
fprintf
(
stderr
,
"pipe_main: close failed: %d
\n
"
,
errno
);
}
}
if
(
close
(
f
iledes
[
1
])
!=
0
)
if
(
close
(
f
d
[
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
(
"
\n
pipe_main: Performing pipe test
\n
"
);
printf
(
"
\n
pipe_main: Performing pipe test
\n
"
);
ret
=
pipe
(
f
iledes
);
ret
=
pipe
(
f
d
);
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
(
f
iledes
[
0
],
filedes
[
1
]);
ret
=
transfer_test
(
f
d
[
0
],
fd
[
1
]);
if
(
close
(
f
iledes
[
0
])
!=
0
)
if
(
close
(
f
d
[
0
])
!=
0
)
{
{
fprintf
(
stderr
,
"pipe_main: close failed: %d
\n
"
,
errno
);
fprintf
(
stderr
,
"pipe_main: close failed: %d
\n
"
,
errno
);
}
}
if
(
close
(
f
iledes
[
1
])
!=
0
)
if
(
close
(
f
d
[
1
])
!=
0
)
{
{
fprintf
(
stderr
,
"pipe_main: close failed: %d
\n
"
,
errno
);
fprintf
(
stderr
,
"pipe_main: close failed: %d
\n
"
,
errno
);
}
}
...
...
This diff is collapsed.
Click to expand it.
examples/pipe/redirect_test.c
+
13
−
13
View file @
59a89b68
...
@@ -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
f
iledes
[
2
];
int
f
d
[
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
(
f
iledes
);
ret
=
pipe
(
f
d
);
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"
,
f
iledes
[
0
]);
sprintf
(
buffer1
,
"%d"
,
f
d
[
0
]);
argv
[
0
]
=
buffer1
;
argv
[
0
]
=
buffer1
;
sprintf
(
buffer2
,
"%d"
,
f
iledes
[
1
]);
sprintf
(
buffer2
,
"%d"
,
f
d
[
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
"
,
f
iledes
[
0
]);
printf
(
"redirection_test: Starting redirect_reader task with fd=%d
\n
"
,
f
d
[
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
"
,
f
iledes
[
1
]);
printf
(
"redirection_test: Starting redirect_writer task with fd=%d
\n
"
,
f
d
[
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
(
f
iledes
[
0
])
!=
0
)
if
(
close
(
f
d
[
0
])
!=
0
)
{
{
fprintf
(
stderr
,
"pipe_main: close failed: %d
\n
"
,
errno
);
fprintf
(
stderr
,
"pipe_main: close failed: %d
\n
"
,
errno
);
}
}
if
(
close
(
f
iledes
[
1
])
!=
0
)
if
(
close
(
f
d
[
1
])
!=
0
)
{
{
fprintf
(
stderr
,
"pipe_main: close failed: %d
\n
"
,
errno
);
fprintf
(
stderr
,
"pipe_main: close failed: %d
\n
"
,
errno
);
}
}
...
...
This diff is collapsed.
Click to expand it.
system/readline/readline.c
+
4
−
4
View file @
59a89b68
...
@@ -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_f
iledes
;
infd
=
instream
->
fs_f
d
;
outfd
=
outstream
->
fs_f
iledes
;
outfd
=
outstream
->
fs_f
d
;
/* <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. */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment