This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils 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]

Re: [PATCH 0/4] Improve elfutils diagnostics


On Wed, May 13, 2015 at 01:31:00PM -0400, Frank Ch. Eigler wrote:
> > One implementation detail that I like to see changed is to make the
> > details errmsg a list of strings instead of one big string (and
> > similarly for dw_tried_paths). [...]
> 
> How would such a list-of-strings be represented?  Considering that
> this is C, and the list arity will vary, we'd be doing dynamic
> allocation anyway, right?

Less allocation is better than more, especially if there are situations
where the extra allocations might not be used anyway.

Note, I am mostly concerned by the asprintf string concats. Those
seem to be done for two reasons that I like to see split out.
They concat because they want to represent the errno (string) and
an extra argument (e.g. file not found plus file name). In which case
I think it is better to store that as two separate items, the errno
and the detail, so no extra string needs to be constructed, unless
the user want to. And to add compound failures together. In that case
I think an array or list of failures (errno plus detail pairs) would
be better.

So the ideal way to represent it might be an array plus length of
pairs typedef struct Dwfl_ErrDetail { int errno, const char *detail }.
Then the array can be preallocated and realloced when necessary.

Cheers,

Mark

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