Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=fd21150a0fe10c504160db359a4eb425576f6e7d
Commit:     fd21150a0fe10c504160db359a4eb425576f6e7d
Parent:     15901a2746e6a2dbe03043609f1575c2bcf726e8
Author:     Thomas Graf <[EMAIL PROTECTED]>
AuthorDate: Thu Sep 6 03:28:08 2007 -0700
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Wed Oct 10 16:48:26 2007 -0700

    [XFRM] netlink: Inline attach_encap_tmpl(), attach_sec_ctx(), and 
attach_one_addr()
    
    These functions are only used once and are a lot easier to understand if
    inlined directly into the function.
    
    Fixes by Masahide NAKAMURA.
    
    Signed-off-by: Thomas Graf <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 net/xfrm/xfrm_user.c |   66 +++++++++++++-------------------------------------
 1 files changed, 17 insertions(+), 49 deletions(-)

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 70dca1e..9e516f5 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -214,23 +214,6 @@ static int attach_one_algo(struct xfrm_algo **algpp, u8 
*props,
        return 0;
 }
 
-static int attach_encap_tmpl(struct xfrm_encap_tmpl **encapp, struct nlattr 
*rta)
-{
-       struct xfrm_encap_tmpl *p, *uencap;
-
-       if (!rta)
-               return 0;
-
-       uencap = nla_data(rta);
-       p = kmemdup(uencap, sizeof(*p), GFP_KERNEL);
-       if (!p)
-               return -ENOMEM;
-
-       *encapp = p;
-       return 0;
-}
-
-
 static inline int xfrm_user_sec_ctx_size(struct xfrm_sec_ctx *xfrm_ctx)
 {
        int len = 0;
@@ -242,33 +225,6 @@ static inline int xfrm_user_sec_ctx_size(struct 
xfrm_sec_ctx *xfrm_ctx)
        return len;
 }
 
-static int attach_sec_ctx(struct xfrm_state *x, struct nlattr *u_arg)
-{
-       struct xfrm_user_sec_ctx *uctx;
-
-       if (!u_arg)
-               return 0;
-
-       uctx = nla_data(u_arg);
-       return security_xfrm_state_alloc(x, uctx);
-}
-
-static int attach_one_addr(xfrm_address_t **addrpp, struct nlattr *rta)
-{
-       xfrm_address_t *p, *uaddrp;
-
-       if (!rta)
-               return 0;
-
-       uaddrp = nla_data(rta);
-       p = kmemdup(uaddrp, sizeof(*p), GFP_KERNEL);
-       if (!p)
-               return -ENOMEM;
-
-       *addrpp = p;
-       return 0;
-}
-
 static void copy_from_user_state(struct xfrm_state *x, struct xfrm_usersa_info 
*p)
 {
        memcpy(&x->id, &p->id, sizeof(x->id));
@@ -348,15 +304,27 @@ static struct xfrm_state *xfrm_state_construct(struct 
xfrm_usersa_info *p,
                                   xfrm_calg_get_byname,
                                   attrs[XFRMA_ALG_COMP])))
                goto error;
-       if ((err = attach_encap_tmpl(&x->encap, attrs[XFRMA_ENCAP])))
-               goto error;
-       if ((err = attach_one_addr(&x->coaddr, attrs[XFRMA_COADDR])))
-               goto error;
+
+       if (attrs[XFRMA_ENCAP]) {
+               x->encap = kmemdup(nla_data(attrs[XFRMA_ENCAP]),
+                                  sizeof(*x->encap), GFP_KERNEL);
+               if (x->encap == NULL)
+                       goto error;
+       }
+
+       if (attrs[XFRMA_COADDR]) {
+               x->coaddr = kmemdup(nla_data(attrs[XFRMA_COADDR]),
+                                   sizeof(*x->coaddr), GFP_KERNEL);
+               if (x->coaddr == NULL)
+                       goto error;
+       }
+
        err = xfrm_init_state(x);
        if (err)
                goto error;
 
-       if ((err = attach_sec_ctx(x, attrs[XFRMA_SEC_CTX])))
+       if (attrs[XFRMA_SEC_CTX] &&
+           security_xfrm_state_alloc(x, nla_data(attrs[XFRMA_SEC_CTX])))
                goto error;
 
        x->km.seq = p->seq;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to