This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/3045] New: add verror


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]