lkml.org 
[lkml]   [2015]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf/tool: remove newline char when reading event scale and unit
Em Sun, May 31, 2015 at 11:36:23AM +0530, Madhavan Srinivasan escreveu:
> commit <fd979c013207> intruduced perf_event_sysfs_show function to display
> event_str value of an attr in kernel/event/core.c. But the function returns
> the value with a newline char. So, if a event also carries a event.unit file,
> when printing the counter data perf tool formatting goes for a spin.
> That is, because of the event unit, event name is printed in the newline
> because of perf_event_sysfs_show returns with a newline char.
>
> Now fixing perf core will break API, hencing proposing a fix in the perf tool.

Looks sensible, but please next time add spaces around operators, doing
it this time.

I.e., it should be:

scale[sret - 1] = '\0';

Thanks,

- Arnaldo

> + if (scale[sret-1] == '\n')
> + scale[sret-1] = '\0';
> + else
> + scale[sret] = '\0';
> +
> /*
> * save current locale
> */
> @@ -154,7 +158,10 @@ static int perf_pmu__parse_unit(struct perf_pmu_alias *alias, char *dir, char *n
>
> close(fd);
>
> - alias->unit[sret] = '\0';
> + if (alias->unit[sret-1] == '\n')
> + alias->unit[sret-1] = '\0';
> + else
> + alias->unit[sret] = '\0';
>
> return 0;
> error:
> --
> 1.9.1


\
 
 \ /
  Last update: 2015-06-01 16:01    [W:1.278 / U:1.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site