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]
Message-ID: <84144f020710270447m6f77848fl1f0c43312d172309@mail.gmail.com>
Date:	Sat, 27 Oct 2007 14:47:09 +0300
From:	"Pekka Enberg" <penberg@...helsinki.fi>
To:	"Rusty Russell" <rusty@...tcorp.com.au>
Cc:	"Matthew Wilcox" <matthew@....cx>,
	"Linus Torvalds" <torvalds@...l.org>,
	"Andrew Morton" <akpm@...l.org>, linux-kernel@...r.kernel.org,
	"Matthew Wilcox" <willy@...ux.intel.com>
Subject: Re: [PATCH 1/4] stringbuf: A string buffer implementation

Hi Rusty,

On 10/26/07, Rusty Russell <rusty@...tcorp.com.au> wrote:
>        This just seems like more optimization and complexity that we need.  Interfaces
> using vsnprintf don't seem like good candidates for optimization.
>
> How about this?  It's as simple as I could make it...

FWIW I like this patch better.

On 10/26/07, Rusty Russell <rusty@...tcorp.com.au> wrote:
> +void sb_printf_append(struct stringbuf **sb, gfp_t gfp, const char *fmt, ...)
> +{
> +       unsigned int fmtlen, len;
> +       va_list args;
> +       struct stringbuf *oldsb = *sb;
> +
> +       if (oldsb->buf == enomem_string)
> +               return;
> +
> +       va_start(args, fmt);
> +       fmtlen = vsnprintf(NULL, 0, fmt, args);
> +       va_end(args);
> +
> +       len = oldsb ? strlen(oldsb->buf) : 0;
> +       *sb = krealloc(oldsb, len + fmtlen + 1, gfp);
> +       if (!*sb) {
> +               kfree(oldsb);
> +               *sb = (struct stringbuf *)enomem_string;

Why don't we just return -ENOMEM here just like all other APIs in the
kernel? And I wonder if it makes more sense to store gfp_flags in
struct stringbuf and always use that? I mean, why would you want to
sometimes do GFP_ATOMIC and GFP_KERNEL allocations for the same
buffer?

                                  Pekka
-
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