Skip to contentSkip to conversation

irda: vlsi_ir: use %*ph specifier

PATCH Superseded Andy Shevchenko 2 participants 2 messages Sep 8, 2014

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 irda: vlsi_ir: use %*ph specifier

Instead of looping in the code let's use kernel extension to dump small buffers.

---
 drivers/net/irda/vlsi_ir.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/net/irda/vlsi_ir.c +2 -8
index a04af9d..78e00ad 100644
@@ -323,14 +323,8 @@ static void vlsi_proc_ring(struct seq_file *seq, struct vlsi_ring *r)
 		j = (unsigned) rd_get_count(rd);
 		seq_printf(seq, "current: rd = %d / status = %02x / len = %u\n",
 				h, (unsigned)rd_get_status(rd), j);
-		if (j > 0) {
-			seq_printf(seq, "   data:");
-			if (j > 20)
-				j = 20;
-			for (i = 0; i < j; i++)
-				seq_printf(seq, " %02x", (unsigned)((unsigned char *)rd->buf)[i]);
-			seq_printf(seq, "\n");
-		}
+		if (j > 0)
+			seq_printf(seq, "   data: %*ph\n", min(j, 20), rd->buf);
 	}
 	for (i = 0; i < r->size; i++) {
 		rd = &r->rd[i];
Signature · 1 line
2.1.0
maintainer
#1 lore raw

From: Andy Shevchenko <[email protected]>
Date: Mon, 8 Sep 2014 10:38:43 +0300

Quoted 4 lines

Instead of looping in the code let's use kernel extension to dump small buffers.

Try again:

drivers/net/irda/vlsi_ir.c: In function ‘vlsi_proc_ring’:
drivers/net/irda/vlsi_ir.c:327:39: warning: comparison of distinct pointer types lacks a cast [enabled by default]

The types on each side of the min() expression are different, so the compiler warns. You probably need to use min_t() or similar, and carefuly examine the possible effects of signed overflow etc.