lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 2 Nov 2006 11:34:02 +0100
From:	Thomas Graf <tgraf@...g.ch>
To:	Oleg Nesterov <oleg@...sign.ru>
Cc:	Andrew Morton <akpm@...l.org>,
	Shailabh Nagar <nagar@...son.ibm.com>,
	Balbir Singh <balbir@...ibm.com>, Jay Lan <jlan@....com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] taskstats: factor out reply assembling

* Oleg Nesterov <oleg@...sign.ru> 2006-11-01 21:26
> Introduce mk_reply() helper which does all nla_put()s on reply.
> 
> Saves 453 bytes and a preparation for the next patch.
> 
> Signed-off-by: Oleg Nesterov <oleg@...sign.ru>
> 
>  taskstats.c |   55 ++++++++++++++++++++++++++++---------------------------
>  1 files changed, 28 insertions(+), 27 deletions(-)
> 
> --- STATS/kernel/taskstats.c~5_factor	2006-10-31 16:33:56.000000000 +0300
> +++ STATS/kernel/taskstats.c	2006-11-01 14:00:03.000000000 +0300
> @@ -348,6 +348,25 @@ static int parse(struct nlattr *na, cpum
>  	return ret;
>  }
>  
> +static int mk_reply(struct sk_buff *skb, int type, u32 pid, struct taskstats *stats)
> +{
> +	struct nlattr *na;
> +	int aggr;
> +
> +	aggr = TASKSTATS_TYPE_AGGR_TGID;
> +	if (type == TASKSTATS_TYPE_PID)
> +		aggr = TASKSTATS_TYPE_AGGR_PID;
> +
> +	na = nla_nest_start(skb, aggr);
> +	NLA_PUT_U32(skb, type, pid);
> +	NLA_PUT_TYPE(skb, struct taskstats, TASKSTATS_TYPE_STATS, *stats);
> +	nla_nest_end(skb, na);
> +
> +	return 0;
> +nla_put_failure:
> +	return -1;
> +}

nla_nest_start() may return NULL, either rely on prepare_reply() to be
correct and BUG() on failure or do proper error handling for all
functions.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