Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vdev_elevator_switch() possibly incorrect "none" test #4352

Closed
setharnold opened this issue Feb 20, 2016 · 1 comment
Closed

vdev_elevator_switch() possibly incorrect "none" test #4352

setharnold opened this issue Feb 20, 2016 · 1 comment

Comments

@setharnold
Copy link

static int
vdev_elevator_switch(vdev_t *v, char *elevator)
{
        /* ... */
        /* Leave existing scheduler when set to "none" */
        if (strncmp(elevator, "none", 4) && (strlen(elevator) == 4) == 0)
                return (0);

This code is convoluted, with five different equality tests on one line. Testing it in a standalone program it appears to return 0 whenever the 'elevator' input string isn't four characters long. (It looks like the strlen() check was added later in the wrong position.)

I propose this replacement:

if (strcmp(elevator, "none") == 0)
        return (0);

Since vdev_elevator_switch() is only ever called with elevator="noop" perhaps this test could be removed anyway.

Thanks

@behlendorf
Copy link
Contributor

Resolved by 4903926

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants