backward/forward binary compatibility checker

Matthew Woehlke mw_triad at users.sourceforge.net
Thu Jul 30 21:46:59 BST 2009


Thiago Macieira wrote:
> === section Problems in Data Types (High risk)
> QByteArrayMatcher:
> The report says "Size of this type has been changed from 1032 to 1024 bytes". 
> That's completely wrong. Here's the diff:
> 
>  private:
>      QByteArrayMatcherPrivate *d;
>      QByteArray q_pattern;
> -    uint q_skiptable[256];
> +    union {
> +        uint dummy[256];
> +        struct {
> +            uchar q_skiptable[256];
> +            const uchar *p;
> +            int l;
> +        } p;
> +    };
> 
> As you can see, the size holds the same, at sizeof(QByteArrayMatcherPrivate *) 
> + sizeof(QByteArray) + 256*sizeof(int) = 4 + 4 + 1024 = 1032. I have no clue 
> how it came up with 1024, since there's no addition that would result in that.

If you assume that the 'changed from' is backwards (old was 1024, new is 
1032), that sure looks right to me (for 32-bit systems)... the old is 
obviously 1024 bytes, the new is a struct containing a 1024-byte member, 
a pointer, and a 4-byte member = 1032 bytes.

Am I missing a way to pack the three members of that struct (one of 
which is 1024 bytes by itself) into 1024 bytes?

-- 
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
-- 
Disadvantage: Bad Puns [-5]
You constantly utter puns so egregious as to cause mental distress to 
anyone hearing them. This can, however, be used to distract enemies.





More information about the kde-core-devel mailing list