This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/3045] New: add verror
- From: "ebb9 at byu dot net" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 14 Aug 2006 17:21:25 -0000
- Subject: [Bug libc/3045] New: add verror
- Reply-to: sourceware-bugzilla at sourceware dot org
It is currently very painful to wrap error (or error_at_line), because there is
no va_list variant available.
For example, the GNU M4 project maintains the notion of the current file within
a reentrant struct rather than in a global variable, and it would be nice to
have something like the following:
void
m4_error (struct m4 *context, int status, int errnum, const char *format, ...)
{
va_list args;
va_start (args, format);
verror_at_line (status, errnum, context->file, context->line, format, args);
}
Without the va_list variant, m4 has to resort to a malloc, which has the
potential for failure:
void
m4_error (struct m4 *context, int status, int errnum, const char *format, ...)
{
char *message = xvasprintf (format, args);
if (message)
error_at_line (status, errnum, context->file, context->line, "%s", message);
else
{
error (0, errno, _("unable to display error message"));
abort ();
}
free (message);
}
Having a va_list variant would also reduce code duplication, as shown in this
proposed patch.
--
Summary: add verror
Product: glibc
Version: unspecified
Status: NEW
Severity: enhancement
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: ebb9 at byu dot net
CC: glibc-bugs at sources dot redhat dot com
BugsThisDependsOn: 3044
http://sourceware.org/bugzilla/show_bug.cgi?id=3045
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.