From patchwork Fri Jan 14 22:05:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Correct use of ! and & From: Blue Swirl X-Patchwork-Id: 79016 Message-Id: To: Aurelien Jarno , qemu-devel Cc: Date: Fri, 14 Jan 2011 22:05:11 +0000 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 --- target-sh4/helper.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) *prot = PAGE_READ; @@ -430,7 +430,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/target-sh4/helper.c b/target-sh4/helper.c index 2343366..c6af959 100644 --- a/target-sh4/helper.c +++ b/target-sh4/helper.c @@ -380,7 +380,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 {