mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 7/7] vsprintf: factor out skip_space code in a separate  function
@ 2009-11-02 17:26 André Goddard Rosa
  2009-11-02 19:27 ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: André Goddard Rosa @ 2009-11-02 17:26 UTC (permalink / raw)
  To: Frederic Weisbecker, laijs, mingo, davem, akpm, harvey.harrison,
	linux list
  Cc: me

>From 584d9bfc7c1d41b76a05655b4562b98fcbef6ee4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Goddard=20Rosa?= <andre.goddard@gmail.com>
Date: Sun, 1 Nov 2009 14:09:06 -0200
Subject: [PATCH v2 7/7] vsprintf: factor out skip_space code in a
separate function
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It decreases code size:
   text    data     bss     dec     hex filename
  15703       0       8   15711    3d5f lib/vsprintf.o-before
  15527       0       8   15535    3caf lib/vsprintf.o-after

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
---
 lib/vsprintf.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 957e252..c3b19d7 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1745,6 +1745,13 @@ EXPORT_SYMBOL_GPL(bprintf);

 #endif /* CONFIG_BINARY_PRINTF */

+static noinline const char *skip_space(const char *str)
+{
+	while (isspace(*str))
+		++str;
+	return str;
+}
+
 /**
  * vsscanf - Unformat a buffer into a list of arguments
  * @buf:	input buffer
@@ -1766,10 +1773,8 @@ int vsscanf(const char *buf, const char *fmt,
va_list args)
 		 * white space, including none, in the input.
 		 */
 		if (isspace(*fmt)) {
-			while (isspace(*fmt))
-				++fmt;
-			while (isspace(*str))
-				++str;
+			fmt = skip_space(fmt);
+			str = skip_space(str);
 		}

 		/* anything that is not a conversion must match exactly */
@@ -1839,8 +1844,7 @@ int vsscanf(const char *buf, const char *fmt,
va_list args)
 			if (field_width == -1)
 				field_width = INT_MAX;
 			/* first, skip leading white space in buffer */
-			while (isspace(*str))
-				str++;
+			str = skip_space(str);

 			/* now copy until next white space */
 			while (*str && !isspace(*str) && field_width--)
@@ -1882,8 +1886,7 @@ int vsscanf(const char *buf, const char *fmt,
va_list args)
 		/* have some sort of integer conversion.
 		 * first, skip white space in buffer.
 		 */
-		while (isspace(*str))
-			str++;
+		str = skip_space(str);

 		digit = *str;
 		if (is_sign && digit == '-')
-- 
1.6.5.2.140.g5f809

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 7/7] vsprintf: factor out skip_space code in a separate function
  2009-11-02 17:26 [PATCH v2 7/7] vsprintf: factor out skip_space code in a separate function André Goddard Rosa
@ 2009-11-02 19:27 ` Ingo Molnar
  2009-11-04 14:25   ` André Goddard Rosa
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2009-11-02 19:27 UTC (permalink / raw)
  To: André Goddard Rosa
  Cc: Frederic Weisbecker, laijs, davem, akpm, harvey.harrison, linux list


* André Goddard Rosa <andre.goddard@gmail.com> wrote:

> >From 584d9bfc7c1d41b76a05655b4562b98fcbef6ee4 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Andr=C3=A9=20Goddard=20Rosa?= <andre.goddard@gmail.com>
> Date: Sun, 1 Nov 2009 14:09:06 -0200
> Subject: [PATCH v2 7/7] vsprintf: factor out skip_space code in a
> separate function
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit

btw., for reviewability's sake, could you please fix your patch 
submission method to not include such garbled headers in the mail body?

