From 7e1368b58f37f89152c5811eab98f4667d807b04 Mon Sep 17 00:00:00 2001 From: Nick Alcock Date: Fri, 12 Apr 2024 14:46:00 +0100 Subject: libctf: don't pass errno into ctf_err_warn so often The libctf-internal warning function ctf_err_warn() can be passed a libctf errno as a parameter, and will add its textual errmsg form to the passed-in error message. But if there is an error on the fp already, and this is specifically an error and not a warning, ctf_err_warn() will print the error out regardless: there's no need to pass in anything but 0. There are still a lot of places where we do ctf_err_warn (fp, 0, EFOO, ...); return ctf_set_errno (fp, 0, EFOO); I've left all of those alone, because fixing it makes the code a bit longer: but fixing the cases where no return is involved and the error has just been set on the fp itself costs nothing and reduces redundancy a bit. libctf/ * ctf-dedup.c (ctf_dedup_walk_output_mapping): Drop the errno arg. (ctf_dedup_emit): Likewise. (ctf_dedup_type_mapping): Likewise. * ctf-link.c (ctf_create_per_cu): Likewise. (ctf_link_deduplicating_close_inputs): Likewise. (ctf_link_deduplicating_one_symtypetab): Likewise. (ctf_link_deduplicating_per_cu): Likewise. * ctf-lookup.c (ctf_lookup_symbol_idx): Likewise. * ctf-subr.c (ctf_assert_fail_internal): Likewise. --- libctf/ctf-subr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libctf/ctf-subr.c') diff --git a/libctf/ctf-subr.c b/libctf/ctf-subr.c index ecc6884..deb9e0b 100644 --- a/libctf/ctf-subr.c +++ b/libctf/ctf-subr.c @@ -340,7 +340,7 @@ void ctf_assert_fail_internal (ctf_dict_t *fp, const char *file, size_t line, const char *exprstr) { - ctf_err_warn (fp, 0, ECTF_INTERNAL, _("%s: %lu: libctf assertion failed: %s"), - file, (long unsigned int) line, exprstr); ctf_set_errno (fp, ECTF_INTERNAL); + ctf_err_warn (fp, 0, 0, _("%s: %lu: libctf assertion failed: %s"), + file, (long unsigned int) line, exprstr); } -- cgit v1.1