2020-11-04 05:27:57

by Kaixu Xia

[permalink] [raw]
Subject: [PATCH] cxgb4: Fix the -Wmisleading-indentation warning

From: Kaixu Xia <[email protected]>

Fix the gcc warning:

drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c:2673:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
2673 | for (i = 0; i < n; ++i) \

Reported-by: Tosk Robot <[email protected]>
Signed-off-by: Kaixu Xia <[email protected]>
---
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index 0273f40b85f7..c24d34a937c8 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -2671,7 +2671,7 @@ do { \
seq_printf(seq, "%-12s", s); \
for (i = 0; i < n; ++i) \
seq_printf(seq, " %16" fmt_spec, v); \
- seq_putc(seq, '\n'); \
+ seq_putc(seq, '\n'); \
} while (0)
#define S(s, v) S3("s", s, v)
#define T3(fmt_spec, s, v) S3(fmt_spec, s, tx[i].v)
--
2.20.0


2020-11-05 20:00:12

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] cxgb4: Fix the -Wmisleading-indentation warning

On Wed, 2020-11-04 at 13:24 +0800, [email protected] wrote:
> From: Kaixu Xia <[email protected]>
>
> Fix the gcc warning:
>
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c:2673:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
> ?2673 | for (i = 0; i < n; ++i) \

true, the defined macros though aren't pretty and depend on
externally defined i and n.

It'd be good to show that and to update the slightly difficult to read
helpers below that and remove the unnecessary T3 and R3 macros too.

Perhaps:
---
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 28 ++++++++++------------
1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index 0273f40b85f7..a7fddcdf4eac 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -2666,20 +2666,20 @@ static int sge_qinfo_show(struct seq_file *seq, void *v)
if (r)
seq_putc(seq, '\n');

-#define S3(fmt_spec, s, v) \
-do { \
- seq_printf(seq, "%-12s", s); \
- for (i = 0; i < n; ++i) \
- seq_printf(seq, " %16" fmt_spec, v); \
- seq_putc(seq, '\n'); \
+/* These macros are dependent on locally scoped i and n variables */
+#define S3(fmt_spec, s, v) \
+do { \
+ seq_printf(seq, "%-12s", s); \
+ for (i = 0; i < n; ++i) \
+ seq_printf(seq, " %16" fmt_spec, v); \
+ seq_putc(seq, '\n'); \
} while (0)
-#define S(s, v) S3("s", s, v)
-#define T3(fmt_spec, s, v) S3(fmt_spec, s, tx[i].v)
-#define T(s, v) S3("u", s, tx[i].v)
-#define TL(s, v) T3("lu", s, v)
-#define R3(fmt_spec, s, v) S3(fmt_spec, s, rx[i].v)
-#define R(s, v) S3("u", s, rx[i].v)
-#define RL(s, v) R3("lu", s, v)
+
+#define S(s, v) S3("s", s, v)
+#define T(s, v) S3("u", s, tx[i].v)
+#define TL(s, v) S3("lu", s, tx[i].v)
+#define R(s, v) S3("u", s, rx[i].v)
+#define RL(s, v) S3("lu", s, rx[i].v)

if (r < eth_entries) {
int base_qset = r * 4;
@@ -3139,8 +3139,6 @@ do { \
#undef T
#undef TL
#undef S
-#undef R3
-#undef T3
#undef S3
out:
return 0;


2020-11-07 19:59:51

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH] cxgb4: Fix the -Wmisleading-indentation warning

On Wed, 4 Nov 2020 13:24:04 +0800 [email protected] wrote:
> From: Kaixu Xia <[email protected]>
>
> Fix the gcc warning:
>
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c:2673:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
> 2673 | for (i = 0; i < n; ++i) \
>
> Reported-by: Tosk Robot <[email protected]>
> Signed-off-by: Kaixu Xia <[email protected]>

Applied, thanks!