Skip to contentSkip to conversation

Fix comparison using wrong pointer variable in dma debug code

PATCH Applied Thomas Jarosch 4 participants 5 messages Nov 17, 2011 – Nov 21, 2011 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix comparison using wrong pointer variable in dma debug code

cppcheck reported:
[lib/dma-debug.c:248] -> [lib/dma-debug.c:248]: (style) Same expression on both sides of '=='.

---
 lib/dma-debug.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/dma-debug.c +1 -1
index 74c6c7f..fea790a 100644
@@ -245,7 +245,7 @@ static void put_hash_bucket(struct hash_bucket *bucket,
 
 static bool exact_match(struct dma_debug_entry *a, struct dma_debug_entry *b)
 {
-	return ((a->dev_addr == a->dev_addr) &&
+	return ((a->dev_addr == b->dev_addr) &&
 		(a->dev == b->dev)) ? true : false;
 }
 
Signature · 1 line
1.7.6.4
Acked-by on v1 1/1
#1 lore raw
Quoted 30 lines · Thomas Jarosch

cppcheck reported:
[lib/dma-debug.c:248] -> [lib/dma-debug.c:248]: (style) Same expression on both sides of '=='.

---
 lib/dma-debug.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/dma-debug.c +1 -1
index 74c6c7f..fea790a 100644
@@ -245,7 +245,7 @@ static void put_hash_bucket(struct hash_bucket *bucket,
 
 static bool exact_match(struct dma_debug_entry *a, struct dma_debug_entry *b)
 {
-	return ((a->dev_addr == a->dev_addr) &&
+	return ((a->dev_addr == b->dev_addr) &&
 		(a->dev == b->dev)) ? true : false;
 }
 
Signature · 7 lines
1.7.6.4

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

Thanks for the catch! Viro just pointed out you can also remove the ? true/false changes and extraneous parens, reducing it to:

(a->dev_addr == b->dev_addr) && (a->dev == b->dev) But its not strictly necessecary

#2 lore raw
Quoted 7 lines · On Thursday, 17. November 2011 21:01:36 Neil Horman wrote:

Thanks for the catch! Viro just pointed out you can also remove the ? true/false changes and extraneous parens, reducing it to:

(a->dev_addr == b->dev_addr) && (a->dev == b->dev) But its not strictly necessecary

I'd say just commit the fix, that rarely used function is not worth the extra effort.

Cheers,
Thomas

#3 lore raw
In reply to Thomas Jarosch
Quoted 13 lines · Thomas Jarosch

cppcheck reported:
[lib/dma-debug.c:248] -> [lib/dma-debug.c:248]: (style) Same expression on both sides of '=='.

---
 lib/dma-debug.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/dma-debug.c +0 -0
index 74c6c7f..fea790a 100644

lib/dma-debug.c static void put_hash_bucket(struct hash_bucket *bucket, · line 251

Quoted 8 lines
lib/dma-debug.c +1 -1
@@ -245,7 +245,7 @@ static void put_hash_bucket(struct hash_bucket *bucket,
 
 static bool exact_match(struct dma_debug_entry *a, struct dma_debug_entry *b)
 {
-	return ((a->dev_addr == a->dev_addr) &&
+	return ((a->dev_addr == b->dev_addr) &&
 		(a->dev == b->dev)) ? true : false;
 }
 

Perhaps more sensible without the unnecessary ?:

	return a->dev_addr == b->dev_addr && a->dev == b->dev;
Applied
#4 lore raw
In reply to Thomas Jarosch
Quoted 4 lines · Thomas Jarosch

cppcheck reported:
[lib/dma-debug.c:248] -> [lib/dma-debug.c:248]: (style) Same expression on both sides of '=='.

Applied to iommu/fixes, thanks.

Signature · 5 lines
AMD Operating System Research Center

Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632