Skip to contentSkip to conversation

Sparse on Cygwin (and git).

PATCH Applied Ramsay Jones 2 participants 3 messages May 22, 2007 – May 24, 2007 Sparse checker

lore
Share & tools
lore
#0 lore raw

cover Sparse on Cygwin (and git).

Hi Josh,

Since git uses sparse in it's "check" make target, I decided to download the (then current) 0.2 tar-ball and see what sparse was about. Unfortunately, at present, I am using cygwin on win32 until I get around to installing Linux. ;-) Hence, the following patch series...

0001-Add-support-for-WIN32-attribute-names.patch
0002-Fix-an-__attribute__-parsing-error.patch
0003-Add-cygwin-support-to-cgcc.patch
0004-Fix-a-Wtypesign-bug.patch

Well, when the 0.3 tar-ball was released, I had to update the patch series. Changes to the attribute parsing code meant an update to patch 0001 was required. Patch 0004 now seems to be unnecessary (probably due to commit ef2596162115bfdc2a1d3639ac99dd3ba2a71af2). Also compilation errors lead to the introduction of two new patches (1&2/5), as follows ...

0001-Fix-an-attribute-__sentinel__-unknown-warning.patch 0002-Fix-some-enum-value-XXX-not-handled-in-switch-wa.patch 0003-Add-support-for-WIN32-attribute-names.patch 0004-Fix-an-__attribute__-parsing-error.patch 0005-Add-cygwin-support-to-cgcc.patch

As I am somewhat bandwidth challenged, until recently, I had never cloned a git repository (not even the git repo). So, last week I cloned the sparse repository; thankfully it only took about ten minutes (yep a slow pipe!). Thus, again I had to update the patch series. Patch 0003 overlapped a recent commit (baf2c5a8) by Michael Stefaniuc and patch 0004 required an update due to handle_attributes() gaining a third parameter. So the final patch series is:

0001-Fix-an-__sentinel__-attribute-directive-ignored.patch 0002-Fix-some-enum-value-XXX-not-handled-in-switch-wa.patch 0003-Add-more-support-for-WIN32-attribute-names.patch 0004-Fix-an-__attribute__-parsing-error.patch 0005-Add-cygwin-support-to-cgcc.patch

which was built on top of: 0.3-15-gb5bd30f

I have attached "0004-Fix-a-Wtypesign-bug.patch" simply out of interest, as it does not require the parameter type of "function returning..." to decay to "pointer to function returning...". The test case comes from git:

$cat tsb.c

typedef int erf(const char *r, const unsigned char *s, int f, void *c);

extern int fer(erf, void *);

static int ar(const char *r, const unsigned char *s, int f, void *c)

{
	return 0;
}

int main (int argc, char *argv[])

{
	fer(ar, (void *)0);
}

$

Hope you find this useful.

All the best,

Ramsay Jones

From 99b3a18f82cdeb221ae0b817e0c5d71ba31fd273 Mon Sep 17 00:00:00 2001
From: Ramsay Jones <[email protected]>
Date: Mon, 21 May 2007 15:48:52 +0100
Subject: [PATCH] Fix a -Wtypesign bug.

---
 evaluate.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
