Skip to contentSkip to conversation

staging:iio:ade7854 surround complex defines in parentheses

PATCH In review daniel watson 4 participants 6 messages Aug 15, 2021 – Aug 17, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging:iio:ade7854 surround complex defines in parentheses

Error found by checkpatch.pl

---
 drivers/staging/iio/meter/ade7854.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/meter/ade7854.h +3 -3
index a51e6e3183d38..afb13e21002e1 100644
@@ -139,9 +139,9 @@
 #define ADE7854_MAX_RX    7
 #define ADE7854_STARTUP_DELAY 1000
 
-#define ADE7854_SPI_SLOW	(u32)(300 * 1000)
-#define ADE7854_SPI_BURST	(u32)(1000 * 1000)
-#define ADE7854_SPI_FAST	(u32)(2000 * 1000)
+#define ADE7854_SPI_SLOW	((u32)(300 * 1000))
+#define ADE7854_SPI_BURST	((u32)(1000 * 1000))
+#define ADE7854_SPI_FAST	((u32)(2000 * 1000))
 
 /**
  * struct ade7854_state - device instance specific data
Signature · 1 line
2.30.2
#1 lore raw
Quoted 1 line · daniel watson

Error found by checkpatch.pl

What error?

Quoted 2 lines

Capitalize your name?

Quoted 9 lines
---
 drivers/staging/iio/meter/ade7854.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/meter/ade7854.h +0 -0
index a51e6e3183d38..afb13e21002e1 100644

drivers/staging/iio/meter/ade7854.h line 144

Quoted 9 lines
drivers/staging/iio/meter/ade7854.h +3 -3
@@ -139,9 +139,9 @@
 #define ADE7854_MAX_RX    7
 #define ADE7854_STARTUP_DELAY 1000
 
-#define ADE7854_SPI_SLOW	(u32)(300 * 1000)
-#define ADE7854_SPI_BURST	(u32)(1000 * 1000)
-#define ADE7854_SPI_FAST	(u32)(2000 * 1000)
+#define ADE7854_SPI_SLOW	((u32)(300 * 1000))
+#define ADE7854_SPI_BURST	((u32)(1000 * 1000))
+#define ADE7854_SPI_FAST	((u32)(2000 * 1000))

This is not a real change that is needed, just look at the code to verify that.

thanks,

greg k-h

#2 lore raw

If this is a false positive from checkpatch, I can submit it as an example to the checkpatch maintainers. Do you think I should?

Quoted 4 lines · Greg Kroah-Hartman
Quoted 1 line · daniel watson

Error found by checkpatch.pl

What error?

$ git checkout 36a21d5172 drivers/staging/iio/meter/ade7854.h # before
Updated 1 path from 638ccd1543654
$ ./scripts/checkpatch.pl --terse --types COMPLEX_MACRO \
drivers/staging/iio/meter/ade7854.h
drivers/staging/iio/meter/ade7854.h:142: ERROR: Macros with complex
values should be enclosed in parentheses
drivers/staging/iio/meter/ade7854.h:143: ERROR: Macros with complex
values should be enclosed in parentheses
drivers/staging/iio/meter/ade7854.h:144: ERROR: Macros with complex
values should be enclosed in parentheses
total: 3 errors, 0 warnings, 0 checks, 173 lines checked
$ git checkout 143b51a80978 drivers/staging/iio/meter/ade7854.h # after
Updated 1 path from 21c208a36476a
$ ./scripts/checkpatch.pl --terse --types COMPLEX_MACRO \
drivers/staging/iio/meter/ade7854.h

$

Quoted 3 lines
Quoted 1 line

Capitalize your name?

I can remake this patch with my name capitalized if the patch is worth remaking. I'll be sure to capitalize in future sign-off lines for Linux.

Quoted 2 lines

This is not a real change that is needed, just look at the code to verify that.

Agreed, this is not a huge change.

I thought small changes were acceptable, if they get rid of errors from checkpatch. I got that impression from this video

Write and Submit your first Linux kernel Patch
https://youtu.be/LLBrBBImJt4

At around 15 minutes, you create a patch which removes curly braces from an if-else. That seemed comparable to the change in this patch. That video was posted over a decade ago, so I would understand if things are different now.

Quoted 4 lines

thanks,

greg k-h

You're welcome! Thank you too, that was a super fast response! I am happy to get a direct response from you!

#3 lore raw
Quoted 3 lines · daniel watson

If this is a false positive from checkpatch, I can submit it as an example to the checkpatch maintainers. Do you think I should?

checkpatch is a perl script that does pattern matching, it is really hard for it to determine for things like this specific example, that it is not needed.

Try finding other valid checkpatch cleanups if you wish to contribute in this way, there are loads of others under drivers/staging/ that should be easy to find.

thanks,

greg k-h

#4 lore raw
Quoted 5 lines · Greg Kroah-Hartman
Quoted 3 lines · daniel watson

If this is a false positive from checkpatch, I can submit it as an example to the checkpatch maintainers. Do you think I should?

Quoted 7 lines

checkpatch is a perl script that does pattern matching, it is really hard for it to determine for things like this specific example, that it is not needed.

Try finding other valid checkpatch cleanups if you wish to contribute in this way, there are loads of others under drivers/staging/ that should be easy to find.

These macros, and several other '#define ADE7854_<FOO> <value>' instances, are apparently unused and could possibly be removed instead.

#5 lore raw
In reply to daniel watson

Hi Daniel,

Welcome to drivers/staging.

Quoted 8 lines · CEST daniel watson

If this is a false positive from checkpatch, I can submit it as an example to the checkpatch maintainers. Do you think I should?

Quoted 4 lines · Greg Kroah-Hartman
Quoted 1 line · daniel watson

Error found by checkpatch.pl

What error?

Please, understand that Greg K-H is very busy, so he often is quite terse in his responses. That does not absolutely mean he doesn't care.

You'll read from him questions like "Why did you do this?" or "What error?" or other similar ones. I think that while working here during the past four months I've become able to "decode" :) the meaning of the above questions (at least, I hope).

First of all you should read and follow the guidelines about how to submit
patches: "Submitting patches: the essential guide to getting your code into the kernel" at https://www.kernel.org/doc/html/latest/process/submitting-patches.html

"What error?" may mean that you have not sufficiently described the underlying problem that motivated you to do this work. Don't assume that the reviewers can and want to deduce what the error is by just reading the "Subject" line.

The "Subject" should summarize in few words the content of the commit message, and the commit message should never be written with the assumption that the readers want to compose the whole picture by merging "Subject" and "Commit message" together: they have different purposes and they should be self- contained entities. "Error found by checkpatch.pl" does say nothing about what error you're addressing.

Furthermore, the above-mentioned question may also mean: "Are you sure that there are *real* errors/problems?". In this case they are just false positives.

An example of a real problem that should be worked out by adding parenthesis is the following one...

#define SQRT(x) (x * x)

What happens if some code uses that macro like the following example?

int a = 3;
int b = SQRT(a + 2)

Would the result differ if we put parentheses around arguments?

#define SQRT(x) ((x) * (x))

As Greg wrote in another message of this thread: "checkpatch is a perl script that does pattern matching, it is really hard for it to determine for things like this specific example, that it is not needed.".

The lesson is: we expect you're smarter than checkpatch.pl! :)

Quoted 13 lines
$ git checkout 36a21d5172 drivers/staging/iio/meter/ade7854.h # before
Updated 1 path from 638ccd1543654
$ ./scripts/checkpatch.pl --terse --types COMPLEX_MACRO \
drivers/staging/iio/meter/ade7854.h
drivers/staging/iio/meter/ade7854.h:142: ERROR: Macros with complex
values should be enclosed in parentheses
drivers/staging/iio/meter/ade7854.h:143: ERROR: Macros with complex
values should be enclosed in parentheses
drivers/staging/iio/meter/ade7854.h:144: ERROR: Macros with complex
values should be enclosed in parentheses
total: 3 errors, 0 warnings, 0 checks, 173 lines checked
Quoted 2 lines
$ git checkout 143b51a80978 drivers/staging/iio/meter/ade7854.h # after
Updated 1 path from 21c208a36476a

OK, this is one of many common ways to explain what errors you're addressing. Unfortunately, in this case they are false positives (so you should have ignored them and move on to the next problem).

Quoted 9 lines
$ ./scripts/checkpatch.pl --terse --types COMPLEX_MACRO \
drivers/staging/iio/meter/ade7854.h

$

Quoted 3 lines
Quoted 1 line

Capitalize your name?

Quoted 8 lines

I can remake this patch with my name capitalized if the patch is worth remaking. I'll be sure to capitalize in future sign-off lines for Linux.

Quoted 2 lines

This is not a real change that is needed, just look at the code to verify that.

Agreed, this is not a huge change.

Minor changes are very well welcome here. Move on to something else and fix only what really needs to be fixed.

Quoted 10 lines

I thought small changes were acceptable, if they get rid of errors from checkpatch. I got that impression from this video

Write and Submit your first Linux kernel Patch
https://youtu.be/LLBrBBImJt4

At around 15 minutes, you create a patch which removes curly braces from an if-else. That seemed comparable to the change in this patch. That video was posted over a decade ago, so I would understand if things are different now.

Read again the last sentence I wrote above. I can confirm that the removal of really unneeded curly braces is wanted and welcome.

Have a nice time with kernel hacking.

Thanks,

Fabio

Quoted 6 lines
Quoted 3 lines

thanks,

greg k-h

You're welcome! Thank you too, that was a super fast response! I am happy to get a direct response from you!