Re: [PATCH 1/4] stringbuf: A string buffer implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue 2007-10-23 17:12:43, Matthew Wilcox wrote:
> Consecutive calls to printk are non-atomic, which leads to various
> implementations for accumulating strings which can be printed in one call.
> This is a generic string buffer which can also be used for non-printk
> purposes.  There is no sb_scanf implementation yet as I haven't identified
> a user for it.

GFP_ATOMIC alloca5tion there is bad news. It can randomly fail.....
without good method of handling that in caller.
							Pavel
> +/*
> + * Convert the stringbuf to a string.  It is the caller's responsibility
> + * to free the string.  The stringbuf is then ready to be reused.
> + */
> +static inline char *sb_to_string(struct stringbuf *sb)
> +{
> +	char *s = sb->s;
> +	if (sb_error(sb))
> +		s = kstrdup(s, GFP_ATOMIC);
> +	sb_init(sb);
> +	return s;
> +}

							Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux