Skip to contentSkip to conversation

: Compilation warnings in xfrm_user.c.

PATCH Applied Denis V. Lunev 3 participants 5 messages Apr 14, 2008 – Apr 15, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : Compilation warnings in xfrm_user.c.

When CONFIG_SECURITY_NETWORK_XFRM is undefined the following warnings appears:
net/xfrm/xfrm_user.c: In function 'xfrm_add_pol_expire':
net/xfrm/xfrm_user.c:1576: warning: 'ctx' may be used uninitialized in this function net/xfrm/xfrm_user.c: In function 'xfrm_get_policy':
net/xfrm/xfrm_user.c:1340: warning: 'ctx' may be used uninitialized in this function (security_xfrm_policy_alloc is noop for the case).

It seems that they are result of the commit
03e1ad7b5d871d4189b1da3125c2f12d1b5f7d0b

---
 net/xfrm/xfrm_user.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
net/xfrm/xfrm_user.c +4 -4
index b822b56..1810f56 100644
@@ -1343,14 +1343,14 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
 		if (err)
 			return err;
 
+		ctx = NULL;
 		if (rt) {
 			struct xfrm_user_sec_ctx *uctx = nla_data(rt);
 
 			err = security_xfrm_policy_alloc(&ctx, uctx);
 			if (err)
 				return err;
-		} else
-			ctx = NULL;
+		}
 		xp = xfrm_policy_bysel_ctx(type, p->dir, &p->sel, ctx,
 					   delete, &err);
 		security_xfrm_policy_free(ctx);
@@ -1579,14 +1579,14 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
 		if (err)
 			return err;
 
+		ctx = NULL;
 		if (rt) {
 			struct xfrm_user_sec_ctx *uctx = nla_data(rt);
 
 			err = security_xfrm_policy_alloc(&ctx, uctx);
 			if (err)
 				return err;
-		} else
-			ctx = NULL;
+		}
 		xp = xfrm_policy_bysel_ctx(type, p->dir, &p->sel, ctx, 0, &err);
 		security_xfrm_policy_free(ctx);
 	}
Signature · 1 line
1.5.3.rc5
#1 lore raw
Quoted 26 lines · Denis V. Lunev

When CONFIG_SECURITY_NETWORK_XFRM is undefined the following warnings
appears: net/xfrm/xfrm_user.c: In function 'xfrm_add_pol_expire':
net/xfrm/xfrm_user.c:1576: warning: 'ctx' may be used uninitialized in this function net/xfrm/xfrm_user.c: In function 'xfrm_get_policy':
net/xfrm/xfrm_user.c:1340: warning: 'ctx' may be used uninitialized in this function (security_xfrm_policy_alloc is noop for the case).

It seems that they are result of the commit
03e1ad7b5d871d4189b1da3125c2f12d1b5f7d0b

---
 net/xfrm/xfrm_user.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
net/xfrm/xfrm_user.c +1 -0
index b822b56..1810f56 100644
@@ -1343,14 +1343,14 @@ static int xfrm_get_policy(struct sk_buff
 *skb, struct nlmsghdr *nlh, if (err)
 			return err;
 
+		ctx = NULL;
 		if (rt) {
 			struct xfrm_user_sec_ctx *uctx = nla_data(rt);

net/xfrm/xfrm_user.c static int xfrm_get_policy(struct sk_buff · line 1356

Quoted 10 lines
net/xfrm/xfrm_user.c +1 -2
 
 			err = security_xfrm_policy_alloc(&ctx, uctx);
 			if (err)
 				return err;
-		} else
-			ctx = NULL;
+		}
 		xp = xfrm_policy_bysel_ctx(type, p->dir, &p->sel, ctx,
 					   delete, &err);
 		security_xfrm_policy_free(ctx);

Thanks for catching this, I was focusing more on the runtime issues with the else statement and forgot about compile time issues. I wonder if it would be better to fix this in the dummy function for security_xfrm_policy_alloc()? It seems cleaner to me.

Signature · 2 lines
paul moore
linux @ hp
maintainer
#2 lore raw

From: Paul Moore <[email protected]>
Date: Mon, 14 Apr 2008 10:35:46 -0400

Quoted 4 lines

Thanks for catching this, I was focusing more on the runtime issues with the else statement and forgot about compile time issues. I wonder if it would be better to fix this in the dummy function for security_xfrm_policy_alloc()? It seems cleaner to me.

I think in this specific case the choice is arbitrary, which is why I applied his patch.

maintainer Applied
#3 lore raw
In reply to Denis V. Lunev

From: "Denis V. Lunev" <[email protected]>
Date: Mon, 14 Apr 2008 17:03:39 +0400

Quoted 9 lines

When CONFIG_SECURITY_NETWORK_XFRM is undefined the following warnings appears:
net/xfrm/xfrm_user.c: In function 'xfrm_add_pol_expire':
net/xfrm/xfrm_user.c:1576: warning: 'ctx' may be used uninitialized in this function net/xfrm/xfrm_user.c: In function 'xfrm_get_policy':
net/xfrm/xfrm_user.c:1340: warning: 'ctx' may be used uninitialized in this function (security_xfrm_policy_alloc is noop for the case).

It seems that they are result of the commit
03e1ad7b5d871d4189b1da3125c2f12d1b5f7d0b

Needs commit header-line text reference after commit ID, which I've added. I think I've mentioned this issue to you on several occaisions already :-/

Quoted 1 line

Applied, thanks.

#4 lore raw
Quoted 10 lines · David Miller

From: "Denis V. Lunev" <[email protected]>
Date: Mon, 14 Apr 2008 17:03:39 +0400

Quoted 7 lines

When CONFIG_SECURITY_NETWORK_XFRM is undefined the following warnings appears:
net/xfrm/xfrm_user.c: In function 'xfrm_add_pol_expire':
net/xfrm/xfrm_user.c:1576: warning: 'ctx' may be used uninitialized in this function net/xfrm/xfrm_user.c: In function 'xfrm_get_policy':
net/xfrm/xfrm_user.c:1340: warning: 'ctx' may be used uninitialized in this function (security_xfrm_policy_alloc is noop for the case).

Quoted 6 lines
Quoted 2 lines

It seems that they are result of the commit
03e1ad7b5d871d4189b1da3125c2f12d1b5f7d0b

Needs commit header-line text reference after commit ID, which I've added. I think I've mentioned this issue to you on several occaisions already :-/

got it again. Thank you.