All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gtp: simplify error handling code in 'gtp_encap_enable()'
@ 2020-01-05 17:36 ` Christophe JAILLET
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2020-01-05 17:36 UTC (permalink / raw)
  To: pablo, laforge, davem
  Cc: osmocom-net-gprs, netdev, linux-kernel, kernel-janitors,
	Christophe JAILLET

'gtp_encap_disable_sock(sk)' handles the case where sk is NULL, so there
is no need to test it before calling the function.

This saves a few line of code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/net/gtp.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index ecfe26215935..1499b4a37758 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -849,8 +849,7 @@ static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[])
 
 		sk1u = gtp_encap_enable_socket(fd1, UDP_ENCAP_GTP1U, gtp);
 		if (IS_ERR(sk1u)) {
-			if (sk0)
-				gtp_encap_disable_sock(sk0);
+			gtp_encap_disable_sock(sk0);
 			return PTR_ERR(sk1u);
 		}
 	}
@@ -858,10 +857,8 @@ static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[])
 	if (data[IFLA_GTP_ROLE]) {
 		role = nla_get_u32(data[IFLA_GTP_ROLE]);
 		if (role > GTP_ROLE_SGSN) {
-			if (sk0)
-				gtp_encap_disable_sock(sk0);
-			if (sk1u)
-				gtp_encap_disable_sock(sk1u);
+			gtp_encap_disable_sock(sk0);
+			gtp_encap_disable_sock(sk1u);
 			return -EINVAL;
 		}
 	}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] gtp: simplify error handling code in 'gtp_encap_enable()'
@ 2020-01-05 17:36 ` Christophe JAILLET
  0 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2020-01-05 17:36 UTC (permalink / raw)
  To: pablo, laforge, davem
  Cc: osmocom-net-gprs, netdev, linux-kernel, kernel-janitors,
	Christophe JAILLET

'gtp_encap_disable_sock(sk)' handles the case where sk is NULL, so there
is no need to test it before calling the function.

This saves a few line of code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/net/gtp.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index ecfe26215935..1499b4a37758 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -849,8 +849,7 @@ static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[])
 
 		sk1u = gtp_encap_enable_socket(fd1, UDP_ENCAP_GTP1U, gtp);
 		if (IS_ERR(sk1u)) {
-			if (sk0)
-				gtp_encap_disable_sock(sk0);
+			gtp_encap_disable_sock(sk0);
 			return PTR_ERR(sk1u);
 		}
 	}
@@ -858,10 +857,8 @@ static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[])
 	if (data[IFLA_GTP_ROLE]) {
 		role = nla_get_u32(data[IFLA_GTP_ROLE]);
 		if (role > GTP_ROLE_SGSN) {
-			if (sk0)
-				gtp_encap_disable_sock(sk0);
-			if (sk1u)
-				gtp_encap_disable_sock(sk1u);
+			gtp_encap_disable_sock(sk0);
+			gtp_encap_disable_sock(sk1u);
 			return -EINVAL;
 		}
 	}
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] gtp: simplify error handling code in 'gtp_encap_enable()'
  2020-01-05 17:36 ` Christophe JAILLET
@ 2020-01-06  8:59   ` Simon Horman
  -1 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2020-01-06  8:59 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: pablo, laforge, davem, osmocom-net-gprs, netdev, linux-kernel,
	kernel-janitors

On Sun, Jan 05, 2020 at 06:36:07PM +0100, Christophe JAILLET wrote:
> 'gtp_encap_disable_sock(sk)' handles the case where sk is NULL, so there
> is no need to test it before calling the function.
> 
> This saves a few line of code.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Simon Horman <simon.horman@netronome.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gtp: simplify error handling code in 'gtp_encap_enable()'
@ 2020-01-06  8:59   ` Simon Horman
  0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2020-01-06  8:59 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: pablo, laforge, davem, osmocom-net-gprs, netdev, linux-kernel,
	kernel-janitors

On Sun, Jan 05, 2020 at 06:36:07PM +0100, Christophe JAILLET wrote:
> 'gtp_encap_disable_sock(sk)' handles the case where sk is NULL, so there
> is no need to test it before calling the function.
> 
> This saves a few line of code.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Simon Horman <simon.horman@netronome.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gtp: simplify error handling code in 'gtp_encap_enable()'
  2020-01-05 17:36 ` Christophe JAILLET
@ 2020-01-06 21:39   ` David Miller
  -1 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2020-01-06 21:39 UTC (permalink / raw)
  To: christophe.jaillet
  Cc: pablo, laforge, osmocom-net-gprs, netdev, linux-kernel, kernel-janitors

From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date: Sun,  5 Jan 2020 18:36:07 +0100

> 'gtp_encap_disable_sock(sk)' handles the case where sk is NULL, so there
> is no need to test it before calling the function.
> 
> This saves a few line of code.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied to net-next.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gtp: simplify error handling code in 'gtp_encap_enable()'
@ 2020-01-06 21:39   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2020-01-06 21:39 UTC (permalink / raw)
  To: christophe.jaillet
  Cc: pablo, laforge, osmocom-net-gprs, netdev, linux-kernel, kernel-janitors

From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date: Sun,  5 Jan 2020 18:36:07 +0100

> 'gtp_encap_disable_sock(sk)' handles the case where sk is NULL, so there
> is no need to test it before calling the function.
> 
> This saves a few line of code.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied to net-next.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-01-06 21:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-05 17:36 [PATCH] gtp: simplify error handling code in 'gtp_encap_enable()' Christophe JAILLET
2020-01-05 17:36 ` Christophe JAILLET
2020-01-06  8:59 ` Simon Horman
2020-01-06  8:59   ` Simon Horman
2020-01-06 21:39 ` David Miller
2020-01-06 21:39   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.