9
0
Fork 0

[cat] use define for buffer size not hardcoded value

With this patch a define is used for the buffer size not a hardcoded value
in two places in the node.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
Marc Kleine-Budde 2007-11-16 16:23:32 +01:00
parent 7a8a0b323e
commit 7b2a8252bd
1 changed files with 4 additions and 2 deletions

View File

@ -32,6 +32,8 @@
#include <xfuncs.h>
#include <malloc.h>
#define BUFSIZE 1024
/**
* @param[in] cmdtp FIXME
* @param[in] argc Argument count from command line
@ -50,7 +52,7 @@ static int do_cat(cmd_tbl_t *cmdtp, int argc, char *argv[])
return 1;
}
buf = xmalloc(1024);
buf = xmalloc(BUFSIZE);
while (args < argc) {
fd = open(argv[args], O_RDONLY);
@ -59,7 +61,7 @@ static int do_cat(cmd_tbl_t *cmdtp, int argc, char *argv[])
goto out;
}
while((ret = read(fd, buf, 1024)) > 0) {
while((ret = read(fd, buf, BUFSIZE)) > 0) {
for(i = 0; i < ret; i++) {
if (isprint(buf[i]) || buf[i] == '\n' || buf[i] == '\t')
putchar(buf[i]);