aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/catv.c1
-rw-r--r--coreutils/cksum.c6
-rw-r--r--coreutils/date.c6
-rw-r--r--coreutils/dd.c3
-rw-r--r--coreutils/du.c3
-rw-r--r--coreutils/expr.c3
-rw-r--r--coreutils/ls.c3
-rw-r--r--coreutils/od_bloaty.c3
-rw-r--r--coreutils/split.c1
-rw-r--r--coreutils/stat.c6
-rw-r--r--coreutils/stty.c3
-rw-r--r--coreutils/sum.c3
-rw-r--r--coreutils/tail.c3
-rw-r--r--coreutils/tee.c6
14 files changed, 34 insertions, 16 deletions
diff --git a/coreutils/catv.c b/coreutils/catv.c
index 6bb73ba63..801d2451d 100644
--- a/coreutils/catv.c
+++ b/coreutils/catv.c
@@ -19,6 +19,7 @@
//usage: "\n -v Don't use ^x or M-x escapes"
#include "libbb.h"
+#include "common_bufsiz.h"
#define CATV_OPT_e (1<<0)
#define CATV_OPT_t (1<<1)
diff --git a/coreutils/cksum.c b/coreutils/cksum.c
index ac0b0c319..d8351e7c6 100644
--- a/coreutils/cksum.c
+++ b/coreutils/cksum.c
@@ -13,6 +13,7 @@
//usage: "Calculate the CRC32 checksums of FILES"
#include "libbb.h"
+#include "common_bufsiz.h"
/* This is a NOEXEC applet. Be very careful! */
@@ -42,8 +43,9 @@ int cksum_main(int argc UNUSED_PARAM, char **argv)
crc = 0;
length = 0;
-#define read_buf bb_common_bufsiz1
- while ((bytes_read = safe_read(fd, read_buf, sizeof(read_buf))) > 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) {
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 7965775fe..59b4b8f2a 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -138,6 +138,7 @@
//usage: "Wed Apr 12 18:52:41 MDT 2000\n"
#include "libbb.h"
+#include "common_bufsiz.h"
#if ENABLE_FEATURE_DATE_NANO
# include <sys/syscall.h>
#endif
@@ -367,7 +368,8 @@ int date_main(int argc UNUSED_PARAM, char **argv)
}
#endif
-#define date_buf bb_common_bufsiz1
+#define date_buf bb_common_bufsiz1
+#define sizeof_date_buf COMMON_BUFSIZE
if (*fmt_dt2str == '\0') {
/* With no format string, just print a blank line */
date_buf[0] = '\0';
@@ -377,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, sizeof_date_buf, fmt_dt2str, &tm_time);
}
puts(date_buf);
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 0c0ea07b9..a5b8882a0 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -91,6 +91,7 @@
//usage: "4+0 records out\n"
#include "libbb.h"
+#include "common_bufsiz.h"
/* This is a NOEXEC applet. Be very careful! */
@@ -108,7 +109,7 @@ struct globals {
#endif
int flags;
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \
/* we have to zero it out because of NOEXEC */ \
memset(&G, 0, sizeof(G)); \
diff --git a/coreutils/du.c b/coreutils/du.c
index 1889c16bb..3d6777670 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -58,6 +58,7 @@
//usage: "2417 .\n"
#include "libbb.h"
+#include "common_bufsiz.h"
enum {
OPT_a_files_too = (1 << 0),
@@ -85,7 +86,7 @@ struct globals {
int du_depth;
dev_t dir_dev;
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { } while (0)
diff --git a/coreutils/expr.c b/coreutils/expr.c
index c986f9327..59a66d9c5 100644
--- a/coreutils/expr.c
+++ b/coreutils/expr.c
@@ -61,6 +61,7 @@
//usage: "of characters matched or 0."
#include "libbb.h"
+#include "common_bufsiz.h"
#include "xregex.h"
#if ENABLE_EXPR_MATH_SUPPORT_64
@@ -99,7 +100,7 @@ typedef struct valinfo VALUE;
struct globals {
char **args;
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { } while (0)
/* forward declarations */
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 20bd61860..e8c3e0490 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -93,6 +93,7 @@
//usage: )
#include "libbb.h"
+#include "common_bufsiz.h"
#include "unicode.h"
@@ -365,7 +366,7 @@ struct globals {
time_t current_time_t;
#endif
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \
/* we have to zero it out because of NOEXEC */ \
memset(&G, 0, sizeof(G)); \
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index f47f84b54..1e252caf0 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -20,6 +20,7 @@
/* #include "libbb.h" - done in od.c */
+#include "common_bufsiz.h"
#define assert(a) ((void)0)
@@ -214,7 +215,7 @@ struct globals {
#if !ENABLE_LONG_OPTS
enum { G_pseudo_offset = 0 };
#endif
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
G.bytes_per_block = 32; \
diff --git a/coreutils/split.c b/coreutils/split.c
index 1e1673efb..b2da74e27 100644
--- a/coreutils/split.c
+++ b/coreutils/split.c
@@ -22,6 +22,7 @@
//usage: "$ cat TODO | split -a 2 -l 2 TODO_\n"
#include "libbb.h"
+#include "common_bufsiz.h"
#if ENABLE_FEATURE_SPLIT_FANCY
static const struct suffix_mult split_suffixes[] = {
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 1a490fef7..78df9c948 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -103,6 +103,7 @@
//usage: )
#include "libbb.h"
+#include "common_bufsiz.h"
enum {
OPT_TERSE = (1 << 0),
@@ -157,9 +158,10 @@ 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 buf bb_common_bufsiz1
+#define sizeof_buf COMMON_BUFSIZE
- strcpy(strftime_YYYYMMDDHHMMSS(buf, sizeof(buf), &t), ".000000000");
+ strcpy(strftime_YYYYMMDDHHMMSS(buf, sizeof_buf, &t), ".000000000");
return buf;
#undef buf
}
diff --git a/coreutils/stty.c b/coreutils/stty.c
index b63b0b91a..0e32fc898 100644
--- a/coreutils/stty.c
+++ b/coreutils/stty.c
@@ -32,6 +32,7 @@
//usage: "\n [SETTING] See manpage"
#include "libbb.h"
+#include "common_bufsiz.h"
#ifndef _POSIX_VDISABLE
# define _POSIX_VDISABLE ((unsigned char) 0)
@@ -775,7 +776,7 @@ struct globals {
unsigned current_col;
char buf[10];
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \
G.device_name = bb_msg_standard_input; \
G.max_col = 80; \
diff --git a/coreutils/sum.c b/coreutils/sum.c
index deb068e10..cc6677221 100644
--- a/coreutils/sum.c
+++ b/coreutils/sum.c
@@ -21,6 +21,7 @@
//usage: "\n -s Use System V sum algorithm (512byte blocks)"
#include "libbb.h"
+#include "common_bufsiz.h"
enum { SUM_BSD, PRINT_NAME, SUM_SYSV };
@@ -41,7 +42,7 @@ static unsigned sum_file(const char *file, unsigned type)
return 0;
while (1) {
- size_t bytes_read = safe_read(fd, buf, BUFSIZ);
+ size_t bytes_read = safe_read(fd, buf, COMMON_BUFSIZE);
if ((ssize_t)bytes_read <= 0) {
r = (fd && close(fd) != 0);
diff --git a/coreutils/tail.c b/coreutils/tail.c
index e352ab627..cdc9fb66a 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -49,12 +49,13 @@
//usage: "nameserver 10.0.0.1\n"
#include "libbb.h"
+#include "common_bufsiz.h"
struct globals {
bool from_top;
bool exitcode;
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { } while (0)
static void tail_xprint_header(const char *fmt, const char *filename)
diff --git a/coreutils/tee.c b/coreutils/tee.c
index 48cc0508f..a0e177cbc 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -23,6 +23,7 @@
//usage: "Hello\n"
#include "libbb.h"
+#include "common_bufsiz.h"
int tee_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int tee_main(int argc, char **argv)
@@ -36,7 +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 buf bb_common_bufsiz1
+# define sizeof_buf COMMON_BUFSIZE
#else
int c;
#endif
@@ -79,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, sizeof_buf)) > 0) {
fp = files;
do
fwrite(buf, 1, c, *fp);