public inbox for powertop@lists.linux.dev
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp at gmail.com>
To: powertop@lists.01.org
Subject: [Powertop] [PATCH] event-parse: Add compatibility for non GNU strerror_r
Date: Tue, 04 Jun 2019 12:04:47 -0700	[thread overview]
Message-ID: <20190604190447.8561-1-rosenp@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 848 bytes --]

Needed for libraries like musl that do not implement the GNU variant.

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);
+#endif
 		return 0;
 	}
 
-- 
2.17.1


             reply	other threads:[~2019-06-04 19:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04 19:04 Rosen Penev [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-06-05  6:53 [Powertop] [PATCH] event-parse: Add compatibility for non GNU strerror_r Magnus Fromreide
2019-06-07  1:24 Rosen Penev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190604190447.8561-1-rosenp@gmail.com \
    --to=powertop@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox