diff --git a/lib/fuse_i.h b/lib/fuse_i.h index 2815a8a..f7924eb 100644 --- a/lib/fuse_i.h +++ b/lib/fuse_i.h @@ -9,6 +9,13 @@ #include "fuse.h" #include "fuse_lowlevel.h" +#define MIN(a, b) \ +({ \ + typeof(a) _a = (a); \ + typeof(b) _b = (b); \ + _a < _b ? _a : _b; \ +}) + struct mount_opts; struct fuse_req { diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 84185d5..a505552 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -2146,11 +2146,8 @@ void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) bufsize = FUSE_MIN_READ_BUFFER; } - if (se->conn.max_write > bufsize - FUSE_BUFFER_HEADER_SIZE) - se->conn.max_write = bufsize - FUSE_BUFFER_HEADER_SIZE; - if (se->conn.max_write < bufsize - FUSE_BUFFER_HEADER_SIZE) - bufsize = se->conn.max_write + FUSE_BUFFER_HEADER_SIZE; - se->bufsize = bufsize; + se->conn.max_write = MIN(se->conn.max_write, bufsize - FUSE_BUFFER_HEADER_SIZE); + se->bufsize = se->conn.max_write + FUSE_BUFFER_HEADER_SIZE; if (arg->flags & FUSE_MAX_PAGES) { outarg.flags |= FUSE_MAX_PAGES;