[libfabric-users] API suggestion: some return values without minus sign
Xiong, Jianxin
jianxin.xiong at intel.com
Mon Jun 23 00:16:23 PDT 2025
Hi Hugh,
Thanks for the suggestion, but I would disagree with the proposal.
The convention is to define the error numbers as positive and the returned error as negative, just like how "errno.h" is defined and used. This is a consistent behavior and doesn't need much hard work to use correctly in applications.
Introducing anther set of negative values is redundant and can cause more confusion. Now people will have to remember two different conventions and try not to mix them up. I don't think this is worthwhile.
I understand some users may prefer not needing to write the minus sign, this can be easily achieved easily by local definitions.
Thanks,
Jianxin Xiong
> -----Original Message-----
> From: Libfabric-users <libfabric-users-bounces at lists.openfabrics.org> On Behalf Of Hugh Fisher via Libfabric-users
> Sent: Sunday, June 22, 2025 6:09 PM
> To: libfabric-users at lists.openfabrics.org
> Subject: [libfabric-users] API suggestion: some return values without minus sign
>
> Suggestion for the libfabric public API, add three defines in fabric.h
>
> #define FI_RET_EAVAIL (-FI_EAVAIL)
> #define FI_RET_AGAIN (-FI_EAGAIN)
> #define FI_RET_TIMEDOUT (-FI_ETIMEDOUT)
>
> This is so we don’t have to write the minus sign when comparing the return value from fi_send, etc to particular values.
>
> It’s an easy mistake: in developing my current program I wrote “if (err == FI_EAGAIN) … “ and was very impressed by the speed and reliability
> of my network link, I never ran out of resources. Even though I’d posted tens of thousands of fi_recv ops with no active sender … uh, that can’t
> be right.
>
> I suggest only these three values, not all possible error codes, because these three are the “not really errors” that are most likely to be
> individually tested for.
>
> I considered FI_ERR_AVAIL etc instead of FI_RET, but I think the RET prefix makes it clear that these are derived values.
>
> Happy to try and submit a pull request on GitHub, but thought this was a better place to discuss initially.
>
> —
> cheers,
> Hugh Fisher
>
>
> _______________________________________________
> Libfabric-users mailing list
> Libfabric-users at lists.openfabrics.org
> https://lists.openfabrics.org/mailman/listinfo/libfabric-users
More information about the Libfabric-users
mailing list