[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [Qemu-devel] [PATCH 15/16] os-posix: cleanup: Replace perror with error_report



Philippe Mathieu-Daudé writes ("Re: [Qemu-devel] [PATCH 15/16] os-posix: 
cleanup: Replace perror with error_report"):
> On 04/19/2018 01:45 PM, Ian Jackson wrote:
> > -        perror("mlockall");
> > +        error_report("mlockall: %s", strerror(errno));
> >      }
> >  
> >      return ret;
> 
> Thinking loudly, maybe we can refactor as error_report_errno(const char
> *desc)...

git-grep 'error_report.*errno' shows a lot of call sites that do
something more exciting than const char *desc would support.

I think the right approach would be

 - static void vreport(report_type type, const char *fmt, va_list ap)
 + static void vreport(report_type type, int errnoval, const char *fmt, va_list 
ap)
...
 +     if (errnoval >= 0) {
 +         error_printf(": %s", strerror(errnoval);
 +     }

and then add both
  error_report_errno
  error_vreport_errno
with the obvious semantics.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.