evaluate.c +4 -2
index ca49ed0..5308827 100644
@@ -669,7 +669,7 @@ const char * type_difference(struct symbol *target, struct symbol *source,
 			target = target->ctype.base_type;
 			if (!target)
 				return "bad types";
-			if (target->type == SYM_PTR) {
+			if (target->type == SYM_PTR || target->type == SYM_FN) {
 				mod1 = 0;
 				as1 = 0;
 			}	
@@ -680,7 +680,7 @@ const char * type_difference(struct symbol *target, struct symbol *source,
 			source = source->ctype.base_type;
 			if (!source)
 				return "bad types";
-			if (source->type == SYM_PTR) {
+			if (source->type == SYM_PTR || source->type == SYM_FN) {
 				mod2 = 0;
 				as2 = 0;
 			}
@@ -718,6 +718,7 @@ const char * type_difference(struct symbol *target, struct symbol *source,
 			case SYM_FN:
 				type1 = SYM_FN;
 				target = base1;
+				mod1 = target->ctype.modifiers;
 				base1 = base1->ctype.base_type;
 			default:
 				/* nothing */;
@@ -729,6 +730,7 @@ const char * type_difference(struct symbol *target, struct symbol *source,
 			case SYM_FN:
 				type2 = SYM_FN;
 				source = base2;
+				mod2 = source->ctype.modifiers;
 				base2 = base2->ctype.base_type;
 			default:
 				/* nothing */;
Signature · 1 line
1.5.1

typedef int erf(const char *r, const unsigned char *s, int f, void *c);

extern int fer(erf, void *);

static int ar(const char *r, const unsigned char *s, int f, void *c)

{
	return 0;
}

int main (int argc, char *argv[])

{
	fer(ar, (void *)0);
}
#1 lore raw
Quoted 1 line · Ramsay Jones

Since git uses sparse in it's "check" make target,

Cool; I didn't know that. :)

Quoted 2 lines

I decided to download the
(then current) 0.2 tar-ball and see what sparse was about.

Great!

Quoted 2 lines

Unfortunately, at present,
I am using cygwin on win32 until I get around to installing Linux. ;-)

Fortunately, that resulted in some excellent patches. :)

[...]

Quoted 3 lines

As I am somewhat bandwidth challenged, until recently, I had never cloned a git repository (not even the git repo). So, last week I cloned the sparse repository; thankfully it only took about ten minutes (yep a slow pipe!).

I think you'll find that keeping the git repo up-to-date requires quite a bit less bandwidth than the initial checkout.

Quoted 1 line

Thus, again I had to update the patch series.

In general, you'll probably run into conflicts if you try to generate patches from the last release tarball, especially on frequently changed files like ident-list.h and the attribute table.

Quoted 5 lines

Patch 0003 overlapped a
recent commit (baf2c5a8) by Michael Stefaniuc and patch 0004 required an update due to handle_attributes() gaining a third parameter. So the final patch series is:

Quoted 7 lines

0001-Fix-an-__sentinel__-attribute-directive-ignored.patch 0002-Fix-some-enum-value-XXX-not-handled-in-switch-wa.patch 0003-Add-more-support-for-WIN32-attribute-names.patch 0004-Fix-an-__attribute__-parsing-error.patch 0005-Add-cygwin-support-to-cgcc.patch

which was built on top of: 0.3-15-gb5bd30f

Looks like a good set of patches. However, only patches 3 and 4 seem to have hit the list.

- Josh Triplett

#2 lore raw
Quoted 4 lines · Josh Triplett
Quoted 1 line · Ramsay Jones

Since git uses sparse in it's "check" make target,

Cool; I didn't know that. :)

heh, I don't know how often git developers "make check" ;-)

[...]

Quoted 5 lines
Quoted 2 lines

Unfortunately, at present,
I am using cygwin on win32 until I get around to installing Linux. ;-)

Fortunately, that resulted in some excellent patches. :)

Apart from the whitespace breakage!

Quoted 7 lines

[...]

Quoted 6 lines

0001-Fix-an-__sentinel__-attribute-directive-ignored.patch 0002-Fix-some-enum-value-...-not-handled-in-switch-wa.patch 0003-Add-more-support-for-WIN32-attribute-names.patch 0004-Fix-an-__attribute__-parsing-error.patch 0005-Add-cygwin-support-to-cgcc.patch

Quoted 5 lines
Quoted 1 line

which was built on top of: 0.3-15-gb5bd30f

Looks like a good set of patches. However, only patches 3 and 4 seem to have hit the list.

Patch 2 was bounced by the vger spam blocker (because of the 3 uppercase x chars).

ATB,

Ramsay Jones