summaryrefslogtreecommitdiffstats
path: root/commands/cat.c
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2007-11-16 16:23:32 +0100
committerMarc Kleine-Budde <mkl@pengutronix.de>2007-11-28 08:27:38 +0100
commit7b2a8252bd5401c3e02c290b7c54217a8780f48a (patch)
treea45c7fcdbe6bd0fbef42f2fc0aa2047054039118 /commands/cat.c
parent7a8a0b323ea6d50862291169ce4cc6e801cba32a (diff)
downloadbarebox-7b2a8252bd5401c3e02c290b7c54217a8780f48a.tar.gz
barebox-7b2a8252bd5401c3e02c290b7c54217a8780f48a.tar.xz
[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>
Diffstat (limited to 'commands/cat.c')
-rw-r--r--commands/cat.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/commands/cat.c b/commands/cat.c
index 6596612e95..0840fdfeae 100644
--- a/commands/cat.c
+++ b/commands/cat.c
@@ -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]);