This utility function is almost useless (all it does is casts the result
of a strerror) but has a seriously confusing name. Over and over again
I have accidentally called it instead of ctf_errmsg, and hidden a
time-bomb for myself in a hard-to-test error-handling path: since
ctf_strerror is just a strerror wrapper, it cannot handle CTF errnos,
unlike ctf_errmsg. It's astonishingly lucky that none of these errors
have crept into any commits to date.
Fuse it into ctf_errmsg and drop it.
libctf/
* ctf-impl.h (ctf_strerror): Delete.
* ctf-subr.c (ctf_strerror): Likewise.
* ctf-error.c (ctf_errmsg): Stop using ctf_strerror: just use
strerror directly.
+2020-07-22 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-impl.h (ctf_strerror): Delete.
+ * ctf-subr.c (ctf_strerror): Likewise.
+ * ctf-error.c (ctf_errmsg): Stop using ctf_strerror: just use
+ strerror directly.
+
2020-07-22 Nick Alcock <nick.alcock@oracle.com>
* ctf-impl.c (ctf_file_t) <ctf_parent_unreffed>: New.
#include <ctf-impl.h>
#include <stddef.h>
+#include <string.h>
/* This construct is due to Bruno Haible: much thanks. */
if (error >= ECTF_BASE && (error - ECTF_BASE) < ECTF_NERR)
str = _ctf_errlist.str + _ctf_erridx[error - ECTF_BASE];
else
- str = ctf_strerror (error);
+ str = (const char *) strerror (error);
return (str ? str : "Unknown error");
}
extern void *ctf_realloc (ctf_file_t *, void *, size_t);
extern char *ctf_str_append (char *, const char *);
extern char *ctf_str_append_noerr (char *, const char *);
-extern const char *ctf_strerror (int);
extern ctf_id_t ctf_type_resolve_unsliced (ctf_file_t *, ctf_id_t);
extern int ctf_type_kind_unsliced (ctf_file_t *, ctf_id_t);
return acc;
}
-const char *
-ctf_strerror (int err)
-{
- return (const char *) (strerror (err));
-}
-
/* Set the CTF library client version to the specified version. If version is
zero, we just return the default library version number. */
int