OpenSolaris

Discussions Communities Projects Download Source Browser

Home » OpenSolaris Forums » OpenSolaris » code

Thread: err/warn in libc

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 1 - Last Post: Sep 28, 2007 9:33 AM by: alanc
vkotal

Posts: 266
From: CZ

Registered: 12/20/05
err/warn in libc
Posted: Sep 28, 2007 7:03 AM

  Click to reply to this thread Reply


Hi coders,

Tired of always writing something like this?

if ((ptr = malloc(size)) == NULL) {
(void) fprintf(stderr, "%s: out of memory\n", prog);
exit(1);
}

Well, now you can just write this:

if ((ptr = malloc(size)) == NULL)
err(1, "%s: out of memory", prog);

This is now possible thanks to err/warn function family being integrated
into libc in the ON consolidation.

More details and examples can be found in the man page, blog entry and
PSARC materials:

err(3C) / available in Nevada since build 72
http://blogs.sun.com/vlad/entry/closing_bsd_compatibility_gap
http://www.opensolaris.org/os/community/arc/caselog/2006/662/


v.
_______________________________________________
opensolaris-code mailing list
opensolaris-code at opensolaris dot org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code


alanc

Posts: 5,504
From: US

Registered: 3/9/05
Re: err/warn in libc
Posted: Sep 28, 2007 9:33 AM   in response to: vkotal

  Click to reply to this thread Reply

Vladimir Kotal wrote:
> Tired of always writing something like this?

No, but I am tired of having to replace err() and family in
code being ported from BSD/Linux, so hurrah! (In fact, I
just updated a machine to nv_74 yesterday just to get err()
so I didn't have to plugin my own copy yet again for another
X.Org library that now uses err().)

--
-Alan Coopersmith- alan dot coopersmith at sun dot com
Sun Microsystems, Inc. - X Window System Engineering
_______________________________________________
opensolaris-code mailing list
opensolaris-code at opensolaris dot org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code





Terms of Use | Privacy | Trademarks | Copyright Policy | Site Guidelines
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Use.
Copyright © 1995-2005 Sun Microsystems, Inc.