On Tue, Sep 27, 2016 at 06:57:34PM -0400, David Turner wrote: > > int report_error(struct error_context *err, const char *fmt, ...) > > { > > if (err->fn) { > > va_list ap; > > va_start(ap, fmt); > > err->fn(err->data, fmt, ap); > > va_end(ap); > > } > > return -1; > > } > > > > Then low-level functions just take a context and do: > > > > return report_error(&err, "some error: %s", foo); > > > > And then the callers would pick one of a few generic error contexts: > > > > - passing NULL silences the errors > > Overall, +1. > > I guess I would rather have a sentinel value for silencing errors, > because I'm worried that someone might read NULL as "don't handle the > errors, just die". Of course, code review would hopefully catch this, > but even so, it would be easier to read foo(x, y, silence_errors) than > foo(x, y, null). Yeah, I waffled on that. If you look carefully, you'll note that the report_error() I showed above would actually require such a "{ NULL, NULL }" global. I don't plan to make any patches immediately for this, but I'll let it percolate and consider whether it makes sense to try out for a future series. -Peff