mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
can: netlink: remove redundant check in can_validate()
can_validate() does a first check:
| if (is_can_fd) {
| if (!data[IFLA_CAN_BITTIMING] || !data[IFLA_CAN_DATA_BITTIMING])
| return -EOPNOTSUPP;
| }
If that first if succeeds, we know that if is_can_fd is true then
data[IFLA_CAN_BITTIMING is set.
However, the next if switch does not leverage on above knowledge and
redoes the check:
| if (data[IFLA_CAN_DATA_BITTIMING]) {
| if (!is_can_fd || !data[IFLA_CAN_BITTIMING])
| ^~~~~~~~~~~~~~~~~~~~~~~~
| return -EOPNOTSUPP;
| }
This patch removes that redundant check.
Link: https://lore.kernel.org/r/20210603151550.140727-2-mailhol.vincent@wanadoo.fr
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
parent
e3b0a4a470
commit
6b6bd19992
|
|
@ -47,7 +47,7 @@ static int can_validate(struct nlattr *tb[], struct nlattr *data[],
|
|||
}
|
||||
|
||||
if (data[IFLA_CAN_DATA_BITTIMING]) {
|
||||
if (!is_can_fd || !data[IFLA_CAN_BITTIMING])
|
||||
if (!is_can_fd)
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user