aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-subr.c
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2020-11-20 13:34:04 +0000
committerNick Alcock <nick.alcock@oracle.com>2020-11-20 13:34:12 +0000
commit8f235c90a287ee961153dd94f5ca28b033ebb668 (patch)
treed43c3ab0cf3fae2b62081fa92e1c3f534efdf205 /libctf/ctf-subr.c
parent97a2a623d0193dbfc92d92545b63aaffd6099272 (diff)
downloadgdb-8f235c90a287ee961153dd94f5ca28b033ebb668.zip
gdb-8f235c90a287ee961153dd94f5ca28b033ebb668.tar.gz
gdb-8f235c90a287ee961153dd94f5ca28b033ebb668.tar.bz2
libctf: error-handling fixes
libctf/ChangeLog 2020-11-20 Nick Alcock <nick.alcock@oracle.com> * ctf-create.c (ctf_dtd_insert): Set ENOMEM on the dict if out of memory. (ctf_dvd_insert): Likewise. (ctf_add_function): Report ECTF_RDONLY if this dict is not writable. * ctf-subr.c (ctf_err_warn): Only debug-dump passed-in warnings if the passed-in error code is nonzero: the error on the dict for warnings may relate to a previous error.
Diffstat (limited to 'libctf/ctf-subr.c')
-rw-r--r--libctf/ctf-subr.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libctf/ctf-subr.c b/libctf/ctf-subr.c
index c902494..a4d445a 100644
--- a/libctf/ctf-subr.c
+++ b/libctf/ctf-subr.c
@@ -225,10 +225,12 @@ ctf_err_warn (ctf_dict_t *fp, int is_warning, int err,
}
va_end (alist);
- /* Include the error code only if there is one, and if this is not a warning.
+ /* Include the error code only if there is one; if this is not a warning,
+ only use the error code if it was explicitly passed and is nonzero.
(Warnings may not have a meaningful error code, since the warning may not
lead to unwinding up to the user.) */
- if (!is_warning && (err != 0 || (fp && ctf_errno (fp) != 0)))
+ if ((!is_warning && (err != 0 || (fp && ctf_errno (fp) != 0)))
+ || (is_warning && err != 0))
ctf_dprintf ("%s: %s (%s)\n", is_warning ? _("error") : _("warning"),
cew->cew_text, err != 0 ? ctf_errmsg (err)
: ctf_errmsg (ctf_errno (fp)));