From: Nick Alcock <nick.alcock@oracle.com>
To: "Torbjörn SVENSSON" <torbjorn.svensson@foss.st.com>
Cc: <binutils@sourceware.org>, <nick.alcock@oracle.com>,
<amodra@gmail.com>, Yvan ROUX <yvan.roux@foss.st.com>
Subject: Re: [PATCH v5] libctf: Sanitize error types for PR 30836
Date: Mon, 09 Oct 2023 11:27:54 +0100 [thread overview]
Message-ID: <8734ykks45.fsf@esperi.org.uk> (raw)
In-Reply-To: <20231005083920.2676339-1-torbjorn.svensson@foss.st.com> (=?utf-8?Q?=22Torbj=C3=B6rn?= SVENSSON"'s message of "Thu, 5 Oct 2023 10:39:21 +0200")
On 5 Oct 2023, Torbjörn SVENSSON verbalised:
> v1 -> v2:
> Changed all functions with signed interger return type to return -1 based on
> comment from Alan.
(integer)
> v2 -> v3:
> Added ctf_set_errno_signed function to return a signed -1 value based on
> comment from Nick.
>
> v3 -> v4:
> - Moved ctf_set_errno_signed function to ctf-inlines.h, renamed it to
> ctf_set_int_errno and converted it to an inline function.
> - Moved ctf_set_errno function to ctf-inlines.h, renamed it to
> ctf_set_type_errno, changed return type to ctf_id_t and converted it to an
> inline function.
> - Updated the changelog entry in the commit message. Is this list really
> required? I don't think it give much information in this patch and 'git log'
> have mixed commits (some have the entry while others don't).
>
> v4 -> v5:
> Updated in accordance with comments from Nick.
> - Changed return type to void for ctf_set_errno.
> - Inline the return on every call to ctf_set_errno.
> - Merged ctf_set_int_errno and ctf_set_type_errno into ctf_set_errno.
> - Droped log entry as it's too many places with this change to make it
> readable.
> - Corrected a few places where -1 was returned where it should have been
> CTF_ERR.
>
>
> @Nick: Can you please try this is in your test bench and let me know if it's
> ok for trunk?
... I don't understand why we even have a ctf_set_errno any more. It
does nothing that fp->ctf_errno = FOO doesn't. (Is it just to keep the
commit size down? If so, that seems sensible: either of us can follow it
up with a patch removing ctf_set_errno entirely as redundant.)
Alternatively -- and I promise I'll stop constantly changing my mind in
a moment! it's just this patch seems likely to be pervasive enough that
I'd like to get it right first time -- since nearly all functions in
ctf-api.h return either ctf_id_t or int, we could just do what you did
in the *previous* patch and have two functions for those:
ctf_id_t ctf_set_typed_errno()
for functions returning ctf_id_t, and
int ctf_set_errno()
for functions returning int. The original problem, those few functions
that return other types, would still need to do things "by hand",
probably by setting fp->ctf_errno before returning.
I *think* that would work for all callers and let people just compare
with CTF_ERR for ctf_id_t and unsigned types and with < 0 for all the
others, like they're suposed to be.
That way about half the call sites could stay unchanged, most of the
rest only need one a _typed_ added, and hopefully it's easier to grasp?
plus there is less need to introduce new { ... } just for the sake of
setting the errno value.
We still have a potential problem with functions returning unsigned
types that might be wider than ctf_id_t, since CTF_ERR isn't suitable to
compare against to detect errors for those; thankfully the only one of
those is ctf_archive_count, which cannot return errors :)
Again, really sorry I keep chopping and changing like this, but every
time you do something I think of a possible better way. (Unless I've
missed something, which I probably have.)
next prev parent reply other threads:[~2023-10-09 10:28 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-24 11:32 [PATCH] libctf: ctf_member_next needs to return (ssize_t)-1 on error Torbjörn SVENSSON
2023-08-25 2:22 ` Alan Modra
2023-08-25 16:53 ` [PATCH v2] " Torbjörn SVENSSON
2023-08-30 8:34 ` Torbjorn SVENSSON
2023-08-30 9:39 ` Alan Modra
2023-09-07 12:10 ` Nick Alcock
2023-09-08 12:58 ` Torbjorn SVENSSON
2023-09-12 14:23 ` Nick Alcock
2023-09-12 18:44 ` Torbjorn SVENSSON
2023-09-13 9:57 ` [PATCH v3] " Torbjörn SVENSSON
2023-09-13 18:37 ` Nick Alcock
2023-09-13 20:20 ` Torbjorn SVENSSON
2023-09-20 17:44 ` Torbjorn SVENSSON
2023-09-26 14:51 ` Nick Alcock
2023-09-26 17:28 ` [PATCH v4] " Torbjörn SVENSSON
2023-09-26 17:49 ` [PATCH v3] " Torbjorn SVENSSON
2023-09-28 16:41 ` Nick Alcock
2023-09-29 12:11 ` Torbjorn SVENSSON
2023-10-02 10:57 ` Nick Alcock
2023-10-03 12:59 ` Torbjorn SVENSSON
2023-10-03 20:53 ` Nick Alcock
2023-10-05 8:39 ` [PATCH v5] libctf: Sanitize error types for PR 30836 Torbjörn SVENSSON
2023-10-09 10:27 ` Nick Alcock [this message]
2023-10-09 14:44 ` [PATCH v6] " Torbjörn SVENSSON
2023-10-09 15:11 ` [PATCH v7] " Torbjörn SVENSSON
2023-10-11 11:14 ` Nick Alcock
2023-10-13 14:01 ` [PATCH] libctf: check for problems with error returns Nick Alcock
2023-10-13 18:31 ` Torbjorn SVENSSON
2023-10-15 19:18 ` Nick Alcock
2023-10-16 12:51 ` [PATCH v8] libctf: Sanitize error types for PR 30836 Torbjörn SVENSSON
2023-10-17 15:15 ` Nick Alcock
2023-10-17 15:35 ` Torbjorn SVENSSON
2023-10-17 18:54 ` [PATCH] libctf: Return CTF_ERR in ctf_type_resolve_unsliced " Torbjörn SVENSSON
2023-10-17 19:40 ` Nick Alcock
2023-10-18 7:40 ` Torbjorn SVENSSON
2023-10-20 17:01 ` Nick Alcock
2023-10-16 13:02 ` [PATCH] libctf: check for problems with error returns Torbjorn SVENSSON
2023-10-17 14:45 ` Nick Alcock
2024-01-30 12:46 ` Andreas Schwab
2024-01-30 14:22 ` Nick Alcock
2024-01-30 14:27 ` Andreas Schwab
2024-03-09 2:44 ` Sam James
2024-03-11 15:14 ` Nick Alcock
2024-03-12 6:52 ` Sam James
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8734ykks45.fsf@esperi.org.uk \
--to=nick.alcock@oracle.com \
--cc=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=torbjorn.svensson@foss.st.com \
--cc=yvan.roux@foss.st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).