diff options
author | midipix <writeonce@midipix.org> | 2018-08-09 07:51:51 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-08-09 07:51:51 -0400 |
commit | efc472bc14a9a8abe14d69244fa1d8e291b41c0b (patch) | |
tree | e5277b6d2f45b6c15f3702cb4f7ebcb000d0f5ca | |
parent | 85cfaaf90eed065df038384a2874f60cce395e47 (diff) | |
download | mdso-efc472bc14a9a8abe14d69244fa1d8e291b41c0b.tar.bz2 mdso-efc472bc14a9a8abe14d69244fa1d8e291b41c0b.tar.xz |
internals: mdso_output_strerror(): use strerror_r(3) rather than strerror(3).
-rw-r--r-- | src/output/mdso_output_error.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/output/mdso_output_error.c b/src/output/mdso_output_error.c index 9ae5e30..6a382b7 100644 --- a/src/output/mdso_output_error.c +++ b/src/output/mdso_output_error.c @@ -62,7 +62,9 @@ static const char * mdso_output_unit_header(const struct mdso_error_info * erri) return "while parsing"; } -static const char * mdso_output_strerror(const struct mdso_error_info * erri) +static const char * mdso_output_strerror( + const struct mdso_error_info * erri, + char (*errbuf)[256]) { if (erri->eflags & MDSO_ERROR_CUSTOM) return ((erri->elibcode < 0) || (erri->elibcode >= MDSO_ERR_CAP)) @@ -79,7 +81,9 @@ static const char * mdso_output_strerror(const struct mdso_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 mdso_output_error_record_plain( @@ -87,8 +91,10 @@ static int mdso_output_error_record_plain( const struct mdso_error_info * erri) { const char * epath; - const char * errdesc = mdso_output_strerror(erri); + char errbuf[256]; + int fderr = mdso_driver_fderr(dctx); + const char * errdesc = mdso_output_strerror(erri,&errbuf); epath = erri->euctx ? *erri->euctx->path @@ -122,8 +128,10 @@ static int mdso_output_error_record_annotated( const struct mdso_error_info * erri) { const char * epath; - const char * errdesc = mdso_output_strerror(erri); + char errbuf[256]; + int fderr = mdso_driver_fderr(dctx); + const char * errdesc = mdso_output_strerror(erri,&errbuf); epath = erri->euctx ? *erri->euctx->path @@ -169,7 +177,7 @@ static int mdso_output_error_record_annotated( strlen(errdesc) ? ": " : "", aclr_bold, - mdso_output_strerror(erri), + errdesc, aclr_reset) < 0) return -1; |