[PATCH] FUSE: trivial cleanups

From: Miklos Szeredi
Date: Thu Mar 24 2005 - 13:14:03 EST


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 <miklos@xxxxxxxxxx>

dev.c | 30 +++++++++---------------------
1 files changed, 9 insertions(+), 21 deletions(-)

diff -ru linux-2.6.12-rc1-mm2/fs/fuse/dev.c linux-fuse/fs/fuse/dev.c
--- linux-2.6.12-rc1-mm2/fs/fuse/dev.c 2005-03-24 18:46:37.000000000 +0100
+++ linux-fuse/fs/fuse/dev.c 2005-03-24 18:49:04.000000000 +0100
@@ -142,10 +142,8 @@

void fuse_release_background(struct fuse_req *req)
{
- if (req->inode)
- iput(req->inode);
- if (req->inode2)
- iput(req->inode2);
+ iput(req->inode);
+ iput(req->inode2);
if (req->file)
fput(req->file);
spin_lock(&fuse_lock);
@@ -397,24 +395,15 @@
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;
}

static inline void fuse_copy_finish(struct fuse_copy_state *cs)
@@ -578,7 +567,6 @@
struct fuse_req *req;
struct fuse_in *in;
struct fuse_copy_state cs;
- unsigned nbytes;
unsigned reqsize;

spin_lock(&fuse_lock);
@@ -600,9 +588,9 @@

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,
@@ -683,7 +671,7 @@
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;
@@ -691,7 +679,7 @@
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;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/