Skip to contentSkip to conversation

Compile sparse executable under it's own name, not as "check"

PATCH Applied Pavel Roskin 2 participants 6 messages Nov 3, 2006 – Nov 6, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 Compile sparse executable under it's own name, not as "check"

From: Pavel Roskin <[email protected]>

No need to confuse everyone. Besides, it allows to use "make check" for some something meaningful in the future.

---

 Makefile |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)
Makefile +3 -8
index ccf9f89..da4a47a 100644
@@ -21,7 +21,7 @@ CFLAGS += -DDEBUG
 
 PREFIX=$(HOME)
 BINDIR=$(PREFIX)/bin
-PROGRAMS=test-lexing test-parsing obfuscate check compile graph test-linearize example test-unssa test-dissect
+PROGRAMS=test-lexing test-parsing obfuscate compile graph sparse test-linearize example test-unssa test-dissect
 
 LIB_H=    token.h parse.h lib.h symbol.h scope.h expression.h target.h \
 	  linearize.h bitmap.h ident-list.h compat.h flow.h allocate.h \
@@ -39,12 +39,7 @@ LIBS=$(LIB_FILE)
 
 all: $(PROGRAMS) $(SLIB_FILE)
 
-#
-# Install the 'check' binary as 'sparse', just to confuse people.
-#
-#		"The better to keep you on your toes, my dear".
-#
-install: check $(SLIB_FILE) bin-dir
+install: sparse $(SLIB_FILE) bin-dir
 	if test $< -nt $(BINDIR)/sparse ; then install -v $< $(BINDIR)/sparse ; install -v $(SLIB_FILE) $(BINDIR) ; fi
 
 bin-dir:
