[5/7] files-reg: Remove redundant inner if

Submitted by Rikard Falkeborn on April 28, 2019, 6:22 p.m.

Details

Message ID 20190428182255.5641-6-rikard.falkeborn@gmail.com
State Accepted
Series "Misc fixes found by cppcheck"
Commit 4a4d3f72b2e7cfd6b43388506d627392afa6d245
Headers show

Commit Message

Rikard Falkeborn April 28, 2019, 6:22 p.m.
Remove a redundant if-statement, since the same condition is already
checked in the outer if-statement.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 criu/files-reg.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/files-reg.c b/criu/files-reg.c
index b30da8c9..b7e04384 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -1745,12 +1745,10 @@  ext:
 		}
 
 		if (rfi->rfe->has_mode && (st.st_mode != rfi->rfe->mode)) {
-			if (st.st_mode != rfi->rfe->mode) {
-				pr_err("File %s has bad mode 0%o (expect 0%o)\n",
-				       rfi->path, (int)st.st_mode,
-				       rfi->rfe->mode);
-				return -1;
-			}
+			pr_err("File %s has bad mode 0%o (expect 0%o)\n",
+			       rfi->path, (int)st.st_mode,
+			       rfi->rfe->mode);
+			return -1;
 		}
 
 		/*

Comments

Dmitry Safonov April 29, 2019, 2:52 p.m.
On Sun, 28 Apr 2019 at 19:45, Rikard Falkeborn
<rikard.falkeborn@gmail.com> wrote:
>
> Remove a redundant if-statement, since the same condition is already
> checked in the outer if-statement.
>
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>

Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>

> ---
>  criu/files-reg.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/criu/files-reg.c b/criu/files-reg.c
> index b30da8c9..b7e04384 100644
> --- a/criu/files-reg.c
> +++ b/criu/files-reg.c
> @@ -1745,12 +1745,10 @@ ext:
>                 }
>
>                 if (rfi->rfe->has_mode && (st.st_mode != rfi->rfe->mode)) {
> -                       if (st.st_mode != rfi->rfe->mode) {
> -                               pr_err("File %s has bad mode 0%o (expect 0%o)\n",
> -                                      rfi->path, (int)st.st_mode,
> -                                      rfi->rfe->mode);
> -                               return -1;
> -                       }
> +                       pr_err("File %s has bad mode 0%o (expect 0%o)\n",
> +                              rfi->path, (int)st.st_mode,
> +                              rfi->rfe->mode);
> +                       return -1;
>                 }
>
>                 /*
> --
> 2.21.0
>
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu