summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-08-09 07:53:47 -0400
committermidipix <writeonce@midipix.org>2018-08-09 07:53:47 -0400
commita8b6550a52599f4e652f358ecf1da924a594c398 (patch)
tree49fa63c60f33291056d803e8f344abe64557b35c /src
parentc44aca813ce341a37492947f469a4eaedf570a9c (diff)
downloadapimagic-a8b6550a52599f4e652f358ecf1da924a594c398.tar.bz2
apimagic-a8b6550a52599f4e652f358ecf1da924a594c398.tar.xz
internals: amgc_output_strerror(): use strerror_r(3) rather than strerror(3).
Diffstat (limited to 'src')
-rw-r--r--src/output/amgc_output_error.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/output/amgc_output_error.c b/src/output/amgc_output_error.c
index f76d068..f9b475b 100644
--- a/src/output/amgc_output_error.c
+++ b/src/output/amgc_output_error.c
@@ -52,7 +52,9 @@ static const char * amgc_output_unit_header(const struct amgc_error_info * erri)
return "while parsing";
}
-static const char * amgc_output_strerror(const struct amgc_error_info * erri)
+static const char * amgc_output_strerror(
+ const struct amgc_error_info * erri,
+ char (*errbuf)[256])
{
if (erri->eflags & AMGC_ERROR_CUSTOM)
return ((erri->elibcode < 0) || (erri->elibcode >= AMGC_ERR_CAP))
@@ -69,7 +71,9 @@ static const char * amgc_output_strerror(const struct amgc_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 amgc_output_error_record_plain(
@@ -77,8 +81,10 @@ static int amgc_output_error_record_plain(
const struct amgc_error_info * erri)
{
const char * epath;
- const char * errdesc = amgc_output_strerror(erri);
+ char errbuf[256];
+
int fderr = amgc_driver_fderr(dctx);
+ const char * errdesc = amgc_output_strerror(erri,&errbuf);
epath = erri->euctx
? *erri->euctx->path
@@ -112,8 +118,10 @@ static int amgc_output_error_record_annotated(
const struct amgc_error_info * erri)
{
const char * epath;
- const char * errdesc = amgc_output_strerror(erri);
+ char errbuf[256];
+
int fderr = amgc_driver_fderr(dctx);
+ const char * errdesc = amgc_output_strerror(erri,&errbuf);
epath = erri->euctx
? *erri->euctx->path
@@ -159,7 +167,7 @@ static int amgc_output_error_record_annotated(
strlen(errdesc) ? ": " : "",
aclr_bold,
- amgc_output_strerror(erri),
+ errdesc,
aclr_reset) < 0)
return -1;