Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp355211pxj; Thu, 3 Jun 2021 08:20:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxICgqQy9tS0CVf5iywCbsrecsLfUokgwPzTdRblDgMdg5eSg/dfF+seAIQzyrMa5yFwpZX X-Received: by 2002:a17:906:1591:: with SMTP id k17mr106374ejd.401.1622733601365; Thu, 03 Jun 2021 08:20:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622733601; cv=none; d=google.com; s=arc-20160816; b=sf1OUKVxR2oBIh48YRiKkCRxgtTpiFHnkoIjUo4zofn4AtExxlhMRKIM1YW1bWOaP2 GKkCwwVIzjG9pTcdqVB5wr6bNlEawtzHF/uqwk7nk9Be9G+G0Vd2k7nHWnwWXMTpZvQo Y/44GwmckpwpHYIM/Ksl2t8SEWkUPr4sM7kYWKp7Ly7y/wz/iLtyMnx/5XrhLqc4rbZs S2NgYZcYhS4VVkG1JC4l9H5W/jzqnsqshFx8RyuSZH2WkvR8+O/w36jckM0FN2nOBNxO Nqd66DXah+TIyNE47Y5MRKQIjavi5WbcdX4M3aEHYUWXbTiZi8hHkiKdMaYCJFnWR7Cn wR7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=GBy3Ek6Ah3zT3vWcT5iFq6CxTPvun8qGj3K1Ss89gPg=; b=lhWAfn6kTYpl9SQdQZh0kUce/XsMH6e5GKYAG2cM1UynBtB9MVbkMVmoiRZukVnBsW NlvEsqRKSLK2fvzsJYQddkyj6ed2hcfIYU2pbKxE/GtmJ1ZoRmToiTppYrJCNBbm9xFc P+qcwg1fpKC1Fu0u3OZWUvBicSaZpg1Auvi54D30XHWuMqNY/bsY62Xu/bqzTH6ORUaG J47h85d+YcMvvVMpSLfhvIG1VGIku4n3tKUhxdmCsjwRq9iKE2c1XLQSlCYKyBpgDUxV 6dxc4JOm+MisEn4qLhKPuP3wM7Y2zwDhSi8BMBv02N8yQyyeIdBjhYpxDgqlGkoGi+Ct 2JoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h14si2643506edr.526.2021.06.03.08.19.37; Thu, 03 Jun 2021 08:20:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232134AbhFCPSQ (ORCPT + 99 others); Thu, 3 Jun 2021 11:18:16 -0400 Received: from smtp13.smtpout.orange.fr ([80.12.242.135]:59086 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232136AbhFCPSP (ORCPT ); Thu, 3 Jun 2021 11:18:15 -0400 Received: from tomoyo.flets-east.jp ([114.149.34.46]) by mwinf5d75 with ME id CfFu2500H0zjR6y03fGTTY; Thu, 03 Jun 2021 17:16:29 +0200 X-ME-Helo: tomoyo.flets-east.jp X-ME-Auth: bWFpbGhvbC52aW5jZW50QHdhbmFkb28uZnI= X-ME-Date: Thu, 03 Jun 2021 17:16:29 +0200 X-ME-IP: 114.149.34.46 From: Vincent Mailhol To: Marc Kleine-Budde , linux-can@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Oliver Hartkopp , Vincent Mailhol Subject: [PATCH v2 1/2] can: netlink: remove redundant check in can_validate() Date: Fri, 4 Jun 2021 00:15:49 +0900 Message-Id: <20210603151550.140727-2-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210603151550.140727-1-mailhol.vincent@wanadoo.fr> References: <20210603151550.140727-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Vincent Mailhol --- drivers/net/can/dev/netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c index e38c2566aff4..32c603a09809 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; } -- 2.31.1