aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-04-21 18:38:51 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-04-21 18:38:51 +0200
commit9de2e5a22213842da5b116723392de88de9ed419 (patch)
treedff999a566382174e084d377dc3b4c03de1d4c62 /coreutils
parent47cfbf32fd66563f8c4e09ad6cced6abfbe2fad5 (diff)
downloadbusybox-9de2e5a22213842da5b116723392de88de9ed419.tar.gz
*: hopefully all setup_common_bufsiz() are in place
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/catv.c4
-rw-r--r--coreutils/cksum.c6
-rw-r--r--coreutils/date.c6
-rw-r--r--coreutils/split.c2
-rw-r--r--coreutils/stat.c7
-rw-r--r--coreutils/sum.c4
-rw-r--r--coreutils/tee.c6
7 files changed, 20 insertions, 15 deletions
diff --git a/coreutils/catv.c b/coreutils/catv.c
index 801d2451d..0e71368a5 100644
--- a/coreutils/catv.c
+++ b/coreutils/catv.c
@@ -49,6 +49,9 @@ int catv_main(int argc UNUSED_PARAM, char **argv)
/* Read from stdin if there's nothing else to do. */
if (!argv[0])
*--argv = (char*)"-";
+
+#define read_buf bb_common_bufsiz1
+ setup_common_bufsiz();
do {
fd = open_or_warn_stdin(*argv);
if (fd < 0) {
@@ -58,7 +61,6 @@ int catv_main(int argc UNUSED_PARAM, char **argv)
for (;;) {
int i, res;
-#define read_buf bb_common_bufsiz1
res = read(fd, read_buf, COMMON_BUFSIZE);
if (res < 0)
retval = EXIT_FAILURE;
diff --git a/coreutils/cksum.c b/coreutils/cksum.c
index d8351e7c6..8a8a39f68 100644
--- a/coreutils/cksum.c
+++ b/coreutils/cksum.c
@@ -33,6 +33,7 @@ int cksum_main(int argc UNUSED_PARAM, char **argv)
argv++;
#endif
+ setup_common_bufsiz();
do {
int fd = open_or_warn_stdin(*argv ? *argv : bb_msg_standard_input);
@@ -43,9 +44,8 @@ int cksum_main(int argc UNUSED_PARAM, char **argv)
crc = 0;
length = 0;
-#define read_buf bb_common_bufsiz1
-#define sizeof_read_buf COMMON_BUFSIZE
- while ((bytes_read = safe_read(fd, read_buf, sizeof_read_buf)) > 0) {
+#define read_buf bb_common_bufsiz1
+ while ((bytes_read = safe_read(fd, read_buf, COMMON_BUFSIZE)) > 0) {
length += bytes_read;
crc = crc32_block_endian1(crc, read_buf, bytes_read, crc32_table);
}
diff --git a/coreutils/date.c b/coreutils/date.c
index 59b4b8f2a..ff3214d85 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -368,8 +368,8 @@ int date_main(int argc UNUSED_PARAM, char **argv)
}
#endif
-#define date_buf bb_common_bufsiz1
-#define sizeof_date_buf COMMON_BUFSIZE
+#define date_buf bb_common_bufsiz1
+ setup_common_bufsiz();
if (*fmt_dt2str == '\0') {
/* With no format string, just print a blank line */
date_buf[0] = '\0';
@@ -379,7 +379,7 @@ int date_main(int argc UNUSED_PARAM, char **argv)
fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S";
}
/* Generate output string */
- strftime(date_buf, sizeof_date_buf, fmt_dt2str, &tm_time);
+ strftime(date_buf, COMMON_BUFSIZE, fmt_dt2str, &tm_time);
}
puts(date_buf);
diff --git a/coreutils/split.c b/coreutils/split.c
index b2da74e27..e67c3de66 100644
--- a/coreutils/split.c
+++ b/coreutils/split.c
@@ -79,6 +79,8 @@ int split_main(int argc UNUSED_PARAM, char **argv)
ssize_t bytes_read, to_write;
char *src;
+ setup_common_bufsiz();
+
opt_complementary = "?2:a+"; /* max 2 args; -a N */
opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len);
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 78df9c948..ddcfcf2d7 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -158,10 +158,9 @@ static const char *human_time(time_t t)
/* coreutils 6.3 compat: */
/*static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")] ALIGN1;*/
-#define buf bb_common_bufsiz1
-#define sizeof_buf COMMON_BUFSIZE
-
- strcpy(strftime_YYYYMMDDHHMMSS(buf, sizeof_buf, &t), ".000000000");
+#define buf bb_common_bufsiz1
+ setup_common_bufsiz();
+ strcpy(strftime_YYYYMMDDHHMMSS(buf, COMMON_BUFSIZE, &t), ".000000000");
return buf;
#undef buf
}
diff --git a/coreutils/sum.c b/coreutils/sum.c
index cc6677221..ec9ed2a11 100644
--- a/coreutils/sum.c
+++ b/coreutils/sum.c
@@ -31,12 +31,14 @@ enum { SUM_BSD, PRINT_NAME, SUM_SYSV };
/* Return 1 if successful. */
static unsigned sum_file(const char *file, unsigned type)
{
-#define buf bb_common_bufsiz1
unsigned long long total_bytes = 0;
int fd, r;
/* The sum of all the input bytes, modulo (UINT_MAX + 1). */
unsigned s = 0;
+#define buf bb_common_bufsiz1
+ setup_common_bufsiz();
+
fd = open_or_warn_stdin(file);
if (fd == -1)
return 0;
diff --git a/coreutils/tee.c b/coreutils/tee.c
index a0e177cbc..a68e9446f 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -37,8 +37,8 @@ int tee_main(int argc, char **argv)
//TODO: make unconditional
#if ENABLE_FEATURE_TEE_USE_BLOCK_IO
ssize_t c;
-# define buf bb_common_bufsiz1
-# define sizeof_buf COMMON_BUFSIZE
+# define buf bb_common_bufsiz1
+ setup_common_bufsiz();
#else
int c;
#endif
@@ -81,7 +81,7 @@ int tee_main(int argc, char **argv)
/* names[0] will be filled later */
#if ENABLE_FEATURE_TEE_USE_BLOCK_IO
- while ((c = safe_read(STDIN_FILENO, buf, sizeof_buf)) > 0) {
+ while ((c = safe_read(STDIN_FILENO, buf, COMMON_BUFSIZE)) > 0) {
fp = files;
do
fwrite(buf, 1, c, *fp);