[PATCH 2/3] scanner: fix writing i586 descriptions

Olivier Blin dev at blino.org
Sun Oct 14 15:49:12 PDT 2012


This moves desc as first argument of desc_dump().
Description writing was broken on i586 because desc_dump() used
va_arg() after a vsnprintf() call to find the last argument.
But after calling a function with a va_arg argument, this arguments is
undefined.
---
 src/scanner.c | 39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/src/scanner.c b/src/scanner.c
index 9696107..c09a88f 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -158,15 +158,14 @@ static const char *indent(int n)
 }
 
 static void
-desc_dump(const char *fmt, ...)
+desc_dump(char *desc, const char *fmt, ...)
 {
 	va_list ap;
-	char buf[128], *desc, hang;
+	char buf[128], hang;
 	int col, i, j, k, startcol;
 
 	va_start(ap, fmt);
 	vsnprintf(buf, sizeof buf, fmt, ap);
-	desc = va_arg(ap, char *);
 	va_end(ap);
 
 	for (i = 0, col = 0; buf[i] != '*'; i++) {
@@ -709,18 +708,19 @@ emit_enumerations(struct interface *interface)
 
 		if (desc) {
 			printf("/**\n");
-			desc_dump(" * %s_%s - ",
-				  interface->name, e->name, desc->summary);
+			desc_dump(desc->summary,
+				  " * %s_%s - ",
+				  interface->name, e->name);
 			wl_list_for_each(entry, &e->entry_list, link) {
-				desc_dump(" * @%s_%s_%s: ",
+				desc_dump(entry->summary,
+					  " * @%s_%s_%s: ",
 					  interface->uppercase_name,
 					  e->uppercase_name,
-					  entry->uppercase_name,
-					  entry->summary);
+					  entry->uppercase_name);
 			}
 			if (desc->text) {
 				printf(" *\n");
-				desc_dump(" * ", desc->text);
+				desc_dump(desc->text, " * ");
 			}
 			printf(" */\n");
 		}
@@ -750,14 +750,15 @@ emit_structs(struct wl_list *message_list, struct interface *interface)
 	if (interface->description) {
 		struct description *desc = interface->description;
 		printf("/**\n");
-		desc_dump(" * %s - ", interface->name, desc->summary);
+		desc_dump(desc->summary, " * %s - ", interface->name);
 		wl_list_for_each(m, message_list, link) {
 			struct description *mdesc = m->description;
-			desc_dump(" * @%s: ",
-				  m->name, mdesc ? mdesc->summary : "(none)");
+			desc_dump(mdesc ? mdesc->summary : "(none)",
+				  " * @%s: ",
+				  m->name);
 		}
 		printf(" *\n");
-		desc_dump(" * ", desc->text);
+		desc_dump(desc->text, " * ");
 		printf(" */\n");
 	}
 	printf("struct %s_%s {\n", interface->name,
@@ -767,15 +768,17 @@ emit_structs(struct wl_list *message_list, struct interface *interface)
 		struct description *mdesc = m->description;
 
 		printf("\t/**\n");
-		desc_dump("\t * %s - ",
-			  m->name, mdesc ? mdesc->summary : "(none)");
+		desc_dump(mdesc ? mdesc->summary : "(none)",
+			   "\t * %s - ",
+			   m->name);
 		wl_list_for_each(a, &m->arg_list, link) {
-			desc_dump("\t * @%s: ",
-				  a->name, a->summary ? a->summary : "(none)");
+			desc_dump(a->summary ? a->summary : "(none)",
+				  "\t * @%s: ",
+				  a->name);
 		}
 		if (mdesc) {
 			printf("\t *\n");
-			desc_dump("\t * ", mdesc->text);
+			desc_dump(mdesc->text, "\t * ");
 		}
 		if (m->since > 1) {
 			printf("\t * @since: %d\n", m->since);
-- 
1.7.12.3



More information about the wayland-devel mailing list