From e2aa5d82b91b7649dc8494e2cd9a4694a8a97efb Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Wed, 1 May 2019 20:04:24 +0100 Subject: hardlink: retire NIOBUF in favour of more common BUFSIZ Reason to retire NIOBUF is that it is obscure local definition, while BUFSIZ is well understood and commonly used constant. Besized sizes of these are not far off, the NIOBUF was 4096 bytes and BUFSIZ tends to be 8192 bytes. Proposed-by: Karel Zak Reference: https://github.com/karelzak/util-linux/pull/783 Signed-off-by: Sami Kerola --- misc-utils/hardlink.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'misc-utils') diff --git a/misc-utils/hardlink.c b/misc-utils/hardlink.c index 6a0d0c361..3354273cb 100644 --- a/misc-utils/hardlink.c +++ b/misc-utils/hardlink.c @@ -42,7 +42,6 @@ #include "closestream.h" #define NHASH (1<<17) /* Must be a power of 2! */ -#define NIOBUF (1<<12) #define NBUF 64 struct hardlink_file; @@ -75,8 +74,8 @@ struct hardlink_dynstr { struct hardlink_ctl { struct hardlink_dir *dirs; struct hardlink_hash *hps[NHASH]; - char iobuf1[NIOBUF]; - char iobuf2[NIOBUF]; + char iobuf1[BUFSIZ]; + char iobuf2[BUFSIZ]; /* summary counters */ unsigned long long ndirs; unsigned long long nobjects; @@ -282,9 +281,10 @@ static void process_path(struct hardlink_ctl *ctl, const char *name) lseek(fd, 0, SEEK_SET); for (fsize = st.st_size; fsize > 0; - fsize -= NIOBUF) { + fsize -= (off_t)sizeof(ctl->iobuf1)) { ssize_t xsz; - off_t rsize = fsize >= NIOBUF ? NIOBUF : fsize; + ssize_t rsize = fsize > (ssize_t)sizeof(ctl->iobuf1) ? + sizeof(ctl->iobuf1) : fsize; if ((xsz = read(fd, ctl->iobuf1, rsize)) != rsize) warn(_("cannot read %s"), name); -- cgit v1.2.3-55-g7522