On Tue, Jun 04, 2019 at 12:04:47PM -0700, Rosen Penev wrote:
Needed for libraries like musl that do not implement the GNU variant.
This patch seems curious.
Signed-off-by: Rosen Penev <rosenp(a)gmail.com>
---
traceevent/event-parse.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/traceevent/event-parse.c b/traceevent/event-parse.c
index 5a717a0..1f7eb80 100644
--- a/traceevent/event-parse.c
+++ b/traceevent/event-parse.c
@@ -5121,12 +5121,17 @@ int pevent_strerror(struct pevent *pevent __maybe_unused,
const char *msg;
if (errnum >= 0) {
+#if defined(__GLIBC__)
msg = strerror_r(errnum, buf, buflen);
if (msg != buf) {
size_t len = strlen(msg);
memcpy(buf, msg, min(buflen - 1, len));
*(buf + min(buflen - 1, len)) = '\0';
}
+#else
+ if (strerror_r(errnum, buf, buflen))
+ snprintf(buf, buflen, "errnum %i", errnum);
Was
if (a human readable response is returned from strerror_r)
clobber it with a numeric version of the error
really what you wanted to achieve?
I would rather expect something like
if (errnum >= 0) {
msg = strerror_r(errnum, buf, buflen);
#if defined(__GLIBC__)
if (msg != buf)
strlcpy(buf, msg, buflen);
#endif
}
where the #ifdef ends up as a pure optimization if strerror_r is the XSI version.
/MF
+#endif
return 0;
}
--
2.17.1
_______________________________________________
PowerTop mailing list
PowerTop(a)lists.01.org
https://lists.01.org/mailman/listinfo/powertop