[Kde-hardware-devel] Solid device action predicates
Ozan Çağlayan
ozan at pardus.org.tr
Wed Jul 8 13:47:45 CEST 2009
Kevin Ottens wrote On 08-07-2009 11:54:
> This one definitely looks like a bug, it should be rejected. Somehow doesn't
> seem to behave like this for me though.
>
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.
Thanks
Ozan Caglayan
More information about the Kde-hardware-devel
mailing list