From patchwork Sat Aug 21 09:42:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 62344 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 35F7EB70DA for ; Sat, 21 Aug 2010 19:44:33 +1000 (EST) Received: from localhost ([127.0.0.1]:48782 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Omkco-0005Q8-7V for incoming@patchwork.ozlabs.org; Sat, 21 Aug 2010 05:44:30 -0400 Received: from [140.186.70.92] (port=45771 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OmkbZ-0005P1-CP for qemu-devel@nongnu.org; Sat, 21 Aug 2010 05:43:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OmkbY-0001ZQ-18 for qemu-devel@nongnu.org; Sat, 21 Aug 2010 05:43:13 -0400 Received: from mail-qy0-f173.google.com ([209.85.216.173]:57589) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OmkbX-0001ZB-VG for qemu-devel@nongnu.org; Sat, 21 Aug 2010 05:43:11 -0400 Received: by qyk5 with SMTP id 5so1400800qyk.4 for ; Sat, 21 Aug 2010 02:43:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:from:date :message-id:subject:to:content-type; bh=Sjt5Lo4UrJfcfAtIhr++ovMP0amB+f32RAP2lHIPUBo=; b=M/n2S7yhKRmeZSKxPILZFsYWla2u8CBc8O/PC62+Fx4xMzfq+5y3fkDsEz2KHjiwgi mejM2SETnqKlBHK6gd1m9Nukd4+jt7Sm02MIHwm4LjfYrF51tb7Ulc4I/L0IA4KOyTha zM1K3HKIVvB7gHvyjHPjYurZhFaqnuUduyHzc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=nHHmXtZdqmJMIIglQ0DP0iiWb+z7xI39piKs4h9UjbrX5GppzkZriDJvdH8CHKVmF/ lHErADToptgM2W8p2LtsPZvPFE/XMNBrdIRF5ozEf0H8mdnnH5B5WpaxEF/OFm/wSg1A O46NO2MmY3FDw8YtX/eDbiblca30IbNjc/ZP8= Received: by 10.224.43.232 with SMTP id x40mr1761900qae.73.1282383791221; Sat, 21 Aug 2010 02:43:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.183.135 with HTTP; Sat, 21 Aug 2010 02:42:51 -0700 (PDT) From: Blue Swirl Date: Sat, 21 Aug 2010 09:42:51 +0000 Message-ID: To: qemu-devel X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH] Correct use of ! and & X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Combining bitwise AND and logical NOT is suspicious. Fixed by this Coccinelle script: // From http://article.gmane.org/gmane.linux.kernel/646367 @@ expression E1,E2; @@ ( !E1 & !E2 | - !E1 & E2 + !(E1 & E2) ) Signed-off-by: Blue Swirl Acked-by: Edgar E. Iglesias --- Maybe the middle hunk should be fixed this way instead: - } else if ((rw == 1) & !matching->d) { + } else if ((rw == 1) && !matching->d) { --- hw/etraxfs_eth.c | 2 +- target-sh4/helper.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) *prot = PAGE_READ; @@ -407,7 +407,7 @@ static int get_physical_address(CPUState * env, target_ulong * physical, } /* If MMU is disabled, return the corresponding physical page */ - if (!env->mmucr & MMUCR_AT) { + if (!(env->mmucr & MMUCR_AT)) { *physical = address & 0x1FFFFFFF; *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; return MMU_OK; diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c index b897c9c..ade96f1 100644 --- a/hw/etraxfs_eth.c +++ b/hw/etraxfs_eth.c @@ -464,7 +464,7 @@ static int eth_match_groupaddr(struct fs_eth *eth, const unsigned char *sa) /* First bit on the wire of a MAC address signals multicast or physical address. */ - if (!m_individual && !sa[0] & 1) + if (!m_individual && !(sa[0] & 1)) return 0; /* Calculate the hash index for the GA registers. */ diff --git a/target-sh4/helper.c b/target-sh4/helper.c index 9e70352..e457904 100644 --- a/target-sh4/helper.c +++ b/target-sh4/helper.c @@ -357,7 +357,7 @@ static int get_mmu_address(CPUState * env, target_ulong * physical, MMU_DTLB_VIOLATION_READ; } else if ((rw == 1) && !(matching->pr & 1)) { n = MMU_DTLB_VIOLATION_WRITE; - } else if ((rw == 1) & !matching->d) { + } else if (!(matching->d & (rw == 1))) { n = MMU_DTLB_INITIAL_WRITE; } else {