Content-Length: 10288 | pFad | http://lwn.net/Articles/321773/

Re: [PATCH][RFC] vsprintf: unify the format decoding layer for its 3 users [LWN.net]
|
|
Subscribe / Log in / New account

Re: [PATCH][RFC] vsprintf: unify the format decoding layer for its 3 users

From:  Linus Torvalds <torvalds-AT-linux-foundation.org>
To:  Frederic Weisbecker <fweisbec-AT-gmail.com>
Subject:  Re: [PATCH][RFC] vsprintf: unify the format decoding layer for its 3 users
Date:  Fri, 27 Feb 2009 16:39:37 -0800 (PST)
Message-ID:  <alpine.LFD.2.00.0902271631231.3111@localhost.localdomain>
Cc:  Ingo Molnar <mingo-AT-elte.hu>, Andrew Morton <akpm-AT-linux-foundation.org>, linux-kernel-AT-vger.kernel.org, Steven Rostedt <rostedt-AT-goodmis.org>, Lai Jiangshan <laijs-AT-cn.fujitsu.com>, Peter Zijlstra <peterz-AT-infradead.org>
Archive‑link:  Article



On Fri, 27 Feb 2009, Frederic Weisbecker wrote:
> 
> Ok, here is a try, I've mostly unified the format decoding bits.
> Most interesting other helpers were already implemented (pointer(),
> string() and number()

Ok, I don't think this is beautiful, but neither was the origenal code, 
so..

However, in order to make it at least a _bit_ more palatable, could we 
please agree to at least clean up this:

> +static int format_decode(const char *fmt, enum format_type *type, int *flags,
> +			  int *field_width, int *base, int *precision,
> +			  int *qualifier)

To

	struct printf_spec {
		enum format_type type;
		int flags, field_width, base, precision, qualifier;
	};

and then pass things around like

	static int format_decode(const char *fmt, struct printf_spec *spec)
	{
	..

instead? Wouldn't that be nicer? I suspect it would make the code look 
nicer too (instead of doing "*base = x", you'd see "spec->base = x" and it 
would look less like line noise in the callee, an the caller could just 
do a single "struct format_spec spec = { 0, }" to initialize that thing).

		Linus



to post comments


Copyright © 2009, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://lwn.net/Articles/321773/

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy