[PATCH wayland 2/3] Add version information to wl_message signatures.
Jason Ekstrand
jason at jlekstrand.net
Thu Jun 27 18:04:29 PDT 2013
On Thu, Jun 27, 2013 at 1:19 PM, Bill Spitzak <spitzak at gmail.com> wrote:
>
>
> Jason Ekstrand wrote:
>
>> This commit adds version information to wl_message signatures and a
>> wl_message_get_since function to retrieve. The since version comes in the
>> form of a (possible) integer at the begining of the message. If the
>> message starts with an integer, then it specifies the "since" version of
>> that message. Messages present in version one do not get this "since"
>> information. In this way we can run-time detect the version information
>> for a structure on a per-message basis.
>>
>
> Why can't it record the version when the client creates an object, and
> then assume all messages to that object are that version?
That is exactly what this patch allows you to do. More particularly, this
patch protects the compositor from bad clients that attempt to use requests
that are not supported by the compositor. In the current implementation,
the compositor simply crashes.
>
> - if (*signature == '?') {
>> - details->nullable = 1;
>> - signature++;
>> - } else
>> - details->nullable = 0;
>> -
>> - details->type = *signature;
>> - return signature + 1;
>> + details->nullable = 0;
>> + for(; *signature; ++signature) {
>> + switch(*signature) {
>> + case 'i':
>> + case 'u':
>> + case 'f':
>> + case 's':
>> + case 'o':
>> + case 'n':
>> + case 'a':
>> + case 'h':
>> + details->type = *signature;
>> + return signature + 1;
>> + case '?':
>> + details->nullable = 1;
>> + }
>> + }
>> + return signature;
>>
>
> To match your use of atoi it would be better to skip all the leading
> digits (possibly in other code where you know you are at the start of the
> signature), then use this old version of the code.
>
I thought about doing that but this is less invasive. Also, I like this
method of counting better anyway because it's a bit more robust. Suppose
we add in some other type-specifier than "?". In that case, the old
implementation wouldn't work anyway.
--Jason Ekstrand
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20130627/a19dfe1e/attachment.html>
More information about the wayland-devel
mailing list