From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752963AbcKIIzO (ORCPT ); Wed, 9 Nov 2016 03:55:14 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:41646 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751332AbcKIIzN (ORCPT ); Wed, 9 Nov 2016 03:55:13 -0500 From: Andrew Shadura To: linuxppc-dev@lists.ozlabs.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Shuah Khan , Cyril Bur Subject: [PATCH RESEND] tools-powerpc: Return false instead of -1 Date: Wed, 9 Nov 2016 09:55:04 +0100 Message-Id: <20161109085504.10799-1-andrew.shadura@collabora.co.uk> X-Mailer: git-send-email 2.9.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Senna Tschudin Returning a negative value for a boolean function seem to have the undesired effect of returning true. require_paranoia_below() is a boolean function, but the variable used to store the return value is an integer, receiving -1 or 0. This patch convert rc to bool, replace -1 by false, and 0 by true. This issue was found by the following Coccinelle semantic patch: @@ identifier f, ret; constant C; typedef bool; @@ bool f (...){ <+... ret = -C; ... * return ret; ...+> } Signed-off-by: Peter Senna Tschudin Signed-off-by: Andrew Shadura --- tools/testing/selftests/powerpc/pmu/lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/powerpc/pmu/lib.c b/tools/testing/selftests/powerpc/pmu/lib.c index 8b992fa..5bf5dd4 100644 --- a/tools/testing/selftests/powerpc/pmu/lib.c +++ b/tools/testing/selftests/powerpc/pmu/lib.c @@ -193,9 +193,9 @@ bool require_paranoia_below(int level) long current; char *end, buf[16]; FILE *f; - int rc; + bool rc; - rc = -1; + rc = false; f = fopen(PARANOID_PATH, "r"); if (!f) { @@ -218,7 +218,7 @@ bool require_paranoia_below(int level) if (current >= level) goto out_close; - rc = 0; + rc = true; out_close: fclose(f); out: -- 2.9.3