[PATCH wayland 2/3] Add version information to wl_message signatures.

Bill Spitzak spitzak at gmail.com
Fri Jun 28 17:46:54 PDT 2013


Jason Ekstrand wrote:

> while a more modern compositor implementation would look like this:
> 
> wl_foo_interface foo_implementation = {
>     set_bar,
>     set_twiddle
> };
> 
> As it stands, libwayland does not checking of requests beyond a simple 
> check to see request n is devined in the wl_interface object that was 
> built into the library.  Let's see what happens when the client calls 
> set_twiddle (opcode 1) in the current library (without this patch).  In 
> this case the following happens:
> 
> 1) libwayland looks up the object and gets the interface
> 2) libwayland checks to see if a wl_foo has at least 2 requests.  The 
> answer is "yes"
> 3) libwayland blindly looks up the 2nd entry in foo_implementation and 
> attempts to call it.

I would think the size of foo_implementation would work as well for 
avoiding calling methods off the end of the table.

What is confusing me is your use of the variable version. I agree the 
compositor would want to keep track of what version the client is trying 
to use of an object, otherwise it can't emulate the older versions 
accurately.

But I just don't see using it to exclude entries from the dispatch 
table. The reason is that any method that just has to act different 
depending on the version would have to test the version number inside 
it's implementation. Therefore it seems more consistent for a method 
that exists only if version > n to do the test in the implementation as 
well.


More information about the wayland-devel mailing list