summaryrefslogtreecommitdiffstats
path: root/common
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 /common
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 'common')
-rw-r--r--common/console.c10
-rw-r--r--common/console_common.c18
-rw-r--r--common/globalvar.c2
3 files changed, 10 insertions, 20 deletions
diff --git a/common/console.c b/common/console.c
index 37574b9b01..a67f169b42 100644
--- a/common/console.c
+++ b/common/console.c
@@ -382,16 +382,6 @@ int getchar(void)
}
EXPORT_SYMBOL(getchar);
-int fgetc(int fd)
-{
- char c;
-
- if (!fd)
- return getchar();
- return read(fd, &c, 1);
-}
-EXPORT_SYMBOL(fgetc);
-
int tstc(void)
{
return kfifo_len(console_input_fifo) || tstc_raw();
diff --git a/common/console_common.c b/common/console_common.c
index a9bbce9a28..2e5869fab0 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -278,7 +278,7 @@ EXPORT_SYMBOL(console_get_first_active);
#endif /* !CONFIG_CONSOLE_NONE */
-int fprintf(int file, const char *fmt, ...)
+int dprintf(int file, const char *fmt, ...)
{
va_list args;
char printbuffer[CFG_PBSIZE];
@@ -293,30 +293,30 @@ int fprintf(int file, const char *fmt, ...)
va_end(args);
/* Print the string */
- return fputs(file, printbuffer);
+ return dputs(file, printbuffer);
}
-EXPORT_SYMBOL(fprintf);
+EXPORT_SYMBOL(dprintf);
-int fputs(int fd, const char *s)
+int dputs(int fd, const char *s)
{
if (fd == 1)
return puts(s);
else if (fd == 2)
- return eputs(s);
+ return console_puts(CONSOLE_STDERR, s);
else
return write(fd, s, strlen(s));
}
-EXPORT_SYMBOL(fputs);
+EXPORT_SYMBOL(dputs);
-int fputc(int fd, char c)
+int dputc(int fd, char c)
{
if (fd == 1)
putchar(c);
else if (fd == 2)
- eputc(c);
+ console_putc(CONSOLE_STDERR, c);
else
return write(fd, &c, 1);
return 0;
}
-EXPORT_SYMBOL(fputc);
+EXPORT_SYMBOL(dputc);
diff --git a/common/globalvar.c b/common/globalvar.c
index d5dd461963..bc1734d58d 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -51,7 +51,7 @@ static int nv_save(const char *name, const char *val)
if (fd < 0)
return fd;
- fprintf(fd, "%s", val);
+ dprintf(fd, "%s", val);
close(fd);