- **Milestone**: 4.4.FC --> future
---
** [tickets:#34] Add utility function for pretty-printing errno**
**Status:** unassigned
**Created:** Tue May 07, 2013 11:16 AM UTC by Ramesh
**Last Updated:** Mon Aug 26, 2013 01:39 PM UTC
**Owner:** nobody
The function strerror() is used at many places in OpenSAF for translating the
error code in the variable errno into a human-readable text. There are a number
of problems with this function:
* strerror() is not thread-safe, and thus should not be used in a
multi-threaded program. Since MDS creates threads, all our programs are
multi-threaded. There is a thread-safe variant of strerror() called
strerror_r(), but unfortunately this function cannot easily be used in a
portable program since different standards define it in different ways (even
the function signature differs).
* strerror() returns a human-readable text translated using the current locale
setting. This could make it difficult to interpret the error messages in a log
file if the locale is set to a language other than English.
* Actually, we don't want a human-readable string in English either. What we
really want is the mnemonic (EINVAL, EBADF etc.), since this is what you will
find in the man pages. Sometimes it can be difficult to know what mnemonic a
certain human-readable error text corresponds to.
The proposal is that we introduce our own utiltiy function that works in a
similar way to streror_r(), but returns both the numeric value and the
mnemonic, e.g.:
char buf[OSAF_ERROR_BUFSIZE];
syslog(LOG_ERR, "Function failed badly, %s", osaf_strerror(buf));
Will log:
Function failed badly, errno = 12 (ENOMEM)
---
Sent from sourceforge.net because [email protected] is
subscribed to https://sourceforge.net/p/opensaf/tickets/
To unsubscribe from further messages, a project admin can change settings at
https://sourceforge.net/p/opensaf/admin/tickets/options. Or, if this is a
mailing list, you can unsubscribe from the mailing list.------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
Opensaf-tickets mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-tickets