linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christopher Li <sparse@chrisli.org>
To: linux-sparse@vger.kernel.org
Cc: Josh Triplett <josh@freedesktop.org>
Subject: [PATCH 2] Fix core dump on anonymous symbol.
Date: Fri, 9 Feb 2007 16:15:40 -0800	[thread overview]
Message-ID: <20070210001540.GA20644@chrisli.org> (raw)


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;
 	}

             reply	other threads:[~2007-02-10  0:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-10  0:15 Christopher Li [this message]
2007-02-23  4:33 ` [PATCH 2] Fix core dump on anonymous symbol Josh Triplett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070210001540.GA20644@chrisli.org \
    --to=sparse@chrisli.org \
    --cc=josh@freedesktop.org \
    --cc=linux-sparse@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).