summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-08-09 06:45:58 -0400
committermidipix <writeonce@midipix.org>2018-08-09 06:45:58 -0400
commit65a0ef6a1e1c2424a4560e9c531e429bbfaaf762 (patch)
tree744762c42fbdceffa73823e32a03da65825dc07d
parent69302dc003c0e55dc9b5ce67b9bb3f2ad31d5284 (diff)
downloadsofort-65a0ef6a1e1c2424a4560e9c531e429bbfaaf762.tar.bz2
sofort-65a0ef6a1e1c2424a4560e9c531e429bbfaaf762.tar.xz
internals: sfrt_output_strerror(): use strerror_r(3) rather than strerror(3).
-rw-r--r--src/output/sfrt_output_error.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/output/sfrt_output_error.c b/src/output/sfrt_output_error.c
index 46b637b..155e009 100644
--- a/src/output/sfrt_output_error.c
+++ b/src/output/sfrt_output_error.c
@@ -52,7 +52,9 @@ static const char * sfrt_output_unit_header(const struct sfrt_error_info * erri)
return "while parsing";
}
-static const char * sfrt_output_strerror(const struct sfrt_error_info * erri)
+static const char * sfrt_output_strerror(
+ const struct sfrt_error_info * erri,
+ char (*errbuf)[256])
{
if (erri->eflags & SFRT_ERROR_CUSTOM)
return ((erri->elibcode < 0) || (erri->elibcode >= SFRT_ERR_CAP))
@@ -69,7 +71,9 @@ static const char * sfrt_output_strerror(const struct sfrt_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 sfrt_output_error_record_plain(
@@ -77,7 +81,8 @@ static int sfrt_output_error_record_plain(
const struct sfrt_error_info * erri)
{
const char * epath;
- const char * errdesc = sfrt_output_strerror(erri);
+ char errbuf[256];
+ const char * errdesc = sfrt_output_strerror(erri,&errbuf);
int fderr = sfrt_driver_fderr(dctx);
epath = erri->euctx
@@ -112,7 +117,8 @@ static int sfrt_output_error_record_annotated(
const struct sfrt_error_info * erri)
{
const char * epath;
- const char * errdesc = sfrt_output_strerror(erri);
+ char errbuf[256];
+ const char * errdesc = sfrt_output_strerror(erri,&errbuf);
int fderr = sfrt_driver_fderr(dctx);
epath = erri->euctx
@@ -159,7 +165,7 @@ static int sfrt_output_error_record_annotated(
strlen(errdesc) ? ": " : "",
aclr_bold,
- sfrt_output_strerror(erri),
+ errdesc,
aclr_reset) < 0)
return -1;