From: Vincent Mailhol Date: Thu, 3 Jun 2021 15:15:49 +0000 (+0900) Subject: can: netlink: remove redundant check in can_validate() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=6b6bd199926797414bf4d6843312709dfd4a649e;p=linux.git 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 Signed-off-by: Marc Kleine-Budde --- diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c index b567fd628c172..147c23d7dab7f 100644 --- a/drivers/net/can/dev/netlink.c +++ b/drivers/net/can/dev/netlink.c @@ -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; }