Skip to content

bug: timer.cancel(anId) always returns true #80

@philj404

Description

@philj404

I tried creating an automated regression test to verify good behavior for timer.cancel() and timer ID collisions.
... and I think I found a regression for the returned value from timer.cancel().

    bool
    cancel(Task &task)
    {
        struct task * const t = static_cast<struct task * const>(task);

        if (t) {
            remove(t);
            task = static_cast<Task>(NULL);
            return true;
        }

        return false;
    }

Here's the regression: Now that a timer ID is just a pointer to the timer's slot in the array, it will never be 0... and so timer.cancel(anId) always returns true.

See #79 for the regression test and a fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions