Skip to contentSkip to conversation

staging: ks7010: Macros with complex values

PATCH In review Fatih Yildirim 2 participants 7 messages Feb 11, 2021 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: ks7010: Macros with complex values

Fix for checkpatch.pl warning:
Macros with complex values should be enclosed in parentheses.

---
 drivers/staging/ks7010/ks_hostif.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/staging/ks7010/ks_hostif.h +12 -12
index 39138191a556..c62a494ed6bb 100644
@@ -498,20 +498,20 @@ struct hostif_mic_failure_request {
 #define TX_RATE_FIXED		5
 
 /* 11b rate */
-#define TX_RATE_1M	(u8)(10 / 5)	/* 11b 11g basic rate */
-#define TX_RATE_2M	(u8)(20 / 5)	/* 11b 11g basic rate */
-#define TX_RATE_5M	(u8)(55 / 5)	/* 11g basic rate */
-#define TX_RATE_11M	(u8)(110 / 5)	/* 11g basic rate */
+#define TX_RATE_1M	((u8)(10 / 5))	/* 11b 11g basic rate */
+#define TX_RATE_2M	((u8)(20 / 5))	/* 11b 11g basic rate */
+#define TX_RATE_5M	((u8)(55 / 5))	/* 11g basic rate */
+#define TX_RATE_11M	((u8)(110 / 5))	/* 11g basic rate */
 
 /* 11g rate */
-#define TX_RATE_6M	(u8)(60 / 5)	/* 11g basic rate */
-#define TX_RATE_12M	(u8)(120 / 5)	/* 11g basic rate */
-#define TX_RATE_24M	(u8)(240 / 5)	/* 11g basic rate */
-#define TX_RATE_9M	(u8)(90 / 5)
-#define TX_RATE_18M	(u8)(180 / 5)
-#define TX_RATE_36M	(u8)(360 / 5)
-#define TX_RATE_48M	(u8)(480 / 5)
-#define TX_RATE_54M	(u8)(540 / 5)
+#define TX_RATE_6M	((u8)(60 / 5))	/* 11g basic rate */
+#define TX_RATE_12M	((u8)(120 / 5))	/* 11g basic rate */
+#define TX_RATE_24M	((u8)(240 / 5))	/* 11g basic rate */
+#define TX_RATE_9M	((u8)(90 / 5))
+#define TX_RATE_18M	((u8)(180 / 5))
+#define TX_RATE_36M	((u8)(360 / 5))
+#define TX_RATE_48M	((u8)(480 / 5))
+#define TX_RATE_54M	((u8)(540 / 5))
 
 static inline bool is_11b_rate(u8 rate)
 {
Signature · 1 line
2.20.1
maintainer
#1 lore raw
Quoted 14 lines · Fatih Yildirim

Fix for checkpatch.pl warning:
Macros with complex values should be enclosed in parentheses.

---
 drivers/staging/ks7010/ks_hostif.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/staging/ks7010/ks_hostif.h +0 -0
index 39138191a556..c62a494ed6bb 100644
@@ -498,20 +498,20 @@ struct hostif_mic_failure_request {
 #define TX_RATE_FIXED		5

drivers/staging/ks7010/ks_hostif.h struct hostif_mic_failure_request { · line 504

Quoted 10 lines
drivers/staging/ks7010/ks_hostif.h +4 -4
 
 /* 11b rate */
-#define TX_RATE_1M	(u8)(10 / 5)	/* 11b 11g basic rate */
-#define TX_RATE_2M	(u8)(20 / 5)	/* 11b 11g basic rate */
-#define TX_RATE_5M	(u8)(55 / 5)	/* 11g basic rate */
-#define TX_RATE_11M	(u8)(110 / 5)	/* 11g basic rate */
+#define TX_RATE_1M	((u8)(10 / 5))	/* 11b 11g basic rate */
+#define TX_RATE_2M	((u8)(20 / 5))	/* 11b 11g basic rate */
+#define TX_RATE_5M	((u8)(55 / 5))	/* 11g basic rate */
+#define TX_RATE_11M	((u8)(110 / 5))	/* 11g basic rate */

But these are not "complex macros" that need an extra () added to them, right?

Checkpatch is a hint, it's not a code parser and can not always know what is happening. With your knowledge of C, does this look like something that needs to be "fixed"?

thanks,

greg k-h

#2 lore raw
Quoted 29 lines · Greg KH
Quoted 14 lines · Fatih Yildirim

Fix for checkpatch.pl warning:
Macros with complex values should be enclosed in parentheses.

---
 drivers/staging/ks7010/ks_hostif.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/staging/ks7010/ks_hostif.h +0 -0
index 39138191a556..c62a494ed6bb 100644
@@ -498,20 +498,20 @@ struct hostif_mic_failure_request {
 #define TX_RATE_FIXED		5

drivers/staging/ks7010/ks_hostif.h struct hostif_mic_failure_request { · line 504

Quoted 10 lines
drivers/staging/ks7010/ks_hostif.h +4 -4
 
 /* 11b rate */
-#define TX_RATE_1M	(u8)(10 / 5)	/* 11b 11g basic rate */
-#define TX_RATE_2M	(u8)(20 / 5)	/* 11b 11g basic rate */
-#define TX_RATE_5M	(u8)(55 / 5)	/* 11g basic rate */
-#define TX_RATE_11M	(u8)(110 / 5)	/* 11g basic rate */
+#define TX_RATE_1M	((u8)(10 / 5))	/* 11b 11g basic rate */
+#define TX_RATE_2M	((u8)(20 / 5))	/* 11b 11g basic rate */
+#define TX_RATE_5M	((u8)(55 / 5))	/* 11g basic rate */
+#define TX_RATE_11M	((u8)(110 / 5))	/* 11g basic rate */

But these are not "complex macros" that need an extra () added to them, right?

Quoted 7 lines

Checkpatch is a hint, it's not a code parser and can not always know what is happening. With your knowledge of C, does this look like something that needs to be "fixed"?

thanks,

greg k-h

Hi Greg,

Thanks for your reply.
Actually, I'm following the Eudyptula Challenge and I'm at task 10. Task is to find and fix a coding style in linux-next/drivers/staging. I've checked many files with checkpatch.pl but they are almost fine :) I found this one and prepared a patch for it.
Thanks in advance for your comments and advice.

Thanks,
Fatih

maintainer
#3 lore raw
Quoted 34 lines · Fatih YILDIRIM
Quoted 33 lines · Greg KH
Quoted 14 lines · Fatih Yildirim

Fix for checkpatch.pl warning:
Macros with complex values should be enclosed in parentheses.

---
 drivers/staging/ks7010/ks_hostif.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/staging/ks7010/ks_hostif.h +0 -0
index 39138191a556..c62a494ed6bb 100644
@@ -498,20 +498,20 @@ struct hostif_mic_failure_request {
 #define TX_RATE_FIXED		5

drivers/staging/ks7010/ks_hostif.h struct hostif_mic_failure_request { · line 504

Quoted 10 lines
drivers/staging/ks7010/ks_hostif.h +4 -4
 
 /* 11b rate */
-#define TX_RATE_1M	(u8)(10 / 5)	/* 11b 11g basic rate */
-#define TX_RATE_2M	(u8)(20 / 5)	/* 11b 11g basic rate */
-#define TX_RATE_5M	(u8)(55 / 5)	/* 11g basic rate */
-#define TX_RATE_11M	(u8)(110 / 5)	/* 11g basic rate */
+#define TX_RATE_1M	((u8)(10 / 5))	/* 11b 11g basic rate */
+#define TX_RATE_2M	((u8)(20 / 5))	/* 11b 11g basic rate */
+#define TX_RATE_5M	((u8)(55 / 5))	/* 11g basic rate */
+#define TX_RATE_11M	((u8)(110 / 5))	/* 11g basic rate */

But these are not "complex macros" that need an extra () added to them, right?

Checkpatch is a hint, it's not a code parser and can not always know what is happening. With your knowledge of C, does this look like something that needs to be "fixed"?

Quoted 8 lines
Quoted 3 lines

thanks,

greg k-h

Hi Greg,

Thanks for your reply.
Actually, I'm following the Eudyptula Challenge and I'm at task 10.

First rule of that challenge is that you are not allowed to talk about it in public :)

That being said, you didn't answer any of my questions above :(

greg k-h

#4 lore raw
Quoted 44 lines · Greg KH
Quoted 34 lines · Fatih YILDIRIM
Quoted 33 lines · Greg KH
Quoted 14 lines · Fatih Yildirim

Fix for checkpatch.pl warning:
Macros with complex values should be enclosed in parentheses.

---
 drivers/staging/ks7010/ks_hostif.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/staging/ks7010/ks_hostif.h +0 -0
index 39138191a556..c62a494ed6bb 100644
@@ -498,20 +498,20 @@ struct hostif_mic_failure_request {
 #define TX_RATE_FIXED		5

drivers/staging/ks7010/ks_hostif.h struct hostif_mic_failure_request { · line 504

Quoted 10 lines
drivers/staging/ks7010/ks_hostif.h +4 -4
 
 /* 11b rate */
-#define TX_RATE_1M	(u8)(10 / 5)	/* 11b 11g basic rate */
-#define TX_RATE_2M	(u8)(20 / 5)	/* 11b 11g basic rate */
-#define TX_RATE_5M	(u8)(55 / 5)	/* 11g basic rate */
-#define TX_RATE_11M	(u8)(110 / 5)	/* 11g basic rate */
+#define TX_RATE_1M	((u8)(10 / 5))	/* 11b 11g basic rate */
+#define TX_RATE_2M	((u8)(20 / 5))	/* 11b 11g basic rate */
+#define TX_RATE_5M	((u8)(55 / 5))	/* 11g basic rate */
+#define TX_RATE_11M	((u8)(110 / 5))	/* 11g basic rate */

But these are not "complex macros" that need an extra () added to them, right?

Checkpatch is a hint, it's not a code parser and can not always know what is happening. With your knowledge of C, does this look like something that needs to be "fixed"?

Quoted 8 lines
Quoted 3 lines

thanks,

greg k-h

Hi Greg,

Thanks for your reply.
Actually, I'm following the Eudyptula Challenge and I'm at task 10.

Quoted 6 lines

First rule of that challenge is that you are not allowed to talk about it in public :)

That being said, you didn't answer any of my questions above :(

greg k-h

Ohh no, missed the rule. Sorry for that, I feel rookie :) You are right, they are not complex macros.
Besides that, type cast operator doesn't have the highest precedence. So, I think we can use enclosing paranthesis.

Thanks,
Fatih

maintainer
#5 lore raw
Quoted 48 lines · Fatih Yildirim
Quoted 47 lines · Greg KH
Quoted 34 lines · Fatih YILDIRIM
Quoted 33 lines · Greg KH
Quoted 14 lines · Fatih Yildirim

Fix for checkpatch.pl warning:
Macros with complex values should be enclosed in parentheses.

---
 drivers/staging/ks7010/ks_hostif.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/staging/ks7010/ks_hostif.h +0 -0
index 39138191a556..c62a494ed6bb 100644
@@ -498,20 +498,20 @@ struct hostif_mic_failure_request {
 #define TX_RATE_FIXED		5

drivers/staging/ks7010/ks_hostif.h struct hostif_mic_failure_request { · line 504

Quoted 10 lines
drivers/staging/ks7010/ks_hostif.h +4 -4
 
 /* 11b rate */
-#define TX_RATE_1M	(u8)(10 / 5)	/* 11b 11g basic rate */
-#define TX_RATE_2M	(u8)(20 / 5)	/* 11b 11g basic rate */
-#define TX_RATE_5M	(u8)(55 / 5)	/* 11g basic rate */
-#define TX_RATE_11M	(u8)(110 / 5)	/* 11g basic rate */
+#define TX_RATE_1M	((u8)(10 / 5))	/* 11b 11g basic rate */
+#define TX_RATE_2M	((u8)(20 / 5))	/* 11b 11g basic rate */
+#define TX_RATE_5M	((u8)(55 / 5))	/* 11g basic rate */
+#define TX_RATE_11M	((u8)(110 / 5))	/* 11g basic rate */

But these are not "complex macros" that need an extra () added to them, right?

Checkpatch is a hint, it's not a code parser and can not always know what is happening. With your knowledge of C, does this look like something that needs to be "fixed"?

Quoted 8 lines
Quoted 3 lines

thanks,

greg k-h

Hi Greg,

Thanks for your reply.
Actually, I'm following the Eudyptula Challenge and I'm at task 10.

First rule of that challenge is that you are not allowed to talk about it in public :)

Quoted 8 lines
Quoted 3 lines

That being said, you didn't answer any of my questions above :(

greg k-h

Ohh no, missed the rule. Sorry for that, I feel rookie :) You are right, they are not complex macros.
Besides that, type cast operator doesn't have the highest precedence. So, I think we can use enclosing paranthesis.

I don't think they are needed, see how these are used please.

thanks,

greg k-h

#6 lore raw

Ok, thanks!

Quoted 64 lines · Greg KH
Quoted 48 lines · Fatih Yildirim
Quoted 47 lines · Greg KH
Quoted 34 lines · Fatih YILDIRIM
Quoted 33 lines · Greg KH
Quoted 14 lines · Fatih Yildirim

Fix for checkpatch.pl warning:
Macros with complex values should be enclosed in parentheses.

---
 drivers/staging/ks7010/ks_hostif.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/staging/ks7010/ks_hostif.h +0 -0
index 39138191a556..c62a494ed6bb 100644
@@ -498,20 +498,20 @@ struct hostif_mic_failure_request {
 #define TX_RATE_FIXED                5

drivers/staging/ks7010/ks_hostif.h struct hostif_mic_failure_request { · line 504

Quoted 10 lines
drivers/staging/ks7010/ks_hostif.h +4 -4
 
 /* 11b rate */
-#define TX_RATE_1M   (u8)(10 / 5)    /* 11b 11g basic rate */
-#define TX_RATE_2M   (u8)(20 / 5)    /* 11b 11g basic rate */
-#define TX_RATE_5M   (u8)(55 / 5)    /* 11g basic rate */
-#define TX_RATE_11M  (u8)(110 / 5)   /* 11g basic rate */
+#define TX_RATE_1M   ((u8)(10 / 5))  /* 11b 11g basic rate */
+#define TX_RATE_2M   ((u8)(20 / 5))  /* 11b 11g basic rate */
+#define TX_RATE_5M   ((u8)(55 / 5))  /* 11g basic rate */
+#define TX_RATE_11M  ((u8)(110 / 5)) /* 11g basic rate */

But these are not "complex macros" that need an extra () added to them, right?

Checkpatch is a hint, it's not a code parser and can not always know what is happening. With your knowledge of C, does this look like something that needs to be "fixed"?

Quoted 8 lines
Quoted 3 lines

thanks,

greg k-h

Hi Greg,

Thanks for your reply.
Actually, I'm following the Eudyptula Challenge and I'm at task 10.

First rule of that challenge is that you are not allowed to talk about it in public :)

Quoted 8 lines
Quoted 3 lines

That being said, you didn't answer any of my questions above :(

greg k-h

Ohh no, missed the rule. Sorry for that, I feel rookie :) You are right, they are not complex macros.
Besides that, type cast operator doesn't have the highest precedence. So, I think we can use enclosing paranthesis.

I don't think they are needed, see how these are used please.

thanks,

greg k-h