From patchwork Mon Jun 9 11:58:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Carmody X-Patchwork-Id: 4321571 Return-Path: X-Original-To: patchwork-linux-sparse@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D2B77BEEAA for ; Mon, 9 Jun 2014 12:10:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E22B220259 for ; Mon, 9 Jun 2014 12:10:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94529201FA for ; Mon, 9 Jun 2014 12:10:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933018AbaFIMKl (ORCPT ); Mon, 9 Jun 2014 08:10:41 -0400 Received: from wursti.dovecot.fi ([87.106.245.223]:41402 "EHLO wursti.dovecot.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932586AbaFIMKk (ORCPT ); Mon, 9 Jun 2014 08:10:40 -0400 Received: from phil.dovecot.net (vfw03.dovecot.fi [88.194.145.100]) by wursti.dovecot.fi (Postfix) with ESMTPSA id 8D5D921EF6; Mon, 9 Jun 2014 13:57:52 +0200 (CEST) From: Phil Carmody To: sparse@chrisli.org Cc: linux-sparse@vger.kernel.org, phil@dovecot.fi Subject: [PATCH 3/3] validation: dubious bitwise operations with nots Date: Mon, 9 Jun 2014 14:58:02 +0300 Message-Id: <1402315082-14102-4-git-send-email-phil@dovecot.fi> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1402315082-14102-3-git-send-email-phil@dovecot.fi> References: <1402315082-14102-1-git-send-email-phil@dovecot.fi> <1402315082-14102-2-git-send-email-phil@dovecot.fi> <1402315082-14102-3-git-send-email-phil@dovecot.fi> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add some bitwise not tests. Signed-off-by: Phil Carmody --- validation/dubious-bitwise-with-not.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/validation/dubious-bitwise-with-not.c b/validation/dubious-bitwise-with-not.c index c48bcae..1cfd5c5 100644 --- a/validation/dubious-bitwise-with-not.c +++ b/validation/dubious-bitwise-with-not.c @@ -10,8 +10,32 @@ static unsigned int ok5 = !1 && !2; static unsigned int bad5 = !1 & !2; static unsigned int ok6 = !1 || !2; static unsigned int bad6 = !1 | !2; +static unsigned long long ok7a = 0x100000001ull & ~1; +static unsigned long long ok7b = 0x100000001ull & ~1ull; +static unsigned long long bad7 = 0x100000001ull & ~1u; +static unsigned long long ok8a = ~1 & 0x100000001ull; +static unsigned long long ok8b = ~1ull & 0x100000001ull; +static unsigned long long bad8 = ~1u & 0x100000001ull; +static unsigned long long ok9a = 0x100000001ull | ~1; +static unsigned long long ok9b = 0x100000001ull | ~1ull; +static unsigned long long bad9 = 0x100000001ull | ~1u; +static unsigned long long ok10a = ~1 | 0x100000001ull; +static unsigned long long ok10b = ~1ull | 0x100000001ull; +static unsigned long long bad10 = ~1u | 0x100000001ull; +static unsigned long long ok11a = 0x100000001ull + ~1; +static unsigned long long ok11b = 0x100000001ull + ~1ull; +static unsigned long long bad11 = 0x100000001ull + ~1u; +static unsigned long long ok12a = ~1 + 0x100000001ull; +static unsigned long long ok12b = ~1ull + 0x100000001ull; +static unsigned long long bad12 = ~1u + 0x100000001ull; +static unsigned long long ok13a = 0x100000001ull - ~1; +static unsigned long long ok13b = 0x100000001ull - ~1ull; +static unsigned long long bad13 = 0x100000001ull - ~1u; +static unsigned long long ok14a = ~1 - 0x100000001ull; +static unsigned long long ok14b = ~1ull - 0x100000001ull; +static unsigned long long bad14 = ~1u - 0x100000001ull; /* - * check-name: Dubious bitwise operation on !x + * check-name: Dubious bitwise operations with nots * * check-error-start dubious-bitwise-with-not.c:2:31: warning: dubious: !x & y @@ -20,5 +44,13 @@ dubious-bitwise-with-not.c:6:31: warning: dubious: x & !y dubious-bitwise-with-not.c:8:31: warning: dubious: x | !y dubious-bitwise-with-not.c:10:31: warning: dubious: !x & !y dubious-bitwise-with-not.c:12:31: warning: dubious: !x | !y +dubious-bitwise-with-not.c:15:50: warning: dubious: x & ~y +dubious-bitwise-with-not.c:18:41: warning: dubious: ~x & y +dubious-bitwise-with-not.c:21:50: warning: dubious: x | ~y +dubious-bitwise-with-not.c:24:41: warning: dubious: ~x | y +dubious-bitwise-with-not.c:27:50: warning: dubious: x + ~y +dubious-bitwise-with-not.c:30:41: warning: dubious: ~x + y +dubious-bitwise-with-not.c:33:50: warning: dubious: x - ~y +dubious-bitwise-with-not.c:36:41: warning: dubious: ~x - y * check-error-end */