Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Aleksandar Markovic <aleksandar.markovic@rt-rk.com>,
	linux-mips@linux-mips.org
Cc: Dragan Cecavac <dragan.cecavac@mips.com>,
	Aleksandar Markovic <aleksandar.markovic@mips.com>,
	Douglas Leung <douglas.leung@mips.com>,
	Goran Ferenc <goran.ferenc@mips.com>,
	James Hogan <james.hogan@mips.com>,
	James Hogan <jhogan@kernel.org>,
	linux-kernel@vger.kernel.org,
	"Maciej W. Rozycki" <macro@linux-mips.org>,
	Miodrag Dinic <miodrag.dinic@mips.com>,
	Paul Burton <paul.burton@imgtec.com>,
	Paul Burton <paul.burton@mips.com>,
	Petar Jovanovic <petar.jovanovic@mips.com>,
	Raghu Gandham <raghu.gandham@mips.com>,
	Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [PATCH] MIPS: kernel: proc: Remove spurious white space in cpuinfo
Date: Fri, 20 Oct 2017 08:17:28 -0700	[thread overview]
Message-ID: <1508512648.30181.1.camel@perches.com> (raw)
In-Reply-To: <1508509203-30661-1-git-send-email-aleksandar.markovic@rt-rk.com>

On Fri, 2017-10-20 at 16:20 +0200, Aleksandar Markovic wrote:
> From: Dragan Cecavac <dragan.cecavac@mips.com>
> 
> Remove unnecessary space from FPU info segment of /proc/cpuinfo.
> 
> Signed-off-by: Dragan Cecavac <dragan.cecavac@mips.com>
> Signed-off-by: Aleksandar Markovic <aleksandar.markovic@mips.com>
> ---
>  arch/mips/kernel/proc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c
> index bd9bf52..99f9aab 100644
> --- a/arch/mips/kernel/proc.c
> +++ b/arch/mips/kernel/proc.c
> @@ -58,7 +58,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
>  
>  	seq_printf(m, "processor\t\t: %ld\n", n);
>  	sprintf(fmt, "cpu model\t\t: %%s V%%d.%%d%s\n",
> -		      cpu_data[n].options & MIPS_CPU_FPU ? "  FPU V%d.%d" : "");
> +		      cpu_data[n].options & MIPS_CPU_FPU ? " FPU V%d.%d" : "");
>  	seq_printf(m, fmt, __cpu_name[n],
>  		      (version >> 4) & 0x0f, version & 0x0f,
>  		      (fp_vers >> 4) & 0x0f, fp_vers & 0x0f);

That's somewhat unpleasant code as it formats a fmt string
and the compiler can not verify fmt and args.

Perhaps something like the below is preferable:
---
 arch/mips/kernel/proc.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c
index bd9bf528f19b..dda4af8fcd7b 100644
--- a/arch/mips/kernel/proc.c
+++ b/arch/mips/kernel/proc.c
@@ -38,7 +38,6 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 	unsigned long n = (unsigned long) v - 1;
 	unsigned int version = cpu_data[n].processor_id;
 	unsigned int fp_vers = cpu_data[n].fpu_id;
-	char fmt [64];
 	int i;
 
 #ifdef CONFIG_SMP
@@ -57,11 +56,13 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 	}
 
 	seq_printf(m, "processor\t\t: %ld\n", n);
-	sprintf(fmt, "cpu model\t\t: %%s V%%d.%%d%s\n",
-		      cpu_data[n].options & MIPS_CPU_FPU ? "  FPU V%d.%d" : "");
-	seq_printf(m, fmt, __cpu_name[n],
-		      (version >> 4) & 0x0f, version & 0x0f,
+	seq_printf(m, "cpu model\t\t: %s V%d.%d",
+		   __cpu_name[n], (version >> 4) & 0x0f, version & 0x0f);
+	if (cpu_data[n].options & MIPS_CPU_FPU)
+		seq_printf(m, " FPU V%d.%d\n",
 		      (fp_vers >> 4) & 0x0f, fp_vers & 0x0f);
+	else
+		seq_printf(m, "\n");
 	seq_printf(m, "BogoMIPS\t\t: %u.%02u\n",
 		      cpu_data[n].udelay_val / (500000/HZ),
 		      (cpu_data[n].udelay_val / (5000/HZ)) % 100);
@@ -143,10 +144,13 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 		seq_printf(m, "VP\t\t\t: %d\n", cpu_vpe_id(&cpu_data[n]));
 #endif
 
-	sprintf(fmt, "VCE%%c exceptions\t\t: %s\n",
-		      cpu_has_vce ? "%u" : "not available");
-	seq_printf(m, fmt, 'D', vced_count);
-	seq_printf(m, fmt, 'I', vcei_count);
+	if (cpu_has_vce) {
+		seq_printf(m, "VCE%c exceptions\t\t: %u\n", 'D', vced_count);
+		seq_printf(m, "VCE%c exceptions\t\t: %u\n", 'I', vcei_count);
+	} else {
+		seq_printf(m, "VCE%c exceptions\t\t: not available\n", 'D');
+		seq_printf(m, "VCE%c exceptions\t\t: not available\n", 'I');
+	}
 
 	proc_cpuinfo_notifier_args.m = m;
 	proc_cpuinfo_notifier_args.n = n;

  reply	other threads:[~2017-10-20 15:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-20 14:20 [PATCH] MIPS: kernel: proc: Remove spurious white space in cpuinfo Aleksandar Markovic
2017-10-20 15:17 ` Joe Perches [this message]
2017-10-20 20:52   ` Maciej W. Rozycki
2017-10-20 20:52     ` Maciej W. Rozycki
2017-10-20 21:08     ` Joe Perches
2017-10-20 21:46       ` Maciej W. Rozycki
2017-10-20 21:46         ` Maciej W. Rozycki
2017-10-20 23:09         ` Joe Perches
2017-10-20 20:47 ` Maciej W. Rozycki
2017-10-20 20:47   ` Maciej W. Rozycki
2017-10-20 23:56   ` David Daney
2017-10-23  7:54     ` Miodrag Dinic

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=1508512648.30181.1.camel@perches.com \
    --to=joe@perches.com \
    --cc=aleksandar.markovic@mips.com \
    --cc=aleksandar.markovic@rt-rk.com \
    --cc=douglas.leung@mips.com \
    --cc=dragan.cecavac@mips.com \
    --cc=goran.ferenc@mips.com \
    --cc=james.hogan@mips.com \
    --cc=jhogan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=macro@linux-mips.org \
    --cc=miodrag.dinic@mips.com \
    --cc=paul.burton@imgtec.com \
    --cc=paul.burton@mips.com \
    --cc=petar.jovanovic@mips.com \
    --cc=raghu.gandham@mips.com \
    --cc=ralf@linux-mips.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