Skip to contentSkip to conversation

dm flakey: Fix clang -Wparentheses-equality in flakey_map()

PATCH In review Nathan Chancellor 2 participants 2 messages Feb 2, 2023 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm flakey: Fix clang -Wparentheses-equality in flakey_map()

Clang warns:

../drivers/md/dm-flakey.c:369:28: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality]

                          if ((fc->corrupt_bio_rw == WRITE)) {
                               ~~~~~~~~~~~~~~~~~~~^~~~~~~~
  ../drivers/md/dm-flakey.c:369:28: note: remove extraneous parentheses around the comparison to silence this warning
                          if ((fc->corrupt_bio_rw == WRITE)) {
                              ~                   ^       ~
  ../drivers/md/dm-flakey.c:369:28: note: use '=' to turn this equality comparison into an assignment
                          if ((fc->corrupt_bio_rw == WRITE)) {
                                                  ^~
                                                  =

1 error generated.

GCC only warns when one set of parentheses are used for assignment expressions, whereas clang additionally warns when two sets of parentheses are used for equality comparisons. Remove the extra set of parentheses to silence the warning as it suggests, as this is obviously supposed to be an equality comparison.

Fixes 0e766389cedc ("dm flakey: fix logic when corrupting a bio")

---
I do not mind this change being squashed with the offending commit, as I noticed it was Cc'd for stable, which would minimize the chance for breakage.

---
 drivers/md/dm-flakey.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-flakey.c +1 -1
index 08f9aa476d97..335684a1aeaa 100644
@@ -366,7 +366,7 @@ static int flakey_map(struct dm_target *ti, struct bio *bio)
 		 * Corrupt matching writes.
 		 */
 		if (fc->corrupt_bio_byte) {
-			if ((fc->corrupt_bio_rw == WRITE)) {
+			if (fc->corrupt_bio_rw == WRITE) {
 				if (all_corrupt_bio_flags_match(bio, fc))
 					corrupt_bio_data(bio, fc);
 			}

---
base-commit: 6f30cc248507ee96c22ff4c3cbc86099ff12b7a9
change-id: 20230202-dm-parenthesis-warning-6139f4b5020b

Best regards,

Signature · 1 line
Nathan Chancellor <[email protected]>
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · Nathan Chancellor

Clang warns:

../drivers/md/dm-flakey.c:369:28: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality]

                          if ((fc->corrupt_bio_rw == WRITE)) {
                               ~~~~~~~~~~~~~~~~~~~^~~~~~~~
  ../drivers/md/dm-flakey.c:369:28: note: remove extraneous parentheses around the comparison to silence this warning
                          if ((fc->corrupt_bio_rw == WRITE)) {
                              ~                   ^       ~
  ../drivers/md/dm-flakey.c:369:28: note: use '=' to turn this equality comparison into an assignment
                          if ((fc->corrupt_bio_rw == WRITE)) {
                                                  ^~
                                                  =

1 error generated.

GCC only warns when one set of parentheses are used for assignment expressions, whereas clang additionally warns when two sets of parentheses are used for equality comparisons. Remove the extra set of parentheses to silence the warning as it suggests, as this is obviously supposed to be an equality comparison.

Quoted 3 lines
Fixes 0e766389cedc ("dm flakey: fix logic when corrupting a bio")

Thanks for the patch!

Quoted 30 lines

---
I do not mind this change being squashed with the offending commit, as I noticed it was Cc'd for stable, which would minimize the chance for breakage.

---
 drivers/md/dm-flakey.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-flakey.c +1 -2
index 08f9aa476d97..335684a1aeaa 100644
@@ -366,7 +366,7 @@ static int flakey_map(struct dm_target *ti, struct bio *bio)
                 * Corrupt matching writes.
                 */
                if (fc->corrupt_bio_byte) {
-                       if ((fc->corrupt_bio_rw == WRITE)) {
+                       if (fc->corrupt_bio_rw == WRITE) {
                                if (all_corrupt_bio_flags_match(bio, fc))
                                        corrupt_bio_data(bio, fc);
                        }
 
---

base-commit: 6f30cc248507ee96c22ff4c3cbc86099ff12b7a9
change-id: 20230202-dm-parenthesis-warning-6139f4b5020b

Best regards,
--
Nathan Chancellor <[email protected]>

Signature · 2 lines
Thanks,
~Nick Desaulniers