]> git.baikalelectronics.ru Git - kernel.git/commit
platform/surface: aggregator: Fix braces in if condition with unlikely() macro
authorMaximilian Luz <luzmaximilian@gmail.com>
Tue, 26 Jan 2021 17:22:02 +0000 (18:22 +0100)
committerHans de Goede <hdegoede@redhat.com>
Wed, 3 Feb 2021 11:00:17 +0000 (12:00 +0100)
commit0c8d5e353057b358fdb0c8b98dca74e61e89da32
tree3948e18e262686c7a84b9d89ebc1a570c637fd8a
parentb6beac3fd880e95aa73627d59ffb144397c04502
platform/surface: aggregator: Fix braces in if condition with unlikely() macro

The braces of the unlikely() macro inside the if condition only cover
the subtraction part, not the whole statement. This causes the result of
the subtraction to be converted to zero or one. While that still works
in this context, it causes static analysis tools to complain (and is
just plain wrong).

Fix the bracket placement and, while at it, simplify the if-condition.
Also add a comment to the if-condition explaining what we expect the
result to be and what happens on the failure path, as it seems to have
caused a bit of confusion.

This commit should not cause any difference in behavior or generated
code.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 2ef0797232f5 ("platform/surface: Add Surface Aggregator subsystem")
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Link: https://lore.kernel.org/r/20210126172202.1428367-1-luzmaximilian@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/surface/aggregator/ssh_packet_layer.c