[git commit master 1/1] vfprintf.c: reduce a chunk of #ifdef forest and remove one goto inside it

Denys Vlasenko dvlasenk at redhat.com
Tue Oct 19 13:07:00 UTC 2010


commit: http://git.uclibc.org/uClibc/commit/?id=71dcf8f4401b27f2b7446601a6d0dbcddc0aa8b4
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

No code changes according to objdump.

Signed-off-by: Denys Vlasenko <dvlasenk at redhat.com>
---
 libc/stdio/_vfprintf.c |   41 ++++++++++++++++++++---------------------
 1 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/libc/stdio/_vfprintf.c b/libc/stdio/_vfprintf.c
index 8c5e0e7..3b00708 100644
--- a/libc/stdio/_vfprintf.c
+++ b/libc/stdio/_vfprintf.c
@@ -1055,31 +1055,30 @@ int attribute_hidden _ppfs_parsespec(ppfs_t *ppfs)
 		if (*fmt == 'm') {
 			ppfs->conv_num = CONV_m;
 			ppfs->num_data_args = 0;
-			goto DONE;
-		}
+		} else
 #endif
-#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__
-		/* Handle custom arg -- WARNING -- overwrites p!!! */
-		ppfs->conv_num = CONV_custom0;
-		p = _custom_printf_spec;
-		do {
-			if (*p == *fmt) {
-				printf_arginfo_function *fp = _custom_printf_arginfo[(int)(p - _custom_printf_spec)];
-				ppfs->num_data_args = fp(&(ppfs->info), MAX_ARGS_PER_SPEC, argtype + 2);
-				if (ppfs->num_data_args > MAX_ARGS_PER_SPEC) {
-					break;		/* Error -- too many args! */
+		{
+#ifndef __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__
+			return -1;  /* Error */
+#else
+			/* Handle custom arg -- WARNING -- overwrites p!!! */
+			ppfs->conv_num = CONV_custom0;
+			p = _custom_printf_spec;
+			while (1) {
+				if (*p == *fmt) {
+					printf_arginfo_function *fp = _custom_printf_arginfo[(int)(p - _custom_printf_spec)];
+					ppfs->num_data_args = fp(&(ppfs->info), MAX_ARGS_PER_SPEC, argtype + 2);
+					if (ppfs->num_data_args > MAX_ARGS_PER_SPEC) {
+						return -1;  /* Error -- too many args! */
+					}
+					break;
 				}
-				goto DONE;
+				if (++p >= (_custom_printf_spec + MAX_USER_SPEC))
+					return -1;  /* Error */
 			}
-		} while (++p < (_custom_printf_spec + MAX_USER_SPEC));
-#endif /* __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__ */
-		/* Otherwise error. */
-		return -1;
-	}
-
-#if defined(__UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__) || defined(__UCLIBC_HAS_PRINTF_M_SPEC__)
- DONE:
 #endif
+		}
+	}
 
 #ifdef NL_ARGMAX
 	if (maxposarg > 0) {
-- 
1.7.1



More information about the uClibc-cvs mailing list