aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
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)
49 /* Read from stdin if there's nothing else to do. */ 49 /* Read from stdin if there's nothing else to do. */
50 if (!argv[0]) 50 if (!argv[0])
51 *--argv = (char*)"-"; 51 *--argv = (char*)"-";
52
53#define read_buf bb_common_bufsiz1
54 setup_common_bufsiz();
52 do { 55 do {
53 fd = open_or_warn_stdin(*argv); 56 fd = open_or_warn_stdin(*argv);
54 if (fd < 0) { 57 if (fd < 0) {
@@ -58,7 +61,6 @@ int catv_main(int argc UNUSED_PARAM, char **argv)
58 for (;;) { 61 for (;;) {
59 int i, res; 62 int i, res;
60 63
61#define read_buf bb_common_bufsiz1
62 res = read(fd, read_buf, COMMON_BUFSIZE); 64 res = read(fd, read_buf, COMMON_BUFSIZE);
63 if (res < 0) 65 if (res < 0)
64 retval = EXIT_FAILURE; 66 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)
33 argv++; 33 argv++;
34#endif 34#endif
35 35
36 setup_common_bufsiz();
36 do { 37 do {
37 int fd = open_or_warn_stdin(*argv ? *argv : bb_msg_standard_input); 38 int fd = open_or_warn_stdin(*argv ? *argv : bb_msg_standard_input);
38 39
@@ -43,9 +44,8 @@ int cksum_main(int argc UNUSED_PARAM, char **argv)
43 crc = 0; 44 crc = 0;
44 length = 0; 45 length = 0;
45 46
46#define read_buf bb_common_bufsiz1 47#define read_buf bb_common_bufsiz1
47#define sizeof_read_buf COMMON_BUFSIZE 48 while ((bytes_read = safe_read(fd, read_buf, COMMON_BUFSIZE)) > 0) {
48 while ((bytes_read = safe_read(fd, read_buf, sizeof_read_buf)) > 0) {
49 length += bytes_read; 49 length += bytes_read;
50 crc = crc32_block_endian1(crc, read_buf, bytes_read, crc32_table); 50 crc = crc32_block_endian1(crc, read_buf, bytes_read, crc32_table);
51 } 51 }
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)
368 } 368 }
369#endif 369#endif
370 370
371#define date_buf bb_common_bufsiz1 371#define date_buf bb_common_bufsiz1
372#define sizeof_date_buf COMMON_BUFSIZE 372 setup_common_bufsiz();
373 if (*fmt_dt2str == '\0') { 373 if (*fmt_dt2str == '\0') {
374 /* With no format string, just print a blank line */ 374 /* With no format string, just print a blank line */
375 date_buf[0] = '\0'; 375 date_buf[0] = '\0';
@@ -379,7 +379,7 @@ int date_main(int argc UNUSED_PARAM, char **argv)
379 fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S"; 379 fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S";
380 } 380 }
381 /* Generate output string */ 381 /* Generate output string */
382 strftime(date_buf, sizeof_date_buf, fmt_dt2str, &tm_time); 382 strftime(date_buf, COMMON_BUFSIZE, fmt_dt2str, &tm_time);
383 } 383 }
384 puts(date_buf); 384 puts(date_buf);
385 385
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)
79 ssize_t bytes_read, to_write; 79 ssize_t bytes_read, to_write;
80 char *src; 80 char *src;
81 81
82 setup_common_bufsiz();
83
82 opt_complementary = "?2:a+"; /* max 2 args; -a N */ 84 opt_complementary = "?2:a+"; /* max 2 args; -a N */
83 opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len); 85 opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len);
84 86
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)
158 /* coreutils 6.3 compat: */ 158 /* coreutils 6.3 compat: */
159 159
160 /*static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")] ALIGN1;*/ 160 /*static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")] ALIGN1;*/
161#define buf bb_common_bufsiz1 161#define buf bb_common_bufsiz1
162#define sizeof_buf COMMON_BUFSIZE 162 setup_common_bufsiz();
163 163 strcpy(strftime_YYYYMMDDHHMMSS(buf, COMMON_BUFSIZE, &t), ".000000000");
164 strcpy(strftime_YYYYMMDDHHMMSS(buf, sizeof_buf, &t), ".000000000");
165 return buf; 164 return buf;
166#undef buf 165#undef buf
167} 166}
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 };
31/* Return 1 if successful. */ 31/* Return 1 if successful. */
32static unsigned sum_file(const char *file, unsigned type) 32static unsigned sum_file(const char *file, unsigned type)
33{ 33{
34#define buf bb_common_bufsiz1
35 unsigned long long total_bytes = 0; 34 unsigned long long total_bytes = 0;
36 int fd, r; 35 int fd, r;
37 /* The sum of all the input bytes, modulo (UINT_MAX + 1). */ 36 /* The sum of all the input bytes, modulo (UINT_MAX + 1). */
38 unsigned s = 0; 37 unsigned s = 0;
39 38
39#define buf bb_common_bufsiz1
40 setup_common_bufsiz();
41
40 fd = open_or_warn_stdin(file); 42 fd = open_or_warn_stdin(file);
41 if (fd == -1) 43 if (fd == -1)
42 return 0; 44 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)
37//TODO: make unconditional 37//TODO: make unconditional
38#if ENABLE_FEATURE_TEE_USE_BLOCK_IO 38#if ENABLE_FEATURE_TEE_USE_BLOCK_IO
39 ssize_t c; 39 ssize_t c;
40# define buf bb_common_bufsiz1 40# define buf bb_common_bufsiz1
41# define sizeof_buf COMMON_BUFSIZE 41 setup_common_bufsiz();
42#else 42#else
43 int c; 43 int c;
44#endif 44#endif
@@ -81,7 +81,7 @@ int tee_main(int argc, char **argv)
81 /* names[0] will be filled later */ 81 /* names[0] will be filled later */
82 82
83#if ENABLE_FEATURE_TEE_USE_BLOCK_IO 83#if ENABLE_FEATURE_TEE_USE_BLOCK_IO
84 while ((c = safe_read(STDIN_FILENO, buf, sizeof_buf)) > 0) { 84 while ((c = safe_read(STDIN_FILENO, buf, COMMON_BUFSIZE)) > 0) {
85 fp = files; 85 fp = files;
86 do 86 do
87 fwrite(buf, 1, c, *fp); 87 fwrite(buf, 1, c, *fp);