2014-11-18 10:35:46

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 1/1] GFS2: Deletion of unnecessary checks before two function calls

From: Markus Elfring <[email protected]>
Date: Tue, 18 Nov 2014 11:31:23 +0100

The functions iput() and put_pid() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <[email protected]>
---
fs/gfs2/glock.c | 3 +--
fs/gfs2/ops_fstype.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 7f513b1..f4aa085 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -836,8 +836,7 @@ void gfs2_holder_reinit(unsigned int state, unsigned flags, struct gfs2_holder *
gh->gh_flags = flags;
gh->gh_iflags = 0;
gh->gh_ip = (unsigned long)__builtin_return_address(0);
- if (gh->gh_owner_pid)
- put_pid(gh->gh_owner_pid);
+ put_pid(gh->gh_owner_pid);
gh->gh_owner_pid = get_pid(task_pid(current));
}

diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index d3eae24..272ff81 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -918,8 +918,7 @@ fail_qc_i:
fail_ut_i:
iput(sdp->sd_sc_inode);
fail:
- if (pn)
- iput(pn);
+ iput(pn);
return error;
}

--
2.1.3


2014-11-18 11:05:50

by Steven Whitehouse

[permalink] [raw]
Subject: Re: [PATCH 1/1] GFS2: Deletion of unnecessary checks before two function calls

Hi,

Now in the GFS2 -nmw git tree. Thanks,

Steve.

On 18/11/14 10:35, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Tue, 18 Nov 2014 11:31:23 +0100
>
> The functions iput() and put_pid() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <[email protected]>
> ---
> fs/gfs2/glock.c | 3 +--
> fs/gfs2/ops_fstype.c | 3 +--
> 2 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
> index 7f513b1..f4aa085 100644
> --- a/fs/gfs2/glock.c
> +++ b/fs/gfs2/glock.c
> @@ -836,8 +836,7 @@ void gfs2_holder_reinit(unsigned int state, unsigned flags, struct gfs2_holder *
> gh->gh_flags = flags;
> gh->gh_iflags = 0;
> gh->gh_ip = (unsigned long)__builtin_return_address(0);
> - if (gh->gh_owner_pid)
> - put_pid(gh->gh_owner_pid);
> + put_pid(gh->gh_owner_pid);
> gh->gh_owner_pid = get_pid(task_pid(current));
> }
>
> diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
> index d3eae24..272ff81 100644
> --- a/fs/gfs2/ops_fstype.c
> +++ b/fs/gfs2/ops_fstype.c
> @@ -918,8 +918,7 @@ fail_qc_i:
> fail_ut_i:
> iput(sdp->sd_sc_inode);
> fail:
> - if (pn)
> - iput(pn);
> + iput(pn);
> return error;
> }
>

2015-11-04 20:27:26

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH] GFS2: Delete an unnecessary check before the function call "iput"

From: Markus Elfring <[email protected]>
Date: Wed, 4 Nov 2015 21:23:43 +0100

The iput() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <[email protected]>
---
fs/gfs2/ops_fstype.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index baab99b..1f9de17 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -910,8 +910,7 @@ fail_qc_i:
fail_ut_i:
iput(sdp->sd_sc_inode);
fail:
- if (pn)
- iput(pn);
+ iput(pn);
return error;
}

--
2.6.2

2015-11-13 14:07:00

by Bob Peterson

[permalink] [raw]
Subject: Re: [PATCH] GFS2: Delete an unnecessary check before the function call "iput"

----- Original Message -----
> From: Markus Elfring <[email protected]>
> Date: Wed, 4 Nov 2015 21:23:43 +0100
>
> The iput() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <[email protected]>
> ---
> fs/gfs2/ops_fstype.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
> index baab99b..1f9de17 100644
> --- a/fs/gfs2/ops_fstype.c
> +++ b/fs/gfs2/ops_fstype.c
> @@ -910,8 +910,7 @@ fail_qc_i:
> fail_ut_i:
> iput(sdp->sd_sc_inode);
> fail:
> - if (pn)
> - iput(pn);
> + iput(pn);
> return error;
> }
>
> --
> 2.6.2
>
>
Hi Markus,

ACK,

I'll save this patch and push it after the current merge window closed.

Regards,

Bob Peterson
Red Hat File Systems

2015-11-16 18:12:10

by Bob Peterson

[permalink] [raw]
Subject: Re: [PATCH] GFS2: Delete an unnecessary check before the function call "iput"

----- Original Message -----
> From: Markus Elfring <[email protected]>
> Date: Wed, 4 Nov 2015 21:23:43 +0100
>
> The iput() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <[email protected]>
> ---
> fs/gfs2/ops_fstype.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
> index baab99b..1f9de17 100644
> --- a/fs/gfs2/ops_fstype.c
> +++ b/fs/gfs2/ops_fstype.c
> @@ -910,8 +910,7 @@ fail_qc_i:
> fail_ut_i:
> iput(sdp->sd_sc_inode);
> fail:
> - if (pn)
> - iput(pn);
> + iput(pn);
> return error;
> }
>
> --
> 2.6.2
>
> --
Hi,

Thanks. This is now applied to the for-next branch of the linux-gfs2 tree:
https://git.kernel.org/cgit/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next&id=6fde22426be6af261816db5941744b8d3c4c7f96

Regards,

Bob Peterson
Red Hat File Systems