[PATCH wayland] server: add helper functions for wl_global
Bryce Harrington
bryce at osg.samsung.com
Mon Feb 23 17:20:37 PST 2015
On Mon, Feb 23, 2015 at 11:30:57AM -0800, Bill Spitzak wrote:
> Which of the 4 arguments do you use for your use case?
>
> Because this can only return the first match I suspect some of the
> NULL tests are pretty useless, because you have to specify arguments
> that you know will return the one and only instance you are
> interested in. It might be better to make this exactly match the use
> case you have. If you are passing NULL just remove that argument,
> and conversely remove the null test from this code for the arguments
> you send. Basically don't add code that is not certain to be useful.
I would assume he's using all of them.
Regardless, so long as the test case covers an adequate number of
permutations I don't see an issue with providing a generalized solution
to this need.
However, I suspect this API would be better named as
wl_global_find_first().
A more general wl_global_find() I would expect to be returning a list of
results.
One thing to think about when writing a test case, is if this function
will always return the same first result. E.g. if the globals list
depends at all on timing of hardware bringup thight might vary boot to
boot, or if hashes are in any way involved in creating it, or etc.
I'm guessing that's not the case, but probably worth checking, else
we'll inevitably have a bug reported about it on some obscure piece of
hardware.
Bryce
> On 02/23/2015 10:06 AM, Jonny Lamb wrote:
>
> >+/** Find a wl_global given search parameters
> >+ *
> >+ * \param display The display object
> >+ * \param interface The interface to match, or NULL
> >+ * \param version The version to match, or 0
> >+ * \param data The user data to match, or NULL
> >+ * \param bind The function used to bind the object, or NULL
> >+ * \return The first wl_global which matches, or NULL
> >+ *
> >+ * The global list of a wl_display is not public so this function helps in
> >+ * finding a specific wl_global based on the parameters. Parameters can be
> >+ * missing for a broader search (NULL for interface, data, and bind, and 0 for
> >+ * version) but at least one must be present or no result will be returned.
> >+ *
> >+ * \memberof wl_global
> >+ */
> >+WL_EXPORT struct wl_global *
> >+wl_global_find(struct wl_display *display,
> >+ const struct wl_interface *interface, uint32_t version,
> >+ void *data, wl_global_bind_func_t bind)
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list