Linux Kernels

net: l2tp: cleanup: remove redundant condition

This change “net: l2tp: cleanup: remove redundant condition” (commit 57ceb86) in Linux kernel is authored by Asbjørn Sloth Tønnesen <asbjorn [at]> on Mon Nov 7 20:39:27 2016 +0000.

Description of "net: l2tp: cleanup: remove redundant condition"

The change “net: l2tp: cleanup: remove redundant condition” introduces changes as follows.

net: l2tp: cleanup: remove redundant condition

These assignments follow this pattern:

        unsigned int foo:1;
        struct nlattr *nla = info->attrs[bar];

        if (nla)
                foo = nla_get_flag(nla); /* expands to: foo = !!nla */

This could be simplified to: if (nla) foo = 1;
but lets just remove the condition and use the macro,

        foo = nla_get_flag(nla);

Signed-off-by: Asbjoern Sloth Toennesen <>
Signed-off-by: David S. Miller <>

Linux kernel releases containing commit 57ceb86

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "net: l2tp: cleanup: remove redundant condition"

There are 12 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 net/l2tp/l2tp_netlink.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c
index 494910d84602..3620fba31786 100644
--- a/net/l2tp/l2tp_netlink.c
+++ b/net/l2tp/l2tp_netlink.c
@@ -220,14 +220,14 @@ static int l2tp_nl_cmd_tunnel_create(struct sk_buff *skb, struct genl_info *info
 			cfg.local_udp_port = nla_get_u16(info->attrs[L2TP_ATTR_UDP_SPORT]);
 		if (info->attrs[L2TP_ATTR_UDP_DPORT])
 			cfg.peer_udp_port = nla_get_u16(info->attrs[L2TP_ATTR_UDP_DPORT]);
-		if (info->attrs[L2TP_ATTR_UDP_CSUM])
-			cfg.use_udp_checksums = nla_get_flag(info->attrs[L2TP_ATTR_UDP_CSUM]);
+		cfg.use_udp_checksums = nla_get_flag(
+			info->attrs[L2TP_ATTR_UDP_CSUM]);
-		if (info->attrs[L2TP_ATTR_UDP_ZERO_CSUM6_TX])
-			cfg.udp6_zero_tx_checksums = nla_get_flag(info->attrs[L2TP_ATTR_UDP_ZERO_CSUM6_TX]);
-		if (info->attrs[L2TP_ATTR_UDP_ZERO_CSUM6_RX])
-			cfg.udp6_zero_rx_checksums = nla_get_flag(info->attrs[L2TP_ATTR_UDP_ZERO_CSUM6_RX]);
+		cfg.udp6_zero_tx_checksums = nla_get_flag(
+			info->attrs[L2TP_ATTR_UDP_ZERO_CSUM6_TX]);
+		cfg.udp6_zero_rx_checksums = nla_get_flag(
+			info->attrs[L2TP_ATTR_UDP_ZERO_CSUM6_RX]);

The commit for this change in Linux stable tree is 57ceb86 (patch).

Last modified: 2020/01/11 09:44