drm/scheduler: Simplify spsc_queue_count check in drm_sched_entity_select_rq
authorNathan Chancellor <natechancellor@gmail.com>
Tue, 2 Oct 2018 06:41:24 +0000 (23:41 -0700)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 9 Oct 2018 22:06:00 +0000 (17:06 -0500)
commitc1f0320e03207255ef618d1bbfe0939d03c7cfac
tree8ea3391f1b0f41b79c8d65c5459185cbfdbd1441
parent5e161e5442a8a209404542c91eb889487b1239f4
drm/scheduler: Simplify spsc_queue_count check in drm_sched_entity_select_rq

Clang generates a warning when it sees a logical not followed by a
conditional operator like ==, >, or <.

drivers/gpu/drm/scheduler/sched_entity.c:470:6: warning: logical not is
only applied to the left hand side of this comparison
[-Wlogical-not-parentheses]
        if (!spsc_queue_count(&entity->job_queue) == 0 ||
            ^                                     ~~
drivers/gpu/drm/scheduler/sched_entity.c:470:6: note: add parentheses
after the '!' to evaluate the comparison first
        if (!spsc_queue_count(&entity->job_queue) == 0 ||
            ^
             (                                        )
drivers/gpu/drm/scheduler/sched_entity.c:470:6: note: add parentheses
around left hand side expression to silence this warning
        if (!spsc_queue_count(&entity->job_queue) == 0 ||
            ^
            (                                    )
1 warning generated.

It assumes the author might have made a mistake in their logic:

if (!a == b) -> if (!(a == b))

Sometimes that is the case; other times, it's just a super convoluted
way of saying 'if (a)' when b = 0:

if (!1 == 0) -> if (0 == 0) -> if (true)

Alternatively:

if (!1 == 0) -> if (!!1) -> if (1)

Simplify this comparison so that Clang doesn't complain.

Fixes: 35e160e781a0 ("drm/scheduler: change entities rq even earlier")
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/scheduler/sched_entity.c