From: Miklos Szeredi This removes check for non-null inode before calling iput(), and uses iov_length() to calculate number of bytes in iovec. Signed-off-by: Miklos Szeredi Signed-off-by: Andrew Morton --- 25-akpm/fs/fuse/dev.c | 24 +++++++----------------- 1 files changed, 7 insertions(+), 17 deletions(-) diff -puN fs/fuse/dev.c~fuse-device-functions-cleanup fs/fuse/dev.c --- 25/fs/fuse/dev.c~fuse-device-functions-cleanup Thu Mar 31 15:08:17 2005 +++ 25-akpm/fs/fuse/dev.c Thu Mar 31 15:08:17 2005 @@ -416,24 +416,15 @@ struct fuse_copy_state { unsigned len; }; -static unsigned fuse_copy_init(struct fuse_copy_state *cs, int write, - struct fuse_req *req, const struct iovec *iov, - unsigned long nr_segs) +static void fuse_copy_init(struct fuse_copy_state *cs, int write, + struct fuse_req *req, const struct iovec *iov, + unsigned long nr_segs) { - unsigned i; - unsigned nbytes; - memset(cs, 0, sizeof(*cs)); cs->write = write; cs->req = req; cs->iov = iov; cs->nr_segs = nr_segs; - - nbytes = 0; - for (i = 0; i < nr_segs; i++) - nbytes += iov[i].iov_len; - - return nbytes; } /* Unmap and put previous page of userspace buffer */ @@ -620,7 +611,6 @@ static ssize_t fuse_dev_readv(struct fil struct fuse_req *req; struct fuse_in *in; struct fuse_copy_state cs; - unsigned nbytes; unsigned reqsize; spin_lock(&fuse_lock); @@ -642,9 +632,9 @@ static ssize_t fuse_dev_readv(struct fil in = &req->in; reqsize = req->in.h.len; - nbytes = fuse_copy_init(&cs, 1, req, iov, nr_segs); + fuse_copy_init(&cs, 1, req, iov, nr_segs); err = -EINVAL; - if (nbytes >= reqsize) { + if (iov_length(iov, nr_segs) >= reqsize) { err = fuse_copy_one(&cs, &in->h, sizeof(in->h)); if (!err) err = fuse_copy_args(&cs, in->numargs, in->argpages, @@ -733,7 +723,7 @@ static ssize_t fuse_dev_writev(struct fi unsigned long nr_segs, loff_t *off) { int err; - unsigned nbytes; + unsigned nbytes = iov_length(iov, nr_segs); struct fuse_req *req; struct fuse_out_header oh; struct fuse_copy_state cs; @@ -741,7 +731,7 @@ static ssize_t fuse_dev_writev(struct fi if (!fc) return -ENODEV; - nbytes = fuse_copy_init(&cs, 0, NULL, iov, nr_segs); + fuse_copy_init(&cs, 0, NULL, iov, nr_segs); if (nbytes < sizeof(struct fuse_out_header)) return -EINVAL; _