summaryrefslogtreecommitdiffstats
path: root/commands/echo.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-04-14 09:37:28 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-04-15 12:21:46 +0200
commit5559bfd2719f0b0795a6ce66b859d879271bb1e4 (patch)
treeea8c3d5779197b753e68d271b45e660d5eb50931 /commands/echo.c
parent473d6f8a7a16d1440f360b8562b746fbadee2d82 (diff)
downloadbarebox-5559bfd2719f0b0795a6ce66b859d879271bb1e4.tar.gz
barebox-5559bfd2719f0b0795a6ce66b859d879271bb1e4.tar.xz
stdio: Replace FILE functions with filedescriptor functions
We have defined stdin, stdout and stderr as integer file descriptors, but normally they should be FILE *. Also fprintf, fputc and fputs take file descriptors instead of FILE *. As FILE * are inconvenient in the barebox environment replace the f* functions with the corresponding d* functions. dprintf is POSIX conform whereas dputc and dputs are barebox specific, but do not conflict with any stdc function. fgetc is unused and can be removed without replacing it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/echo.c')
-rw-r--r--commands/echo.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/commands/echo.c b/commands/echo.c
index 7d47ab7ca7..8853ee0a30 100644
--- a/commands/echo.c
+++ b/commands/echo.c
@@ -27,7 +27,7 @@
static int do_echo(int argc, char *argv[])
{
int i, optind = 1;
- int fd = stdout, opt, newline = 1;
+ int fd = STDOUT_FILENO, opt, newline = 1;
char *file = NULL;
int oflags = O_WRONLY | O_CREAT;
char str[CONFIG_CBSIZE];
@@ -81,17 +81,17 @@ exit_parse:
for (i = optind; i < argc; i++) {
if (i > optind)
- fputc(fd, ' ');
+ dputc(fd, ' ');
if (process_escape) {
process_escape_sequence(argv[i], str, CONFIG_CBSIZE);
- fputs(fd, str);
+ dputs(fd, str);
} else {
- fputs(fd, argv[i]);
+ dputs(fd, argv[i]);
}
}
if (newline)
- fputc(fd, '\n');
+ dputc(fd, '\n');
if (file)
close(fd);