Thread (12 messages) flat view 12 messages, 3 authors, 2006-12-15

Re: [LIBFDT] Fixup byteswapping code

From: Grant Likely <hidden>
Date: 2006-12-04 14:56:02

On 12/4/06, David Gibson [off-list ref] wrote:
I do have one idea for better error handling: I'd like to put in
something defined in the the libfdt_env.h (which is designed to be
replaced when libfdt is compiled in different environments) to report
an error.  That would be invoked every time a libfdt function exits
with an error - I would envisage it calling through to a user supplied
function pointer.

In many practical situations, I think most libfdt errors would be the
result of something unrecoverable problem (such as a corrupted device
tree blob), the callback could just print an error (by whatever means
is appropritate for the environment) and bail out, avoiding the need
for checking return values.  At least for the "serious" errors
(BADMAGIC, BADSTRUCTURE and so forth).  NOTFOUND (and maybe TRUNCATED)
would need to be passed back as a return value still, since that can
certainly occur in a legitimate test.
Yeah, that's not a bad idea.  That way the complexity of making it
thread safe is left with the execution environment, not with libfdt,
and it still leaves the possibility of application code retrieving the
error code if it is interested....  Still not ideal, but of the
options presented, I like this one best.

Cheers,
g.

-- 
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help