[apparmor] [patch 13/26] Move buffer management for the interface to C++ ostringstream class
Seth Arnold
seth.arnold at canonical.com
Thu Apr 17 06:57:29 UTC 2014
On Tue, Apr 15, 2014 at 10:22:20AM -0700, john.johansen at canonical.com wrote:
> includes sbeattie's pad calculation fix.
>
> Signed-off-by: John Johansen <john.johansen at canonical.com>
Acked-by: Seth Arnold <seth.arnold at canonical.com>
Wow, what a cleanup. :) that must have felt good.
Does it still make sense to have 'inline' in front of all these function
declarations? They feel complicated enough that I have trouble believing
they could be inlined.
> +inline void sd_write8(std::ostringstream &buf, u8 b)
> {
> + buf.write((const char *) &b, 1);
> }
This could use buf.put(b) instead, if any function could be inlined this
would be the one you'd most want... Taking the address of a copied
parameter prevents it from just living in a register, right?
> +inline void sd_write_name(std::ostringstream &buf, const char *name)
> {
> PDEBUG("Writing name '%s'\n", name);
> if (name) {
> + sd_write8(buf, SD_NAME);
> + sd_write16(buf, strlen(name) + 1);
> + buf.write(name, strlen(name) + 1);
> }
> }
I think we should store aside strlen(name)+1 to avoid recomputing this.
> if (profile->net.allow && kernel_supports_network) {
> size_t i;
> + sd_write_array(buf, "net_allowed_af", get_af_max());
> for (i = 0; i < get_af_max(); i++) {
And here, also, I think we should store aside get_af_max() to avoid
recomputing it each loop iteration.
Thanks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140416/3f18ac30/attachment.pgp>
More information about the AppArmor
mailing list