summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-08-09 11:35:20 (GMT)
committermidipix <writeonce@midipix.org>2018-08-09 11:35:20 (GMT)
commit009664542be578ce6f1f27bbed86ddee78401cf6 (patch)
tree95a2a875e0358a211d60524e555a984dead929da
parent633f4efee8aabdaa7e3827cfe1af15e4c7842bdc (diff)
downloadslibtool-009664542b.tar.bz2
slibtool-009664542b.tar.xz
internals: slbt_output_strerror(): use strerror_r(3) rather than strerror(3).
-rw-r--r--src/output/slbt_output_error.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/output/slbt_output_error.c b/src/output/slbt_output_error.c
index 15fbd70..d1cc8e5 100644
--- a/src/output/slbt_output_error.c
+++ b/src/output/slbt_output_error.c
@@ -35,7 +35,9 @@ static const char * slbt_output_error_header(const struct slbt_error_info * erri
return "distorted state";
}
-static const char * slbt_output_strerror(const struct slbt_error_info * erri)
+static const char * slbt_output_strerror(
+ const struct slbt_error_info * erri,
+ char (*errbuf)[256])
{
if (erri->eflags & SLBT_ERROR_CUSTOM)
return "flow error: unexpected condition or other";
@@ -50,14 +52,17 @@ static const char * slbt_output_strerror(const struct slbt_error_info * erri)
return "input error: string length exceeds buffer size.";
else
- return strerror(erri->esyscode);
+ return strerror_r(erri->esyscode,*errbuf,sizeof(*errbuf))
+ ? "internal error: strerror_r(3) call failed"
+ : *errbuf;
}
static int slbt_output_error_record_plain(
const struct slbt_driver_ctx * dctx,
const struct slbt_error_info * erri)
{
- const char * errdesc = slbt_output_strerror(erri);
+ char errbuf[256];
+ const char * errdesc = slbt_output_strerror(erri,&errbuf);
if (slbt_dprintf(slbt_driver_fderr(dctx),
"%s: %s %s(), line %d%s%s.\n",
@@ -76,7 +81,8 @@ static int slbt_output_error_record_annotated(
const struct slbt_driver_ctx * dctx,
const struct slbt_error_info * erri)
{
- const char * errdesc = slbt_output_strerror(erri);
+ char errbuf[256];
+ const char * errdesc = slbt_output_strerror(erri,&errbuf);
if (slbt_dprintf(
slbt_driver_fderr(dctx),
@@ -100,7 +106,7 @@ static int slbt_output_error_record_annotated(
strlen(errdesc) ? ": " : "",
aclr_bold,
- slbt_output_strerror(erri),
+ errdesc,
aclr_reset) < 0)
return -1;