aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libctf/ctf-hash.c7
-rw-r--r--libctf/ctf-open.c20
2 files changed, 16 insertions, 11 deletions
diff --git a/libctf/ctf-hash.c b/libctf/ctf-hash.c
index 7f291e3..cd74734 100644
--- a/libctf/ctf-hash.c
+++ b/libctf/ctf-hash.c
@@ -256,7 +256,7 @@ ctf_dynhash_insert (ctf_dynhash_t *hp, void *key, void *value)
key_free, value_free);
if (!slot)
- return errno;
+ return -errno;
/* Keep track of the owner, so that the del function can get at the key_free
and value_free functions. Only do this if one of those functions is set:
@@ -786,7 +786,7 @@ ctf_dynhash_insert_type (ctf_dict_t *fp, ctf_dynhash_t *hp, uint32_t type,
return EINVAL;
if ((str = ctf_strptr_validate (fp, name)) == NULL)
- return ctf_errno (fp);
+ return ctf_errno (fp) * -1;
if (str[0] == '\0')
return 0; /* Just ignore empty strings on behalf of caller. */
@@ -795,6 +795,9 @@ ctf_dynhash_insert_type (ctf_dict_t *fp, ctf_dynhash_t *hp, uint32_t type,
(void *) (ptrdiff_t) type)) == 0)
return 0;
+ /* ctf_dynhash_insert returns a negative error value: negate it for
+ ctf_set_errno. */
+ ctf_set_errno (fp, err * -1);
return err;
}
diff --git a/libctf/ctf-open.c b/libctf/ctf-open.c
index 3f62498..942a53a 100644
--- a/libctf/ctf-open.c
+++ b/libctf/ctf-open.c
@@ -681,6 +681,8 @@ init_static_types_internal (ctf_dict_t *fp, ctf_header_t *cth,
the latest supported representation in the process, if needed, and if this
recension of libctf supports upgrading.
+ Returns zero on success and a *positive* ECTF_* or errno value on error.
+
This is a wrapper to simplify memory allocation on error in the _internal
function that does all the actual work. */
@@ -886,7 +888,7 @@ init_static_types_internal (ctf_dict_t *fp, ctf_header_t *cth,
LCTF_INDEX_TO_TYPE (fp, id, child),
tp->ctt_name);
if (err != 0)
- return err;
+ return err * -1;
}
break;
}
@@ -905,7 +907,7 @@ init_static_types_internal (ctf_dict_t *fp, ctf_header_t *cth,
LCTF_INDEX_TO_TYPE (fp, id, child),
tp->ctt_name);
if (err != 0)
- return err;
+ return err * -1;
break;
case CTF_K_STRUCT:
@@ -920,7 +922,7 @@ init_static_types_internal (ctf_dict_t *fp, ctf_header_t *cth,
tp->ctt_name);
if (err != 0)
- return err;
+ return err * -1;
break;
@@ -936,7 +938,7 @@ init_static_types_internal (ctf_dict_t *fp, ctf_header_t *cth,
tp->ctt_name);
if (err != 0)
- return err;
+ return err * -1;
break;
case CTF_K_ENUM:
@@ -949,14 +951,14 @@ init_static_types_internal (ctf_dict_t *fp, ctf_header_t *cth,
tp->ctt_name);
if (err != 0)
- return err;
+ return err * -1;
/* Remember all enums for later rescanning. */
err = ctf_dynset_insert (all_enums, (void *) (ptrdiff_t)
LCTF_INDEX_TO_TYPE (fp, id, child));
if (err != 0)
- return err;
+ return err * -1;
break;
}
@@ -968,7 +970,7 @@ init_static_types_internal (ctf_dict_t *fp, ctf_header_t *cth,
LCTF_INDEX_TO_TYPE (fp, id, child),
tp->ctt_name);
if (err != 0)
- return err;
+ return err * -1;
break;
case CTF_K_FORWARD:
@@ -985,7 +987,7 @@ init_static_types_internal (ctf_dict_t *fp, ctf_header_t *cth,
err = ctf_dynhash_insert_type (fp, h, LCTF_INDEX_TO_TYPE (fp, id, child),
tp->ctt_name);
if (err != 0)
- return err;
+ return err * -1;
}
break;
}
@@ -1010,7 +1012,7 @@ init_static_types_internal (ctf_dict_t *fp, ctf_header_t *cth,
LCTF_INDEX_TO_TYPE (fp, id, child),
tp->ctt_name);
if (err != 0)
- return err;
+ return err * -1;
break;
default:
ctf_err_warn (fp, 0, ECTF_CORRUPT,