Commit e2aa8732 authored by Dave Jones's avatar Dave Jones

[CPUFREQ] Clean up longhaul's speed pretty-printer

Getting ready to move to core cpufreq.
- Use snprintf
- Remove unnecessary nesting improving readability.
Signed-off-by: default avatarDave Jones <davej@redhat.com>
parent 8cbe0169
...@@ -77,13 +77,17 @@ static char speedbuffer[8]; ...@@ -77,13 +77,17 @@ static char speedbuffer[8];
static char *print_speed(int speed) static char *print_speed(int speed)
{ {
if (speed > 1000) { if (speed < 1000) {
if (speed%1000 == 0) snprintf(speedbuffer, sizeof(speedbuffer),"%dMHz", speed);
sprintf (speedbuffer, "%dGHz", speed/1000); return speedbuffer;
else }
sprintf (speedbuffer, "%d.%dGHz", speed/1000, (speed%1000)/100);
} else if (speed%1000 == 0)
sprintf (speedbuffer, "%dMHz", speed); snprintf(speedbuffer, sizeof(speedbuffer),
"%dGHz", speed/1000);
else
snprintf(speedbuffer, sizeof(speedbuffer),
"%d.%dGHz", speed/1000, (speed%1000)/100);
return speedbuffer; return speedbuffer;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment