[2/7] compel/s390: Fix return value in error path

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

Details

Message ID 20190428182255.5641-3-rikard.falkeborn@gmail.com
State Accepted
Series "Misc fixes found by cppcheck"
Commit 725bd70ec1a283090b3417988afe3cdbf117502c
Headers show

Commit Message

Rikard Falkeborn April 28, 2019, 6:22 p.m.
In a function with return type bool, returning a non-zero value is
interpreted as returning true. In the error paths we want to return
false to indicate failure. Change -1 to false to fix this.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 compel/arch/s390/src/lib/infect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/compel/arch/s390/src/lib/infect.c b/compel/arch/s390/src/lib/infect.c
index fcb463fa..00e9c36d 100644
--- a/compel/arch/s390/src/lib/infect.c
+++ b/compel/arch/s390/src/lib/infect.c
@@ -493,7 +493,7 @@  bool arch_can_dump_task(struct parasite_ctl *ctl)
 	if (psw->mask & PSW_MASK_RI) {
 		if (get_ri_cb(pid, &fpregs) < 0) {
 			pr_perror("Can't dump process with RI bit active");
-			return -1;
+			return false;
 		}
 	}
 	/* We don't support 24 and 31 bit mode - only 64 bit */

Comments

Dmitry Safonov April 29, 2019, 2:49 p.m.
On Sun, 28 Apr 2019 at 19:45, Rikard Falkeborn
<rikard.falkeborn@gmail.com> wrote:
>
> In a function with return type bool, returning a non-zero value is
> interpreted as returning true. In the error paths we want to return
> false to indicate failure. Change -1 to false to fix this.
>
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>

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

> ---
>  compel/arch/s390/src/lib/infect.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/compel/arch/s390/src/lib/infect.c b/compel/arch/s390/src/lib/infect.c
> index fcb463fa..00e9c36d 100644
> --- a/compel/arch/s390/src/lib/infect.c
> +++ b/compel/arch/s390/src/lib/infect.c
> @@ -493,7 +493,7 @@ bool arch_can_dump_task(struct parasite_ctl *ctl)
>         if (psw->mask & PSW_MASK_RI) {
>                 if (get_ri_cb(pid, &fpregs) < 0) {
>                         pr_perror("Can't dump process with RI bit active");
> -                       return -1;
> +                       return false;
>                 }
>         }
>         /* We don't support 24 and 31 bit mode - only 64 bit */
> --
> 2.21.0
>
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu