From: Len Brown <lenb@kernel.org>
To: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 06/13] tools/power turbostat: Cleanup print helper functions
Date: Sat, 25 Apr 2026 14:42:09 -0400 [thread overview]
Message-ID: <092b76a3253fdd476e6d0626a094bf7b632f8eef.1777141988.git.len.brown@intel.com> (raw)
In-Reply-To: <feffac1874820d501e51cd8dcee697063b792c82.1777141988.git.len.brown@intel.com>
From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Make printer helper functions more readable by factoring
out a local 'sep' variable.
Remove the redundant parentheses around sprintf() calls.
Remove an unnecessary cast to "unsigned int" by using the '%08llx' instead
of '%08x'.
No functional changes.
[lenb: fix typos, simplify]
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
tools/power/x86/turbostat/turbostat.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index e609272ed80b..624f54ee1ad8 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -2866,31 +2866,38 @@ void bic_lookup(cpu_set_t *ret_set, char *name_list, enum show_hide_mode mode)
static inline int print_name(int width, int *printed, char *delim, char *name, enum counter_type type, enum counter_format format)
{
UNUSED(type);
+ char *sep = (*printed)++ ? delim : "";
if (format == FORMAT_RAW && width >= 64)
- return (sprintf(outp, "%s%-8s", ((*printed)++ ? delim : ""), name));
+ return sprintf(outp, "%s%-8s", sep, name);
else
- return (sprintf(outp, "%s%s", ((*printed)++ ? delim : ""), name));
+ return sprintf(outp, "%s%s", sep, name);
}
static inline int print_hex_value(int width, int *printed, char *delim, unsigned long long value)
{
+ char *sep = (*printed)++ ? delim : "";
+
if (width <= 32)
- return (sprintf(outp, "%s%08x", ((*printed)++ ? delim : ""), (unsigned int)value));
+ return sprintf(outp, "%s%08llx", sep, value);
else
- return (sprintf(outp, "%s%016llx", ((*printed)++ ? delim : ""), value));
+ return sprintf(outp, "%s%016llx", sep, value);
}
static inline int print_decimal_value(int width, int *printed, char *delim, unsigned long long value)
{
+ char *sep = (*printed)++ ? delim : "";
+
UNUSED(width);
- return (sprintf(outp, "%s%lld", ((*printed)++ ? delim : ""), value));
+ return sprintf(outp, "%s%lld", sep, value);
}
static inline int print_float_value(int *printed, char *delim, double value)
{
- return (sprintf(outp, "%s%0.2f", ((*printed)++ ? delim : ""), value));
+ char *sep = (*printed)++ ? delim : "";
+
+ return sprintf(outp, "%s%0.2f", sep, value);
}
void print_header(char *delim)
--
2.45.2
next prev parent reply other threads:[~2026-04-25 18:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-25 18:42 [PATCH 0/13] Power Utilities update for Linux-7.1 Len Brown
2026-04-25 18:42 ` [PATCH 01/13] tools/power/x86: Add SOC slider and platform profile support Len Brown
2026-04-25 18:42 ` [PATCH 02/13] tools/power turbostat: Fix AMD RAPL regression on big systems Len Brown
2026-04-25 18:42 ` [PATCH 03/13] tools/power turbostat: Fix unrecognized option '-P' Len Brown
2026-04-25 18:42 ` [PATCH 04/13] tools/power turbostat: Fix --cpu-set 0 regression on HT systems Len Brown
2026-04-25 18:42 ` [PATCH 05/13] tools/power turbostat: Fix --cpu-set 1 " Len Brown
2026-04-25 18:42 ` Len Brown [this message]
2026-04-25 18:42 ` [PATCH 07/13] tools/power turbostat: Print core_id and apic_id in hex Len Brown
2026-04-25 18:42 ` [PATCH 08/13] tools/power turbostat: Show module_id column Len Brown
2026-04-25 18:42 ` [PATCH 09/13] tools/power turbostat: Process HT siblings in CPU order Len Brown
2026-04-25 18:42 ` [PATCH 10/13] tools/power turbostat: v2026.04.21 Len Brown
2026-04-25 18:42 ` [PATCH 11/13] tools/power x86_energy_perf_policy: Enhances SoC Slider related checks Len Brown
2026-04-25 18:42 ` [PATCH 12/13] tools/power x86_energy_perf_policy.8: Document SoC Slider Options Len Brown
2026-04-25 18:42 ` [PATCH 13/13] tools/power x86_energy_perf_policy: Version 2026.04.25 Len Brown
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=092b76a3253fdd476e6d0626a094bf7b632f8eef.1777141988.git.len.brown@intel.com \
--to=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.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
all inboxes | Powered by JetHome®