[Kde-hardware-devel] Solid device action predicates

Kevin Ottens ervin at kde.org
Fri Jul 24 13:45:50 CEST 2009


On Wednesday 8 July 2009 13:47:45 Ozan Çağlayan wrote:
> The problem is that when the expected value doesn't exist (e.g. foobar,
> or a plain empty string '') e is equal to -1. So (v &e) masking returns
> non-null because of the signedness of the variable e.

Right, that was the root of the problem.

> I tried a very
> quick hack and it fixed the issue. I replaced that expression with:
>
> return (e_ok && v_ok && (e+1) && (v &e));

Urgh! I'm not quite fan of the "e+1", it'll obviously break if the behavior 
changes and that we get -2 for instance, and moreover it's kind of a magic 
value in this context.

Anyway I committed a proper fix just now[*] which checks the return value of 
keysToValue (aka the place where the error occurs) to reset the expected value 
to an invalid in this case.

Note that I'm committing this with the accompanying unit tests. That generally 
makes it faster to debug something when you use those. ;-)

Regards.
[*] Revision 1001864 in trunk, backported as revision 1001868 in 4.3.
-- 
Kévin 'ervin' Ottens, http://ervin.ipsquad.net
"Ni le maître sans disciple, Ni le disciple sans maître,
Ne font reculer l'ignorance."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/kde-hardware-devel/attachments/20090724/08615060/attachment.sig 


More information about the Kde-hardware-devel mailing list