Skip to contentSkip to conversation

misc: echo: Remove unnecessary parentheses and simplify check for zero

PATCH In review Nathan Chancellor 2 participants 2 messages Sep 15, 2018 – Sep 17, 2018 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 misc: echo: Remove unnecessary parentheses and simplify check for zero

Clang warns when multiple pairs of parentheses are used for a single conditional statement.

drivers/misc/echo/echo.c:384:27: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

        if ((ec->nonupdate_dwell == 0)) {
             ~~~~~~~~~~~~~~~~~~~~^~~~

drivers/misc/echo/echo.c:384:27: note: remove extraneous parentheses around the comparison to silence this warning
if ((ec->nonupdate_dwell == 0)) {
~ ^ ~
drivers/misc/echo/echo.c:384:27: note: use '=' to turn this equality comparison into an assignment

        if ((ec->nonupdate_dwell == 0)) {
                                 ^~
                                 =

1 warning generated.

Remove them and while we're at it, simplify the zero check as '!var' is used more than 'var == 0'.

---
 drivers/misc/echo/echo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/echo/echo.c +1 -1
index 8a5adc0d2e88..3ebe5d75ad6a 100644
@@ -381,7 +381,7 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
 	 */
 	ec->factor = 0;
 	ec->shift = 0;
-	if ((ec->nonupdate_dwell == 0)) {
+	if (!ec->nonupdate_dwell) {
 		int p, logp, shift;
 
 		/* Determine:
Signature · 1 line
2.18.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Nathan Chancellor

Clang warns when multiple pairs of parentheses are used for a single conditional statement.

drivers/misc/echo/echo.c:384:27: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]

        if ((ec->nonupdate_dwell == 0)) {
             ~~~~~~~~~~~~~~~~~~~~^~~~

drivers/misc/echo/echo.c:384:27: note: remove extraneous parentheses around the comparison to silence this warning
if ((ec->nonupdate_dwell == 0)) {
~ ^ ~
drivers/misc/echo/echo.c:384:27: note: use '=' to turn this equality comparison into an assignment

        if ((ec->nonupdate_dwell == 0)) {
                                 ^~
                                 =
Quoted 7 lines

1 warning generated.

Remove them and while we're at it, simplify the zero check as '!var' is used more than 'var == 0'.

Nathan,
Thanks for this patch.

Quoted 20 lines
---
 drivers/misc/echo/echo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/echo/echo.c +1 -2
index 8a5adc0d2e88..3ebe5d75ad6a 100644
@@ -381,7 +381,7 @@ int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx)
         */
        ec->factor = 0;
        ec->shift = 0;
-       if ((ec->nonupdate_dwell == 0)) {
+       if (!ec->nonupdate_dwell) {
                int p, logp, shift;
 
                /* Determine:
--

2.18.0

Signature · 2 lines
Thanks,
~Nick Desaulniers