(Also, it would be nice to reply-thread the 7 patches on the 0/7 mail, 
as git-send-email does.)

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 7/7] vsprintf: factor out skip_space code in a separate  function
  2009-11-02 19:27 ` Ingo Molnar
@ 2009-11-04 14:25   ` André Goddard Rosa
  2009-11-04 14:49     ` [PATCH v3 " André Goddard Rosa
  0 siblings, 1 reply; 4+ messages in thread
From: André Goddard Rosa @ 2009-11-04 14:25 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Frederic Weisbecker, laijs, davem, akpm, harvey.harrison, linux list

Hi, Ingo!

On Mon, Nov 2, 2009 at 5:27 PM, Ingo Molnar <mingo@elte.hu> wrote:
>
> * André Goddard Rosa <andre.goddard@gmail.com> wrote:
>
>> >From 584d9bfc7c1d41b76a05655b4562b98fcbef6ee4 Mon Sep 17 00:00:00 2001
>> From: =?UTF-8?q?Andr=C3=A9=20Goddard=20Rosa?= <andre.goddard@gmail.com>
>> Date: Sun, 1 Nov 2009 14:09:06 -0200
>> Subject: [PATCH v2 7/7] vsprintf: factor out skip_space code in a
>> separate function
>> MIME-Version: 1.0
>> Content-Type: text/plain; charset=UTF-8
>> Content-Transfer-Encoding: 8bit
>
> btw., for reviewability's sake, could you please fix your patch
> submission method to not include such garbled headers in the mail body?
>
> (Also, it would be nice to reply-thread the 7 patches on the 0/7 mail,
> as git-send-email does.)
>

I had some discussion about these headers on git mailing list (
http://marc.info/?t=125726599400002&r=1&w=2 ).

So, I'd like to know if it's preferred to remove all these headers
altogether or leave them by just removing the
commit # line and fixing the "From: " line.

What do you think?

p.s.: I'll probably use git-send-email in a second moment -- have to
fix my environment first
https://bugzilla.novell.com/show_bug.cgi?id=525780

Thanks,
André

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 7/7] vsprintf: factor out skip_space code in a separate  function
  2009-11-04 14:25   ` André Goddard Rosa
@ 2009-11-04 14:49     ` André Goddard Rosa
  0 siblings, 0 replies; 4+ messages in thread
From: André Goddard Rosa @ 2009-11-04 14:49 UTC (permalink / raw)
  To: Frederic Weisbecker, laijs, mingo, davem, akpm, harvey.harrison,
	linux list
  Cc: me

From: André Goddard Rosa <andre.goddard@gmail.com>
Date: Tue, 3 Nov 2009 11:02:09 -0200
Subject: [PATCH v3 7/7] vsprintf: factor out skip_space code in a
separate function
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It decreases code size:
   text    data     bss     dec     hex filename
  15719       0       8   15727    3d6f lib/vsprintf.o-before
  15543       0       8   15551    3cbf lib/vsprintf.o-after

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 lib/vsprintf.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index f703fdf..566c947 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1736,6 +1736,13 @@ EXPORT_SYMBOL_GPL(bprintf);

 #endif /* CONFIG_BINARY_PRINTF */

+static noinline const char *skip_space(const char *str)
+{
+	while (isspace(*str))
+		++str;
+	return str;
+}
+
 /**
  * vsscanf - Unformat a buffer into a list of arguments
  * @buf:	input buffer
@@ -1757,10 +1764,8 @@ int vsscanf(const char *buf, const char *fmt,
va_list args)
 		 * white space, including none, in the input.
 		 */
 		if (isspace(*fmt)) {
-			while (isspace(*fmt))
-				++fmt;
-			while (isspace(*str))
-				++str;
+			fmt = skip_space(fmt);
+			str = skip_space(str);
 		}

 		/* anything that is not a conversion must match exactly */
@@ -1830,8 +1835,7 @@ int vsscanf(const char *buf, const char *fmt,
va_list args)
 			if (field_width == -1)
 				field_width = INT_MAX;
 			/* first, skip leading white space in buffer */
-			while (isspace(*str))
-				str++;
+			str = skip_space(str);

 			/* now copy until next white space */
 			while (*str && !isspace(*str) && field_width--)
@@ -1873,8 +1877,7 @@ int vsscanf(const char *buf, const char *fmt,
va_list args)
 		/* have some sort of integer conversion.
 		 * first, skip white space in buffer.
 		 */
-		while (isspace(*str))
-			str++;
+		str = skip_space(str);

 		digit = *str;
 		if (is_sign && digit == '-')
-- 
1.6.5.2.143.g8cc62.dirty

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-04 14:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-02 17:26 [PATCH v2 7/7] vsprintf: factor out skip_space code in a separate function André Goddard Rosa
2009-11-02 19:27 ` Ingo Molnar
2009-11-04 14:25   ` André Goddard Rosa
2009-11-04 14:49     ` [PATCH v3 " André Goddard Rosa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®