summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2026-03-11 11:00:35 +0200
committerLen Brown <len.brown@intel.com>2026-04-22 11:31:57 -0400
commit092b76a3253fdd476e6d0626a094bf7b632f8eef (patch)
tree96717ce54c4c4e17ad97e2f5afa6133219597d8b /tools
parent08e11edd0e63b72651ed5eb9142430d1ca764923 (diff)
tools/power turbostat: Cleanup print helper functions
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/power/x86/turbostat/turbostat.c19
1 files 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)