Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1633746 > unrolled thread

[PATCH 1/4] drm/dp: Use seq_putc() in drm_dp_mst_dump_topology()

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-05-01 19:00 +0200
Last post2017-05-01 19:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 1/4] drm/dp: Use seq_putc() in drm_dp_mst_dump_topology() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-01 19:00 +0200
    Re: [PATCH 1/4] drm/dp: Use seq_putc() in drm_dp_mst_dump_topology() Joe Perches <joe@perches.com> - 2017-05-01 19:20 +0200

#1633746 — [PATCH 1/4] drm/dp: Use seq_putc() in drm_dp_mst_dump_topology()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-05-01 19:00 +0200
Subject[PATCH 1/4] drm/dp: Use seq_putc() in drm_dp_mst_dump_topology()
Message-ID<tCmQ1-39r-7@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 1 May 2017 17:08:56 +0200

A few single characters (line breaks) should be put into a sequence.
Thus use the corresponding function "seq_putc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index d3fc7e4e85b7..89fc05fa6a74 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -2840,17 +2840,17 @@ void drm_dp_mst_dump_topology(struct seq_file *m,
 		seq_printf(m, "dpcd: ");
 		for (i = 0; i < DP_RECEIVER_CAP_SIZE; i++)
 			seq_printf(m, "%02x ", buf[i]);
-		seq_printf(m, "\n");
+		seq_putc(m, '\n');
 		ret = drm_dp_dpcd_read(mgr->aux, DP_FAUX_CAP, buf, 2);
 		seq_printf(m, "faux/mst: ");
 		for (i = 0; i < 2; i++)
 			seq_printf(m, "%02x ", buf[i]);
-		seq_printf(m, "\n");
+		seq_putc(m, '\n');
 		ret = drm_dp_dpcd_read(mgr->aux, DP_MSTM_CTRL, buf, 1);
 		seq_printf(m, "mst ctrl: ");
 		for (i = 0; i < 1; i++)
 			seq_printf(m, "%02x ", buf[i]);
-		seq_printf(m, "\n");
+		seq_putc(m, '\n');
 
 		/* dump the standard OUI branch header */
 		ret = drm_dp_dpcd_read(mgr->aux, DP_BRANCH_OUI, buf, DP_BRANCH_OUI_HEADER_SIZE);
@@ -2868,7 +2868,7 @@ void drm_dp_mst_dump_topology(struct seq_file *m,
 			seq_printf(m, "payload table: ");
 			for (i = 0; i < 63; i++)
 				seq_printf(m, "%02x ", buf[i]);
-			seq_printf(m, "\n");
+			seq_putc(m, '\n');
 		}
 
 	}
-- 
2.12.2

[toc] | [next] | [standalone]


#1633756

FromJoe Perches <joe@perches.com>
Date2017-05-01 19:20 +0200
Message-ID<tCn9n-3uH-7@gated-at.bofh.it>
In reply to#1633746
On Mon, 2017-05-01 at 18:46 +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 1 May 2017 17:08:56 +0200
> 
> A few single characters (line breaks) should be put into a sequence.
> Thus use the corresponding function "seq_putc".
> 
> This issue was detected by using the Coccinelle software.
[]
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
[]
> @@ -2840,17 +2840,17 @@ void drm_dp_mst_dump_topology(struct seq_file *m,
>  		seq_printf(m, "dpcd: ");
>  		for (i = 0; i < DP_RECEIVER_CAP_SIZE; i++)
>  			seq_printf(m, "%02x ", buf[i]);
> -		seq_printf(m, "\n");
> +		seq_putc(m, '\n');
>  		ret = drm_dp_dpcd_read(mgr->aux, DP_FAUX_CAP, buf, 2);
>  		seq_printf(m, "faux/mst: ");
>  		for (i = 0; i < 2; i++)
>  			seq_printf(m, "%02x ", buf[i]);
> -		seq_printf(m, "\n");
> +		seq_putc(m, '\n');
>  		ret = drm_dp_dpcd_read(mgr->aux, DP_MSTM_CTRL, buf, 1);
>  		seq_printf(m, "mst ctrl: ");
>  		for (i = 0; i < 1; i++)
>  			seq_printf(m, "%02x ", buf[i]);
> -		seq_printf(m, "\n");
> +		seq_putc(m, '\n');

Please don't be _just_ mechanical.

Stop and read the code the tools you use using
suggest modifying and see how you can improve
it for a human reader.

If you're really trying to improve these to make
them more readable or smaller object code size, 
you should use the vsprintf extensions like:

		seq_printf(m, "dpcd: %*ph\n", DP_RECEIVER_CAP_SIZE, buf);

And if these are supposed to be correct, then
the return value from drm_dp_dpcd_read should
be tested too.

Likely these repeated code blocks could be put
into a helper function.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web