diff options
Diffstat (limited to 'coreutils/sum.c')
-rw-r--r-- | coreutils/sum.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/coreutils/sum.c b/coreutils/sum.c index deb068e10..ec9ed2a11 100644 --- a/coreutils/sum.c +++ b/coreutils/sum.c | |||
@@ -21,6 +21,7 @@ | |||
21 | //usage: "\n -s Use System V sum algorithm (512byte blocks)" | 21 | //usage: "\n -s Use System V sum algorithm (512byte blocks)" |
22 | 22 | ||
23 | #include "libbb.h" | 23 | #include "libbb.h" |
24 | #include "common_bufsiz.h" | ||
24 | 25 | ||
25 | enum { SUM_BSD, PRINT_NAME, SUM_SYSV }; | 26 | enum { SUM_BSD, PRINT_NAME, SUM_SYSV }; |
26 | 27 | ||
@@ -30,18 +31,20 @@ enum { SUM_BSD, PRINT_NAME, SUM_SYSV }; | |||
30 | /* Return 1 if successful. */ | 31 | /* Return 1 if successful. */ |
31 | static unsigned sum_file(const char *file, unsigned type) | 32 | static unsigned sum_file(const char *file, unsigned type) |
32 | { | 33 | { |
33 | #define buf bb_common_bufsiz1 | ||
34 | unsigned long long total_bytes = 0; | 34 | unsigned long long total_bytes = 0; |
35 | int fd, r; | 35 | int fd, r; |
36 | /* The sum of all the input bytes, modulo (UINT_MAX + 1). */ | 36 | /* The sum of all the input bytes, modulo (UINT_MAX + 1). */ |
37 | unsigned s = 0; | 37 | unsigned s = 0; |
38 | 38 | ||
39 | #define buf bb_common_bufsiz1 | ||
40 | setup_common_bufsiz(); | ||
41 | |||
39 | fd = open_or_warn_stdin(file); | 42 | fd = open_or_warn_stdin(file); |
40 | if (fd == -1) | 43 | if (fd == -1) |
41 | return 0; | 44 | return 0; |
42 | 45 | ||
43 | while (1) { | 46 | while (1) { |
44 | size_t bytes_read = safe_read(fd, buf, BUFSIZ); | 47 | size_t bytes_read = safe_read(fd, buf, COMMON_BUFSIZE); |
45 | 48 | ||
46 | if ((ssize_t)bytes_read <= 0) { | 49 | if ((ssize_t)bytes_read <= 0) { |
47 | r = (fd && close(fd) != 0); | 50 | r = (fd && close(fd) != 0); |