Re: [PATCH v4] tools/lib/traceevent: Separate out tep_strerror() for strerror_r() issues
From: Arnaldo Carvalho de Melo
Date: Mon Oct 08 2018 - 13:27:16 EST
Em Fri, Oct 05, 2018 at 12:18:16PM -0400, Steven Rostedt escreveu:
>
> From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>
>
> While working on having PowerTop use libtracevent as a shared object
> library, Tzvetomir hit "str_error_r not defined". This was added by commit
> c3cec9e68f12d ("tools lib traceevent: Use str_error_r()") because
> strerror_r() has two definitions, where one is GNU specific, and the other
> is XSI complient. The strerror_r() is in a wrapper str_error_r() to keep the
> code from having to worry about which compiler is being used.
>
> The problem is that str_error_r() is external to libtraceevent, and not part
> of the library. If it is used as a shared object then the tools using it
> will need to define that function. I do not want that function defined in
> libtraceevent itself, as it is out of scope for that library.
>
> As there's only a single instance of this call, and its in the traceevent
> library's own tep_strerror() function, we can copy what was done in perf,
> and create yet another external file that undefs _GNU_SOURCE to use the more
> portable version of the function. We don't need to worry about the errors
> that strerror_r() returns. If the buffer isn't big enough, we simply
> truncate it.
Thanks, applied, replacing the previous version since this is still not
in tip.
- Arnaldo