]> err.no Git - linux-2.6/blobdiff - kernel/taskstats.c
[NET]: Possible cleanups.
[linux-2.6] / kernel / taskstats.c
index 8adfb8069c6d52be1893b8bd26175d7da9aac838..d3d28919d4b494a026701fb4c87426c99111fe7f 100644 (file)
@@ -77,7 +77,7 @@ static int prepare_reply(struct genl_info *info, u8 cmd, struct sk_buff **skbp,
        /*
         * If new attributes are added, please revisit this allocation
         */
-       skb = nlmsg_new(genlmsg_total_size(size), GFP_KERNEL);
+       skb = genlmsg_new(size, GFP_KERNEL);
        if (!skb)
                return -ENOMEM;
 
@@ -85,13 +85,9 @@ static int prepare_reply(struct genl_info *info, u8 cmd, struct sk_buff **skbp,
                int seq = get_cpu_var(taskstats_seqnum)++;
                put_cpu_var(taskstats_seqnum);
 
-               reply = genlmsg_put(skb, 0, seq,
-                               family.id, 0, 0,
-                               cmd, family.version);
+               reply = genlmsg_put(skb, 0, seq, &family, 0, cmd);
        } else
-               reply = genlmsg_put(skb, info->snd_pid, info->snd_seq,
-                               family.id, 0, 0,
-                               cmd, family.version);
+               reply = genlmsg_put_reply(skb, info, &family, 0, cmd);
        if (reply == NULL) {
                nlmsg_free(skb);
                return -EINVAL;
@@ -411,7 +407,7 @@ static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
        return send_reply(rep_skb, info->snd_pid);
 
 nla_put_failure:
-       return genlmsg_cancel(rep_skb, reply);
+       rc = genlmsg_cancel(rep_skb, reply);
 err:
        nlmsg_free(rep_skb);
        return rc;
@@ -454,10 +450,9 @@ void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
        int is_thread_group;
        struct nlattr *na;
 
-       if (!family_registered || !tidstats)
+       if (!family_registered)
                return;
 
-       rc = 0;
        /*
         * Size includes space for nested attributes
         */
@@ -465,8 +460,15 @@ void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
                nla_total_size(sizeof(struct taskstats)) + nla_total_size(0);
 
        is_thread_group = (tsk->signal->stats != NULL);
-       if (is_thread_group)
-               size = 2 * size;        /* PID + STATS + TGID + STATS */
+       if (is_thread_group) {
+               /* PID + STATS + TGID + STATS */
+               size = 2 * size;
+               /* fill the tsk->signal->stats structure */
+               fill_tgid_exit(tsk);
+       }
+
+       if (!tidstats)
+               return;
 
        rc = prepare_reply(NULL, TASKSTATS_CMD_NEW, &rep_skb, &reply, size);
        if (rc < 0)
@@ -486,11 +488,8 @@ void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
                goto send;
 
        /*
-        * tsk has/had a thread group so fill the tsk->signal->stats structure
         * Doesn't matter if tsk is the leader or the last group member leaving
         */
-
-       fill_tgid_exit(tsk);
        if (!group_dead)
                goto send;
 
@@ -507,7 +506,6 @@ send:
 
 nla_put_failure:
        genlmsg_cancel(rep_skb, reply);
-       goto ret;
 err_skb:
        nlmsg_free(rep_skb);
 ret: