Subject: Re: [RFC v2 00/10] snet: Security for NETwork syscalls

From: Samir Bellabes <[email-masked]>
Date: Sat, 06 Mar 2010 19:20:26 +0100

Tetsuo Handa <[email-masked]> writes:

> Regarding [RFC v2 06/10] snet: introduce snet_hooks
> +                       if ((verdict = snet_ticket_check(&info)) != SNET_VERDICT_NONE)
>
> Please avoid assignment in "if" statement, as scripts/checkpatch.pl suggests.

Right, I should have run script/checkpatch.pl on this set of patches. I
won't miss it next time. 

Thanks Tetsuo.
sam

>>From ea2234c07ea1bf76579ba127c8a8be6ab276515f Mon Sep 17 00:00:00 2001
From: Samir Bellabes <[email-masked]>
Date: Sat, 6 Mar 2010 17:49:22 +0100
Subject: [PATCH 3/3] snet: avoid assigment in if statement

Noticed by Tetsuo Handa <[email-masked]>

Signed-off-by: Samir Bellabes <[email-masked]>
---
 security/snet/snet_hooks.c |   37 +++++++++++++++++++++++++------------
 1 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/security/snet/snet_hooks.c b/security/snet/snet_hooks.c
index 689babe..d9cf0b9 100644
--- a/security/snet/snet_hooks.c
+++ b/security/snet/snet_hooks.c
@@ -160,7 +160,8 @@ static int snet_socket_bind(struct socket *sock,
 			info.dst.u3.ip = inet->inet_daddr;
 			info.src.u.port = ntohs(a->sin_port);
 			/* check tickets */
-			if ((verdict = snet_ticket_check(&info)) != SNET_VERDICT_NONE)
+			verdict = snet_ticket_check(&info) ;
+			if (verdict != SNET_VERDICT_NONE)
 				goto out;
 			/* inserting verdict PENDING */
 			info.verdict_id = snet_verdict_insert();
@@ -173,7 +174,8 @@ static int snet_socket_bind(struct socket *sock,
 			       sizeof(info.dst.u3.ip6));
 			info.src.u.port = ntohs(a6->sin6_port);
 			/* check tickets */
-			if ((verdict = snet_ticket_check(&info)) != SNET_VERDICT_NONE)
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
 				goto out;
 			/* inserting verdict PENDING */
 			info.verdict_id = snet_verdict_insert();
@@ -229,7 +231,8 @@ static int snet_socket_connect(struct socket *sock,
 			info.dst.u3.ip = a->sin_addr.s_addr;
 			info.dst.u.port = ntohs(a->sin_port);
 			/* check tickets */
-			if ((verdict = snet_ticket_check(&info)) != SNET_VERDICT_NONE)
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
 				goto out;
 			/* inserting verdict PENDING */
 			info.verdict_id = snet_verdict_insert();
@@ -242,7 +245,8 @@ static int snet_socket_connect(struct socket *sock,
 			       sizeof(info.dst.u3.ip6));
 			info.dst.u.port = ntohs(a6->sin6_port);
 			/* check tickets */
-			if ((verdict = snet_ticket_check(&info)) != SNET_VERDICT_NONE)
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
 				goto out;
 			/* inserting verdict PENDING */
 			info.verdict_id = snet_verdict_insert();
@@ -295,7 +299,8 @@ static int snet_socket_listen(struct socket *sock, int backlog)
 			info.src.u3.ip = inet->inet_saddr;
 			info.dst.u3.ip = inet->inet_daddr;
 			/* check tickets */
-			if ((verdict = snet_ticket_check(&info)) != SNET_VERDICT_NONE)
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
 				goto out;
 			/* inserting verdict PENDING */
 			info.verdict_id = snet_verdict_insert();
@@ -306,7 +311,9 @@ static int snet_socket_listen(struct socket *sock, int backlog)
 			       sizeof(info.src.u3.ip6));
 			memcpy(&info.dst.u3.ip6, (void *)&inet->pinet6->daddr,
 			       sizeof(info.dst.u3.ip6));
-			if ((verdict = snet_ticket_check(&info)) != SNET_VERDICT_NONE)
+			/* check tickets */
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
 				goto out;
 			/* inserting verdict PENDING */
 			info.verdict_id = snet_verdict_insert();
@@ -358,7 +365,8 @@ static int snet_socket_accept(struct socket *sock, struct socket *newsock)
 			info.src.u3.ip = inet->inet_saddr;
 			info.dst.u3.ip = inet->inet_daddr;
 			/* check tickets */
-			if ((verdict = snet_ticket_check(&info)) != SNET_VERDICT_NONE)
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
 				goto out;
 			/* inserting verdict PENDING */
 			info.verdict_id = snet_verdict_insert();
@@ -370,7 +378,8 @@ static int snet_socket_accept(struct socket *sock, struct socket *newsock)
 			memcpy(&info.dst.u3.ip6, (void *)&inet->pinet6->daddr,
 			       sizeof(info.dst.u3.ip6));
 			/* check tickets */
-			if ((verdict = snet_ticket_check(&info)) != SNET_VERDICT_NONE)
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
 				goto out;
 			/* inserting verdict PENDING */
 			info.verdict_id = snet_verdict_insert();
@@ -470,7 +479,8 @@ static int snet_socket_sendmsg(struct socket *sock,
 			info.src.u3.ip = inet->inet_saddr;
 			info.dst.u3.ip = inet->inet_daddr;
 			/* check tickets */
-			if ((verdict = snet_ticket_check(&info)) != SNET_VERDICT_NONE)
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
 				goto out;
 			/* inserting verdict PENDING */
 			info.verdict_id = snet_verdict_insert();
@@ -482,7 +492,8 @@ static int snet_socket_sendmsg(struct socket *sock,
 			memcpy(&info.dst.u3.ip6, (void *)&inet->pinet6->daddr,
 			       sizeof(info.dst.u3.ip6));
 			/* check tickets */
-			if ((verdict = snet_ticket_check(&info)) != SNET_VERDICT_NONE)
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
 				goto out;
 			/* inserting verdict PENDING */
 			info.verdict_id = snet_verdict_insert();
@@ -535,7 +546,8 @@ static int snet_socket_recvmsg(struct socket *sock,
 			info.src.u3.ip = inet->inet_saddr;
 			info.dst.u3.ip = inet->inet_daddr;
 			/* check tickets */
-			if ((verdict = snet_ticket_check(&info)) != SNET_VERDICT_NONE)
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
 				goto out;
 			/* inserting verdict PENDING */
 			info.verdict_id = snet_verdict_insert();
@@ -547,7 +559,8 @@ static int snet_socket_recvmsg(struct socket *sock,
 			memcpy(&info.dst.u3.ip6, (void *)&inet->pinet6->daddr,
 			       sizeof(info.dst.u3.ip6));
 			/* check tickets */
-			if ((verdict = snet_ticket_check(&info)) != SNET_VERDICT_NONE)
+			verdict = snet_ticket_check(&info);
+			if (verdict != SNET_VERDICT_NONE)
 				goto out;
 			/* inserting verdict PENDING */
 			info.verdict_id = snet_verdict_insert();
-- 
1.6.3.3