From: Joe Perches <joe@perches.com>
To: SF Markus Elfring <elfring@users.sourceforge.net>,
dri-devel@lists.freedesktop.org,
Daniel Vetter <daniel.vetter@intel.com>,
David Airlie <airlied@linux.ie>,
Jani Nikula <jani.nikula@linux.intel.com>,
Sean Paul <seanpaul@chromium.org>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/4] drm/dp: Use seq_putc() in drm_dp_mst_dump_topology()
Date: Mon, 01 May 2017 10:11:27 -0700 [thread overview]
Message-ID: <1493658687.6621.3.camel@perches.com> (raw)
In-Reply-To: <da81ee94-9bbc-1754-b92f-40bcdbe923fa@users.sourceforge.net>
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.
next prev parent reply other threads:[~2017-05-01 17:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-01 16:45 [PATCH 0/4] drm/dp: Fine-tuning for three function implementations SF Markus Elfring
2017-05-01 16:46 ` [PATCH 1/4] drm/dp: Use seq_putc() in drm_dp_mst_dump_topology() SF Markus Elfring
2017-05-01 17:11 ` Joe Perches [this message]
2017-05-01 16:47 ` [PATCH 2/4] drm/dp: Combine two seq_printf() calls into one call " SF Markus Elfring
2017-05-01 16:48 ` [PATCH 3/4] drm/dp: Replace six seq_printf() calls by seq_puts() " SF Markus Elfring
2017-05-01 16:49 ` [PATCH 4/4] drm/dp: Adjust four checks for null pointers SF Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1493658687.6621.3.camel@perches.com \
--to=joe@perches.com \
--cc=airlied@linux.ie \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=elfring@users.sourceforge.net \
--cc=jani.nikula@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=seanpaul@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).