<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jun 27, 2013 at 1:19 PM, Bill Spitzak <span dir="ltr"><<a href="mailto:spitzak@gmail.com" target="_blank">spitzak@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
<br>
Jason Ekstrand wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This commit adds version information to wl_message signatures and a<br>
wl_message_get_since function to retrieve. The since version comes in the<br>
form of a (possible) integer at the begining of the message. If the<br>
message starts with an integer, then it specifies the "since" version of<br>
that message. Messages present in version one do not get this "since"<br>
information. In this way we can run-time detect the version information<br>
for a structure on a per-message basis.<br>
</blockquote>
<br></div>
Why can't it record the version when the client creates an object, and then assume all messages to that object are that version?</blockquote><div><br></div><div>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. <br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- if (*signature == '?') {<br>
- details->nullable = 1;<br>
- signature++;<br>
- } else<br>
- details->nullable = 0;<br>
-<br>
- details->type = *signature;<br>
- return signature + 1;<br>
+ details->nullable = 0;<br>
+ for(; *signature; ++signature) {<br>
+ switch(*signature) {<br>
+ case 'i':<br>
+ case 'u':<br>
+ case 'f':<br>
+ case 's':<br>
+ case 'o':<br>
+ case 'n':<br>
+ case 'a':<br>
+ case 'h':<br>
+ details->type = *signature;<br>
+ return signature + 1;<br>
+ case '?':<br>
+ details->nullable = 1;<br>
+ }<br>
+ }<br>
+ return signature;<br>
</blockquote>
<br></div></div>
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.<br>
</blockquote></div><br></div><div class="gmail_extra">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.<br>
</div><div class="gmail_extra"><br></div><div class="gmail_extra">--Jason Ekstrand<br></div></div>