From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757371AbcFAGDs (ORCPT ); Wed, 1 Jun 2016 02:03:48 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:47459 "EHLO e34.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751197AbcFAGDq (ORCPT ); Wed, 1 Jun 2016 02:03:46 -0400 X-IBM-Helo: d03dlp01.boulder.ibm.com X-IBM-MailFrom: rui.teng@linux.vnet.ibm.com X-IBM-RcptTo: serge.hallyn@canonical.com;serge@hallyn.com;james.l.morris@oracle.com;linux-kernel@vger.kernel.org;linux-security-module@vger.kernel.org From: Rui Teng To: serge.hallyn@canonical.com, james.l.morris@oracle.com, serge@hallyn.com Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Rui Teng Subject: [PATCH] security: Use || instead of | for boolean expressions Date: Wed, 1 Jun 2016 14:03:02 +0800 Message-Id: <1464760982-3721-1-git-send-email-rui.teng@linux.vnet.ibm.com> X-Mailer: git-send-email 2.7.4 (Apple Git-66) X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16060106-0017-0000-0000-00002FBA7C65 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sparse spits out the following warning: security/commoncap.c:989:41: warning: dubious: !x | y Bitwise and logical are equivalent here, but logical was intended. Replacing the bit-wise '|' with the boolean '||' silences the sparse warning. The generated code for both cases is the same. Signed-off-by: Rui Teng --- security/commoncap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/commoncap.c b/security/commoncap.c index e7fadde..8f6fb24 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -976,7 +976,7 @@ int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3, case PR_CAP_AMBIENT: if (arg2 == PR_CAP_AMBIENT_CLEAR_ALL) { - if (arg3 | arg4 | arg5) + if (arg3 || arg4 || arg5) return -EINVAL; new = prepare_creds(); @@ -986,7 +986,7 @@ int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3, return commit_creds(new); } - if (((!cap_valid(arg3)) | arg4 | arg5)) + if (((!cap_valid(arg3)) || arg4 || arg5)) return -EINVAL; if (arg2 == PR_CAP_AMBIENT_IS_SET) { -- 2.7.4