Skip to contentSkip to conversation

memops.c: always true expression

PATCH In review Nicolas Kaiser 3 participants 3 messages Nov 21, 2010 – Nov 23, 2010 Sparse checker

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memops.c: always true expression

I noticed that the second part of this conditional is always true. Just a shot in the dark: Could that be a typo?

---
 memops.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
memops.c +1 -1
index 9eafb72..45bd340 100644
@@ -69,7 +69,7 @@ static int address_taken(pseudo_t pseudo)
 	struct pseudo_user *pu;
 	FOR_EACH_PTR(pseudo->users, pu) {
 		struct instruction *insn = pu->insn;
-		if (insn->bb && (insn->opcode != OP_LOAD || insn->opcode != OP_STORE))
+		if (insn->bb && (insn->opcode != OP_LOAD && insn->opcode != OP_STORE))
 			return 1;
 	} END_FOR_EACH_PTR(pu);
 	return 0;
Signature · 1 line
1.7.2.2
maintainer
#1 lore raw
Quoted 4 lines · Nicolas Kaiser

I noticed that the second part of this conditional is always true.
Just a shot in the dark: Could that be a typo?
-               if (insn->bb && (insn->opcode != OP_LOAD || insn->opcode != OP_STORE))
+               if (insn->bb && (insn->opcode != OP_LOAD && insn->opcode != OP_STORE))

I think you are right. The insn->opcode can't be both OP_LOAD and OP_STORE.

The fix seems right to me. That is a good catch.

Thanks

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 9 lines · Christopher Li
Quoted 4 lines · Nicolas Kaiser

I noticed that the second part of this conditional is always true.
Just a shot in the dark: Could that be a typo?
-               if (insn->bb && (insn->opcode != OP_LOAD || insn->opcode != OP_STORE))
+               if (insn->bb && (insn->opcode != OP_LOAD && insn->opcode != OP_STORE))

I think you are right. The insn->opcode can't be both OP_LOAD and OP_STORE.

The fix seems right to me. That is a good catch.

I wonder if running sparse on it could catch this...

Regards,

Signature · 5 lines
Anderson Lizardo
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html