From 4b0d8f1279ccf2cc7a8407ea5d66670af06d8ea6 Mon Sep 17 00:00:00 2001 From: Varsha Date: Wed, 4 Apr 2018 16:11:55 +0530 Subject: [PATCH 1/2] Report for parentheses equality warning --- Report/Report_0002.md | 66 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Report/Report_0002.md diff --git a/Report/Report_0002.md b/Report/Report_0002.md new file mode 100644 index 0000000..a7c369d --- /dev/null +++ b/Report/Report_0002.md @@ -0,0 +1,66 @@ +# Warning Analysis Report + +### General + +**Warning Type:** Wparentheses-equality
+**Warning Explanation:** +``` +drivers/crypto/cavium/zip/zip_regs.h:820:15: warning: equality comparison with + extraneous parentheses [-Wparentheses-equality] + if (((param1 == 0))) + ~~~~~~~^~~~ +drivers/crypto/cavium/zip/zip_regs.h:820:15: note: remove extraneous parentheses + around the comparison to silence this warning + if (((param1 == 0))) + ~ ^ ~ +drivers/crypto/cavium/zip/zip_regs.h:820:15: note: use '=' to turn this equality + comparison into an assignment + if (((param1 == 0))) +``` +### History + +**Date:** 2017-02-15
+**Version:** v4.12-rc1
+**Author:** Mahipal Challa
+Patch: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=640035a2dc5534b49cd64580e41874b71f131a1c + +### Warning Assessment + +**File Location:** drivers/crypto/cavium/zip/zip_regs.h +``` +static inline u64 ZIP_MSIX_PBAX(u64 param1) +{ + if (((param1 == 0))) + return 0x0000838000FF0000ull; + pr_err("ZIP_MSIX_PBAX: %llu\n", param1); + return 0; +} +``` +The warning is true. There are few other places in the same file, where +extra parentheses is used. One of them is in ZIP_MSIX_VECX_ADDR +function. +``` +static inline u64 ZIP_MSIX_VECX_ADDR(u64 param1) +{ + if (((param1 <= 17))) + return 0x0000838000F00000ull + (param1 & 31) * 0x10ull; + pr_err("ZIP_MSIX_VECX_ADDR: %llu\n", param1); + return 0; +} +``` +### Solution + +Use the following Coccinelle script to remove extra parentheses. +``` +@@ +identifier i; +constant c; +@@ +( +-((i == c)) ++i == c +| +-((i <= c)) ++i <= c +) +``` From c20a01a9132faf086fe86f9be018ea27ae925719 Mon Sep 17 00:00:00 2001 From: Varsha Date: Sun, 29 Apr 2018 22:07:49 +0530 Subject: [PATCH 2/2] Add link to the accepted patch --- Report/Report_0002.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Report/Report_0002.md b/Report/Report_0002.md index a7c369d..27870de 100644 --- a/Report/Report_0002.md +++ b/Report/Report_0002.md @@ -64,3 +64,6 @@ constant c; +i <= c ) ``` +### Accepted Patch +Commit Id: 5b0aa2556
+Link: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git/commit/?id=5b0aa2556ec9ea98f98e2a802818f75827896d25