summaryrefslogtreecommitdiffstats
path: root/misc-utils
diff options
context:
space:
mode:
authorSami Kerola2019-05-01 21:04:24 +0200
committerSami Kerola2019-05-01 21:19:19 +0200
commite2aa5d82b91b7649dc8494e2cd9a4694a8a97efb (patch)
tree42bd4ff260150936f6eefacc563b9894da3916a6 /misc-utils
parenthardlink: move global variables to a control structure (diff)
downloadkernel-qcow2-util-linux-e2aa5d82b91b7649dc8494e2cd9a4694a8a97efb.tar.gz
kernel-qcow2-util-linux-e2aa5d82b91b7649dc8494e2cd9a4694a8a97efb.tar.xz
kernel-qcow2-util-linux-e2aa5d82b91b7649dc8494e2cd9a4694a8a97efb.zip
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 <kzak@redhat.com> Reference: https://github.com/karelzak/util-linux/pull/783 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'misc-utils')
-rw-r--r--misc-utils/hardlink.c10
1 files changed, 5 insertions, 5 deletions
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);