@@ -74,7 +69,7 @@ compile: compile.o compile-i386.o $(LIBS
 obfuscate: obfuscate.o $(LIBS)
 	$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
 
-check: check.o $(LIBS)
+sparse: check.o $(LIBS)
 	$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
 
 graph: graph.o $(LIBS)
#1 lore raw

PATCH 2/4 Install cgcc on "make install", refactor installation code

From: Pavel Roskin <[email protected]>

---

 Makefile |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
Makefile +5 -2
index da4a47a..61c7953 100644
@@ -22,6 +22,7 @@ CFLAGS += -DDEBUG
 PREFIX=$(HOME)
 BINDIR=$(PREFIX)/bin
 PROGRAMS=test-lexing test-parsing obfuscate compile graph sparse test-linearize example test-unssa test-dissect
+INST_PROGRAMS=sparse cgcc
 
 LIB_H=    token.h parse.h lib.h symbol.h scope.h expression.h target.h \
 	  linearize.h bitmap.h ident-list.h compat.h flow.h allocate.h \
@@ -39,8 +40,10 @@ LIBS=$(LIB_FILE)
 
 all: $(PROGRAMS) $(SLIB_FILE)
 
-install: sparse $(SLIB_FILE) bin-dir
-	if test $< -nt $(BINDIR)/sparse ; then install -v $< $(BINDIR)/sparse ; install -v $(SLIB_FILE) $(BINDIR) ; fi
+install: $(INST_PROGRAMS) $(SLIB_FILE) bin-dir
+	for f in $(INST_PROGRAMS) $(SLIB_FILE); do \
+		install -v $$f $(BINDIR)/$$f || exit 1; \
+	done
 
 bin-dir:
 	@if ! test -d $(BINDIR); then \
#2 lore raw

PATCH 3/4 Add support for __builtin_strpbrk()

In reply to Pavel Roskin

From: Pavel Roskin <[email protected]>

---

 lib.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
lib.c +1 -0
index 81e756d..3f753f0 100644
@@ -479,6 +479,7 @@ void declare_builtin_functions(void)
 	add_pre_buffer("extern char *__builtin_strncpy(char *, const char *, __SIZE_TYPE__);\n");
 	add_pre_buffer("extern __SIZE_TYPE__ __builtin_strspn(const char *, const char *);\n");
 	add_pre_buffer("extern __SIZE_TYPE__ __builtin_strcspn(const char *, const char *);\n");
+	add_pre_buffer("extern char * __builtin_strpbrk(const char *, const char *);\n");
 
 	/* And some random ones.. */
 	add_pre_buffer("extern void *__builtin_return_address(unsigned int);\n");
#3 lore raw

PATCH 4/4 Typo fixes

In reply to Pavel Roskin

From: Pavel Roskin <[email protected]>

---

 evaluate.c                                   |    2 +-
 example.c                                    |    4 ++--
 expand.c                                     |    2 +-
 inline.c                                     |    2 +-
 memops.c                                     |    2 +-
 pre-process.c                                |    2 +-
 simplify.c                                   |    2 +-
 symbol.c                                     |    2 +-
 validation/initializer-entry-defined-twice.c |    2 +-
 9 files changed, 10 insertions(+), 10 deletions(-)
evaluate.c +1 -1
index 6fb6be2..ca49ed0 100644
@@ -1475,7 +1475,7 @@ static struct symbol *evaluate_dereferen
 
 	switch (ctype->type) {
 	default:
-		sparse_error(expr->pos, "cannot derefence this type");
+		sparse_error(expr->pos, "cannot dereference this type");
 		return NULL;
 	case SYM_PTR:
 		node->ctype.modifiers = target->ctype.modifiers & MOD_SPECIFIER;
example.c +2 -2
index 7e30c22..7c2bae3 100644
@@ -942,7 +942,7 @@ static void generate_commutative_binop(s
 	if (!is_dead_reg(state, src1, reg1))
 		goto do_switch;
 
-	/* Both are dead. Is one preferrable? */
+	/* Both are dead. Is one preferable? */
 	if (reg2 != preferred_reg(state, insn->target))
 		goto dont_switch;
 
@@ -1493,7 +1493,7 @@ static void write_reg_to_storage(struct
 
 		/* Fall back on stack allocation ... */
 		alloc_stack(state, storage);
-		/* Fallthroigh */
+		/* Fallthrough */
 	default:
 		output_insn(state, "movl %s,%s", reg->name, show_memop(storage));
 		return;
expand.c +1 -1
index a34d07d..90f7f36 100644
@@ -562,7 +562,7 @@ static int expand_dereference(struct exp
 	/*
 	 * NOTE! We get a bogus warning right now for some special
 	 * cases: apparently I've screwed up the optimization of
-	 * a zero-offset derefence, and the ctype is wrong.
+	 * a zero-offset dereference, and the ctype is wrong.
 	 *
 	 * Leave the warning in anyway, since this is also a good
 	 * test for me to get the type evaluation right..
inline.c +1 -1
index 81530d1..77adfab 100644
@@ -428,7 +428,7 @@ static struct statement *copy_one_statem
 }
 
 /*
- * Copy a stateemnt tree from 'src' to 'dst', where both
+ * Copy a statement tree from 'src' to 'dst', where both
  * source and destination are of type STMT_COMPOUND.
  *
  * We do this for the tree-level inliner.
memops.c +1 -1
index 8fd777d..bdecf14 100644
@@ -69,7 +69,7 @@ found_dominator:
  * we can no longer really use "container()" to get from a user to
  * the instruction that uses it.
  *
- * This happens to work, simply because the likelyhood of the
+ * This happens to work, simply because the likelihood of the
  * (possibly non-instruction) containing the right bitpattern
  * in the right place is pretty low. But this is still wrong.
  *
pre-process.c +1 -1
index 08d1a2e..81a535e 100644
@@ -630,7 +630,7 @@ static int already_tokenized(const char
 	return 0;
 }
 
-/* Hande include of header files.
+/* Handle include of header files.
  * The relevant options are made compatible with gcc. The only options that
  * are not supported is -withprefix and friends.
  *
simplify.c +1 -1
index 495f5d3..a8b736b 100644
@@ -550,7 +550,7 @@ offset:
 
 /*
  * We walk the whole chain of adds/subs backwards. That's not
- * only more efficient, but it allows us to find looops.
+ * only more efficient, but it allows us to find loops.
  */
 static int simplify_memop(struct instruction *insn)
 {
symbol.c +1 -1
index 6c91112..a9b26b5 100644
@@ -360,7 +360,7 @@ static struct symbol *examine_pointer_ty
 	 * We need to set the pointer size first, and
 	 * examine the thing we point to only afterwards.
 	 * That's because this pointer type may end up
-	 * being needed for the base type size evalutation.
+	 * being needed for the base type size evaluation.
 	 */
 	if (!sym->bit_size)
 		sym->bit_size = bits_in_pointer;
validation/initializer-entry-defined-twice.c +1 -1
index 80434f1..58f314b 100644
@@ -29,7 +29,7 @@ struct has_union union_error = {
 };
 
 /* Empty structures can make two fields have the same offset in a struct.
- * Initialzing both should not trigger the warning. */
+ * Initializing both should not trigger the warning. */
 struct empty { };
 
 struct same_offset {
#4 lore raw
In reply to Pavel Roskin

I've applied this series of four patches; thanks.

Your "typo fixes" patch also reminded me that I needed to fix the typo in the name of "validation/bad-assignement.c", which I have now done.

Regarding your comment about using "make check" for something more useful, I would greatly welcome a patch which actually checked sparse against all the files in validation/ and tested what those files intended to test. As far as I can tell, it looks like some of them may not work as intended right now; for example, it looks like validation/builtin_safe1.c expects __attribute__((pure)) and __attribute__((const)) to work and mark a function as side-effect-free, which doesn't currently happen in sparse.

- Josh Triplett

#5 lore raw

Hi Josh,

Quoted 7 lines · Josh Triplett

Regarding your comment about using "make check" for something more useful, I would greatly welcome a patch which actually checked sparse against all the files in validation/ and tested what those files intended to test. As far as I can tell, it looks like some of them may not work as intended right now; for example, it looks like validation/builtin_safe1.c expects __attribute__((pure)) and __attribute__((const)) to work and mark a function as side-effect-free, which doesn't currently happen in sparse.

I've just mailed a very primitive testsuite.

I would prefer to have a test list and lists for "should be bad" and "known to fail", but it would have to use double loops or some shell tricks (e.g. using environment variables as a hash), so I opted for the simplest approach for now.

By the way, I'm not sure how to distinguish sparse errors from sparse warnings short of grepping stderr. For now, any stderr output is an error.

Signature · 2 lines
Regards,
Pavel Roskin