On Wed, 2020-11-04 at 13:24 +0800, xiakaixu1...@gmail.com wrote:
> From: Kaixu Xia <kaixu...@tencent.com>
> 
> 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;


Reply via email to