[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-hardware-devel
Subject:    Re: [Kde-hardware-devel] Solid device action predicates
From:       Ozan Çağlayan <ozan () pardus ! org ! tr>
Date:       2009-07-08 11:47:45
Message-ID: 4A548761.8050502 () pardus ! org ! tr
[Download RAW message or body]

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
_______________________________________________
Kde-hardware-devel mailing list
Kde-hardware-devel@kde.org
https://mail.kde.org/mailman/listinfo/kde-hardware-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic