[Xcb] [RFC] New project: util-errors for translating numbers into request/error/event names

Ran Benita ran234 at gmail.com
Fri Mar 27 12:58:02 PDT 2015


On Wed, Mar 25, 2015 at 07:02:25PM +0100, Uli Schlachter wrote:
> Hi everyone,
>
> inspired by an issue that showed up in Qt, I started working on an
> util-errors library that does something similar to Xlib's XErrorDB. By
> now this library is progressing nicely and I'm interested in feedback
> from others.
> 
> Currently it can be found on GitHub:
> 
> https://github.com/psychon/util-errors

That's a useful addition. Making errors better is a good cause :)
I've skimmed through the code, haven't tried it yet, so can't comment
on the functionality for now.

make check fails for me:
    For event 89: Expected ScreenChangeNotify, got RawTouchUpdate
    For event 90: Expected Notify, got RawTouchEnd

Btw: if X is not available for the test, I think it's better to SKIP it
(exit with status 77) instead of FAILing it.

I see that you generate extensions.c during build. Have you considered
commiting it to git instead? That way all versions are the same, and do
not depend on the builder's environment. If there's a change you can
release a new version. (I'm not arguing for that - just a
consideration).

Is it not possible to make it entirely static? (i.e. no memory
allocations / requests at all). (Are first_event/first_error dynamic?)

In register_extension(), why return 0 if calloc fails?

Finally, I think a library whose purpose is informative errors should
itself return informative errors :) Maybe <errno.h> codes?

> The API can be found in src/xcb_errors.h and I would suggest looking at
> tests/test.c to see it in action. Basically, you create a
> "xcb_errors_context_t*" for your xcb_connection_t* and can then get the
> names of major codes, event codes, error codes and (major, minor).
> 
> The biggest issue that I see right now is support for GE events and XKB
> events (since XKB does something similar to GE internally). This likely
> requires some more API, something like
> xcb_errors_get_name_for_xge_event(). At that point it might sense to
> also have a function that gets an xcb_generic_error_t* as an argument
> and internally checks for GE / XKB and then calls the correct function.

Functions that take xcb_generic_error_t makes sense to me, to make
things easier with XKB/xinput.

> Also, right now xcb_errors_get_name_for_minor_code() returns NULL if the
> major code belongs to the core protocol. I guess that for arguments in
> the range 0 to 127 it should behave like *_for_major_code() instead to simplify
> usage.
> 
> For the output, it might make sense to include the extension name in the
> result. For example "RandR QueryVersion" is more helpful than just
> "QueryVersion".

Why not xcb_errors_get_name_for_extension()?

Ran

> It would be nice if others could take a look at this library and perhaps
> check their various project for uses. This was inspired by being able to
> "pretty print" errors, but also handling events would be nice.
> 
> Another thing is: Does it make sense to have such a library? If yes, it
> should likely be moved from github to fdo. Can I just create a git repo
> there? If yes, how exactly? :-)
> 
> Cheers,
> Uli
> -- 
> "In the beginning the Universe was created. This has made a lot of
>  people very angry and has been widely regarded as a bad move."
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb


More information about the Xcb mailing list