[Kde-hardware-devel] Solid device action predicates

Ozan Çağlayan ozan at pardus.org.tr
Fri Jul 10 11:26:44 CEST 2009


Ozan Çağlayan wrote On 08-07-2009 14:47:
> Okay I've found the problem in solid/solid/predicate.cpp:
>
> In Solid::Predicate::matches, a boolean expression is returned to
> identify whether there was a match or not:
>
>
> if (d->compOperator==Mask) {
>                 bool v_ok;
>                 int v = value.toInt(&v_ok);
>                 bool e_ok;
>                 int e = expected.toInt(&e_ok);
>
>                 return (e_ok && v_ok && (v &e));
>             } else {
>                 return (value == expected);
>
> 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. 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));
>
>
> I'm not quite familiar with boolean expressions so the optimal solution
> is up to you.
>   
ping :)


More information about the Kde-hardware-devel mailing list