[mythtv] Possible errors

marty.boeckman at comcast.net marty.boeckman at comcast.net
Fri Oct 8 17:58:01 UTC 2004


The code below has a note about being slow. It could be fixed by putting a break statement in the loop whenever the boolean is set to false.  Because once the boolean is set to false, that's all this method can ever return.  I found this potential issue using a case tools audit feature. The results of the audit are posted at: http://home.comcast.net/~marty.boeckman/audit.txt

bool GenericTree::checkNode(QValueList<int> route_of_branches)
{
    bool found_it = true;
    GenericTree *parent_finder = this;

    // FIXME: slow

    for (int i = route_of_branches.count() - 1; i > -1 && found_it; --i)
    {
        if (!(parent_finder->getInt() == (*route_of_branches.at(i))))
            found_it = false;

        if (i > 0)
        {
            if (parent_finder->getParent())
                parent_finder = parent_finder->getParent();
            else
                found_it = false;
        }
    }

    return found_it;
} 


More information about the mythtv-dev mailing list