-const char *rrd_strerror(int err) {
- struct rrd_context *ctx = rrd_get_context();
- return strerror_r(err, ctx->lib_errstr, ctx->errlen);
+const char *rrd_strerror(
+ int err)
+{
+ rrd_context_t *ctx = rrd_get_context();
+
+ if (strerror_r(err, ctx->lib_errstr, sizeof(ctx->lib_errstr)))
+ return "strerror_r failed. sorry!";
+ else
+ return ctx->lib_errstr;