linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2] Fix core dump on anonymous symbol.
@ 2007-02-10  0:15 Christopher Li
  2007-02-23  4:33 ` Josh Triplett
  0 siblings, 1 reply; 2+ messages in thread
From: Christopher Li @ 2007-02-10  0:15 UTC (permalink / raw)
  To: linux-sparse; +Cc: Josh Triplett


Using the following can generate anonymous symbol without
initializer expression.

	return (struct foo) {};

It would be nice if sparse does not crash on it.

Signed-Off-By: Christopher Li <sparse@chrisli.org>

Index: sparse/linearize.c
===================================================================
--- sparse.orig/linearize.c	2007-01-30 19:47:10.000000000 -0800
+++ sparse/linearize.c	2007-01-30 19:47:54.000000000 -0800
@@ -116,14 +116,16 @@ const char *show_pseudo(pseudo_t pseudo)
 		}
 		expr = sym->initializer;
 		snprintf(buf, 64, "<anon symbol:%p>", sym);
-		switch (expr->type) {
-		case EXPR_VALUE:
-			snprintf(buf, 64, "<symbol value: %lld>", expr->value);
-			break;
-		case EXPR_STRING:
-			return show_string(expr->string);
-		default:
-			break;
+		if (expr) {
+			switch (expr->type) {
+			case EXPR_VALUE:
+				snprintf(buf, 64, "<symbol value: %lld>", expr->value);
+				break;
+			case EXPR_STRING:
+				return show_string(expr->string);
+			default:
+				break;
+			}
 		}
 		break;
 	}

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

end of thread, other threads:[~2007-02-23  4:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-10  0:15 [PATCH 2] Fix core dump on anonymous symbol Christopher Li
2007-02-23  4:33 ` Josh Triplett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).