From: "Anthony PERARD" <anthony.perard@vates.tech>
To: "Teddy Astie" <teddy.astie@vates.tech>
Cc: "Jan Beulich" <jbeulich@suse.com>,
"Juergen Gross" <jgross@suse.com>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v7 1/2] libxc: Report consistent errors in xc_resource_op
Date: Wed, 25 Feb 2026 10:50:38 +0000 [thread overview]
Message-ID: <aZ7T_ddTHBY0fz7I@l14> (raw)
In-Reply-To: <f569a8f0-8df9-4e5a-b3ed-ae600c3c0bd3@vates.tech>
On Tue, Feb 24, 2026 at 09:28:57AM +0000, Teddy Astie wrote:
> Le 23/02/2026 à 17:15, Jan Beulich a écrit :
> > On 23.02.2026 17:06, Teddy Astie wrote:
> >> xc_report_op returns -1 in some error conditions.
> >> Make sure it returns -ENOMEM in out of memory errors and -EINVAL
> >> in invalid usages errors.
> >
> > Isn't this a move in the wrong direction? -1 as a return value is quite okay.
> > errno wants setting to indicate the cause of the error (if called functions
> > don't already set it properly).
> >
>
> To me, passing error through errno here feels more like a workaround
> rather than a proper error handling. It doesn't feel consistent in libxc
> overall (some functions returns a negative value corresponding to a
> error number while some others -1; in some cases we update errno).
>
> What are the error handling rules for xenctrl ?
They are written down. See
https://elixir.bootlin.com/xen/v4.21.0/source/tools/include/xenctrl.h#L76
Unless otherwise specified, each function here returns zero or a
non-null pointer on success; or in case of failure, sets errno and
returns -1 or a null pointer.
Unless otherwise specified, errors result in a call to the error
handler function, which by default prints a message to the
FILE* passed as the caller_data, which by default is stderr.
(This is described below as "logging errors".)
The error handler can safely trash errno, as libxc saves it across
the callback.
`errno` isn't a workaround, it is the way many libc functions and other
passes generic error code. It may feel awkward, but that C.
If some functions don't update `errno`, it might be because the syscall
already set `errno` and there's no need to change it.
Thanks,
--
Anthony Perard | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
prev parent reply other threads:[~2026-02-25 10:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 16:06 [PATCH v7 1/2] libxc: Report consistent errors in xc_resource_op Teddy Astie
2026-02-23 16:06 ` [PATCH v7 2/2] xenpm: Add get-dts-temp subcommand Teddy Astie
2026-02-23 16:28 ` Jan Beulich
2026-02-23 16:13 ` [PATCH v7 1/2] libxc: Report consistent errors in xc_resource_op Jan Beulich
2026-02-24 9:28 ` Teddy Astie
2026-02-24 9:36 ` Jan Beulich
2026-02-25 10:50 ` Anthony PERARD [this message]
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=aZ7T_ddTHBY0fz7I@l14 \
--to=anthony.perard@vates.tech \
--cc=jbeulich@suse.com \
--cc=jgross@suse.com \
--cc=teddy.astie@vates.tech \
--cc=xen-devel@lists.xenproject.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.