[RFC] importing e* (embolic, estrdup, etc) functions from NetBSD (libc/libutil or libnetbsd)?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[RFC] importing e* (embolic, estrdup, etc) functions from NetBSD (libc/libutil or libnetbsd)?

Enji Cooper
Hi all,
        While looking quickly through makefs upstream for fixing a PR, I realized that some years ago NetBSD has refactored a number of userland utilities (including makefs) to use their new e* function implementations of malloc, strndup, etc: http://man.netbsd.org/HEAD/usr/share/man/html3/efun.html (they have some other functions that we don’t have in libc/libutil in their libutil that might need to be ported as well).
        The basic overall difference is that when the failing case occurs, a function defined by esetfunc is called, it dumps out a diagnostic error message via esetfunc, then returns the original value [*].
        I was wondering if anyone had objections to adding this to libutil (I think it’d be handy because it would eliminate a lot of repetitive error handling in our user land code)? If there are major objections, I’ll take it and stuff it into libnetbsd.
Thanks!
-NGie

[*] Based on a quick glance over the code, estrlcpy/estrlcat/estrtoi/estrtou are exceptions to the rule. It modifies/saves errno before calling the error function: http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libutil/efun.c?rev=1.10&content-type=text/x-cvsweb-markup&only_with_tag=MAIN
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] importing e* (embolic, estrdup, etc) functions from NetBSD (libc/libutil or libnetbsd)?

Oliver Pinter-4
added pfg@ to CC

On Mon, Oct 19, 2015 at 9:14 PM, NGie Cooper <[hidden email]> wrote:

> Hi all,
>         While looking quickly through makefs upstream for fixing a PR, I realized that some years ago NetBSD has refactored a number of userland utilities (including makefs) to use their new e* function implementations of malloc, strndup, etc: http://man.netbsd.org/HEAD/usr/share/man/html3/efun.html (they have some other functions that we don’t have in libc/libutil in their libutil that might need to be ported as well).
>         The basic overall difference is that when the failing case occurs, a function defined by esetfunc is called, it dumps out a diagnostic error message via esetfunc, then returns the original value [*].
>         I was wondering if anyone had objections to adding this to libutil (I think it’d be handy because it would eliminate a lot of repetitive error handling in our user land code)? If there are major objections, I’ll take it and stuff it into libnetbsd.
> Thanks!
> -NGie
>
> [*] Based on a quick glance over the code, estrlcpy/estrlcat/estrtoi/estrtou are exceptions to the rule. It modifies/saves errno before calling the error function: http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libutil/efun.c?rev=1.10&content-type=text/x-cvsweb-markup&only_with_tag=MAIN
> _______________________________________________
> [hidden email] mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-arch
> To unsubscribe, send any mail to "[hidden email]"
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] importing e* (embolic, estrdup, etc) functions from NetBSD (libc/libutil or libnetbsd)?

Ed Maste-2
In reply to this post by Enji Cooper
On 19 October 2015 at 15:14, NGie Cooper <[hidden email]> wrote:
> Hi all,
>         While looking quickly through makefs upstream for fixing a PR, I realized that some years ago NetBSD has refactored a number of userland utilities (including makefs) to use their new e* function implementations of malloc, strndup, etc: http://man.netbsd.org/HEAD/usr/share/man/html3/efun.html (they have some other functions that we don’t have in libc/libutil in their libutil that might need to be ported as well).

Yes, I spotted this while looking at makefs as well and I think it's
reasonable to bring them over. I would put them in libnetbsd though
until there's an actual plan to start migrating our own tools to use
them.  Moving them from libnetbsd to libutil is easy to do later on.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] importing e* (embolic, estrdup, etc) functions from NetBSD (libc/libutil or libnetbsd)?

Brooks Davis-2
On Mon, Oct 19, 2015 at 04:03:58PM -0400, Ed Maste wrote:
> On 19 October 2015 at 15:14, NGie Cooper <[hidden email]> wrote:
> > Hi all,
> >         While looking quickly through makefs upstream for fixing a PR, I realized that some years ago NetBSD has refactored a number of userland utilities (including makefs) to use their new e* function implementations of malloc, strndup, etc: http://man.netbsd.org/HEAD/usr/share/man/html3/efun.html (they have some other functions that we don???t have in libc/libutil in their libutil that might need to be ported as well).
>
> Yes, I spotted this while looking at makefs as well and I think it's
> reasonable to bring them over. I would put them in libnetbsd though
> until there's an actual plan to start migrating our own tools to use
> them.  Moving them from libnetbsd to libutil is easy to do later on.

This feels like the right approach to me as well.  Let's get them in and
get some them some more exposure and then, if people like them, we can
put a copy in libutil.

-- Brooks

signature.asc (484 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] importing e* (embolic, estrdup, etc) functions from NetBSD (libc/libutil or libnetbsd)?

Poul-Henning Kamp
--------
In message <[hidden email]>, Brooks Davis writes:

>This feels like the right approach to me as well.

I looked at it at one point and I found it seriously lacking.

The philosophy seems to be "just stick 'e' in front and you're done"
but in practice that is not even close.

The *real* problem they're trying to solve is safe string handling,
and the e* functions only cover a small corner area of that space.

Their implemenation also seems half-hearted in many ways.  For
instance they have not specified what happens if the error handler
returns to the e* function.

And finally, C-with-exceptions ?  Really ?

I far prefer sbuf(3) to e*(3)

--
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
[hidden email]         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] importing e* (embolic, estrdup, etc) functions from NetBSD (libc/libutil or libnetbsd)?

Brooks Davis-2
On Mon, Oct 19, 2015 at 09:50:12PM +0000, Poul-Henning Kamp wrote:
> --------
> In message <[hidden email]>, Brooks Davis writes:
>
> >This feels like the right approach to me as well.
>
> I looked at it at one point and I found it seriously lacking.

By "This" I ment, sticking them in libnetbsd.  For code we don't actively
maintain, I'd rather pick up some extra funcitions in libnetbsd than
convert the code to match our prefered mechanism unless there's a good
reason to.

> The philosophy seems to be "just stick 'e' in front and you're done"
> but in practice that is not even close.

If one wanted this approach, a libc replacment that fails stop on
unrecoverable errors might be more interesting approach (somwhat with
different, but still signficant limitations).

> The *real* problem they're trying to solve is safe string handling,
> and the e* functions only cover a small corner area of that space.
>
> Their implemenation also seems half-hearted in many ways.  For
> instance they have not specified what happens if the error handler
> returns to the e* function.
>
> And finally, C-with-exceptions ?  Really ?
>
> I far prefer sbuf(3) to e*(3)
For our code, I think I agree.

-- Brooks

signature.asc (484 bytes) Download Attachment