Skip to contentSkip to conversation

linearize.h: sanitize header

PATCH In review Kamil Dudka 3 participants 9 messages Aug 6, 2009 Sparse checker

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linearize.h: sanitize header

Hello,

please consider applying the attached one-line patch. Feel free to choose better identifiers if these are not accurate enough. Thanks!

Kamil

From 4ad2c5943c1d0b16a19feefe721ebc53a4875a35 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <[email protected]>
Date: Thu, 6 Aug 2009 10:54:56 +0200
Subject: [PATCH] linearize.h: sanitize header

It's unfortunate to use 'true' and 'false' as identifiers in a system header. It clashes with corresponding macros from <stdbool.h> when included before <sparse/linearize.h>.

---
 linearize.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
linearize.h +1 -1
index 2205082..50b3601 100644
@@ -328,7 +328,7 @@ struct entrypoint {
 	struct instruction *entry;
 };
 
-extern void insert_select(struct basic_block *bb, struct instruction *br, struct instruction *phi, pseudo_t true, pseudo_t false);
+extern void insert_select(struct basic_block *bb, struct instruction *br, struct instruction *phi, pseudo_t if_true, pseudo_t if_false);
 extern void insert_branch(struct basic_block *bb, struct instruction *br, struct basic_block *target);
 
 pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, int size);
Signature · 1 line
1.6.2.5
#2 lore raw
In reply to Hannes Eder
Quoted 18 lines · On Thu August 6 2009 11:23:26 Hannes Eder wrote:
Quoted 17 lines · Kamil Dudka

It's unfortunate to use 'true' and 'false' as identifiers in a system header. It clashes with corresponding macros from <stdbool.h> when included before <sparse/linearize.h>.

---
 linearize.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
linearize.h +0 -0
index 2205082..50b3601 100644
@@ -328,7 +328,7 @@ struct entrypoint {
        struct instruction *entry;
 };
 
Quoted 7 lines
Quoted 4 lines
linearize.h +0 -1
-extern void insert_select(struct basic_block *bb, struct instruction
 *br, struct instruction *phi, pseudo_t true, pseudo_t false); +extern

void insert_select(struct basic_block *bb, struct instruction *br, struct instruction *phi, pseudo_t if_true, pseudo_t if_false);

I guess it is wise to change this in linearize.c as well. Mind sending a patch?

The question is if we need/want to :-) It's change of the working code for no real benefit. I am talking only about system-wide headers which can be included anywhere.

Kamil

#1 lore raw
In reply to Kamil Dudka
Quoted 14 lines · Kamil Dudka

It's unfortunate to use 'true' and 'false' as identifiers in a system header. It clashes with corresponding macros from <stdbool.h> when included before <sparse/linearize.h>.

---
 linearize.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
linearize.h +0 -0
index 2205082..50b3601 100644

linearize.h struct entrypoint { · line 331

Quoted 5 lines
linearize.h +1 -1
@@ -328,7 +328,7 @@ struct entrypoint {
        struct instruction *entry;
 };
 
-extern void insert_select(struct basic_block *bb, struct instruction *br, struct instruction *phi, pseudo_t true, pseudo_t false);
+extern void insert_select(struct basic_block *bb, struct instruction *br, struct instruction *phi, pseudo_t if_true, pseudo_t if_false);

I guess it is wise to change this in linearize.c as well. Mind sending a patch?

linearize.h struct entrypoint { · line 334

Quoted 3 lines
linearize.h +0 -0
 extern void insert_branch(struct basic_block *bb, struct instruction *br, struct basic_block *target);
 
 pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, int size);

Cheers,
-Hannes

#3 lore raw
In reply to Kamil Dudka
Quoted 27 lines · Kamil Dudka
Quoted 18 lines · On Thu August 6 2009 11:23:26 Hannes Eder wrote:
Quoted 17 lines · Kamil Dudka

It's unfortunate to use 'true' and 'false' as identifiers in a system header. It clashes with corresponding macros from <stdbool.h> when included before <sparse/linearize.h>.

---
 linearize.h |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
linearize.h +0 -0
index 2205082..50b3601 100644
@@ -328,7 +328,7 @@ struct entrypoint {
         struct instruction *entry;
  };
 
Quoted 7 lines
Quoted 4 lines
linearize.h +0 -1
-extern void insert_select(struct basic_block *bb, struct instruction
 *br, struct instruction *phi, pseudo_t true, pseudo_t false); +extern

void insert_select(struct basic_block *bb, struct instruction *br, struct instruction *phi, pseudo_t if_true, pseudo_t if_false);

I guess it is wise to change this in linearize.c as well.  Mind sending a patch?

Quoted 3 lines

The question is if we need/want to :-) It's change of the working code for no real benefit. I am talking only about system-wide headers which can be included anywhere.

Well I see at least one benefit, a small one though. Syntax highlighting is somewhat confused with "true" and "false", at least emacs is. They appear like the constants, where in fact they are variables.

The likelyhood to break the code by renaming this two variables is kinda low, no? And IHMO it was not so wise in the first place to pick these names. ;)

My 2 cents
-Hannes
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 11 lines · On Thu August 6 2009 11:39:11 Hannes Eder wrote:
Quoted 6 lines
Quoted 2 lines

I guess it is wise to change this in linearize.c as well. Mind sending a patch?

The question is if we need/want to :-) It's change of the working code for no real benefit. I am talking only about system-wide headers which can be included anywhere.

Well I see at least one benefit, a small one though. Syntax highlighting is somewhat confused with "true" and "false", at least emacs is. They appear like the constants, where in fact they are variables.

I can confirm it's the same case with the vim's syntax highlighter.

Quoted 3 lines

The likelyhood to break the code by renaming this two variables is kinda low, no? And IHMO it was not so wise in the first place to pick these names. ;)

I would contend that only two variables are affected. They are if we consider only headers. However the situation is much worse when we concern about .c files. The patch would be non-trivial. Please try the following command:

$ grep --color '[^_]false[^_]' *.c

Kamil

#5 lore raw
Quoted 19 lines · Kamil Dudka
Quoted 11 lines · On Thu August 6 2009 11:39:11 Hannes Eder wrote:
Quoted 6 lines
Quoted 2 lines

I guess it is wise to change this in linearize.c as well.  Mind sending a patch?

The question is if we need/want to :-) It's change of the working code for no real benefit. I am talking only about system-wide headers which can be included anywhere.

Well I see at least one benefit, a small one though.  Syntax highlighting is somewhat confused with "true" and "false", at least emacs is.  They appear like the constants, where in fact they are variables.

I can confirm it's the same case with the vim's syntax highlighter.

Quoted 3 lines

The likelyhood to break the code by renaming this two variables is kinda low, no?  And IHMO it was not so wise in the first place to pick these names. ;)

Quoted 5 lines

I would contend that only two variables are affected. They are if we consider only headers. However the situation is much worse when we concern about .c files. The patch would be non-trivial. Please try the following command:

$ grep --color '[^_]false[^_]' *.c
$ grep --color '\bfalse\b\|\btrue\b' *.c | wc -l
91

some of them are just in comments, does not look to scary to me. If others agree that its a good idea to rename them, I can do it if you don't want to.

-Hannes
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#6 lore raw
Quoted 8 lines · Hannes Eder
Quoted 1 line
$ grep --color '[^_]false[^_]' *.c
$ grep --color '\bfalse\b\|\btrue\b' *.c | wc -l
91

some of them are just in comments, does not look to scary to me.  If others agree that its a good idea to rename them, I can do it if you don't want to.

I would just apply the change to the header file and related variables. The linearize.h is consider an API header file for other sparse application to use. So we'd better not assume too much on the sparse caller side.

I agree with Kamil that rename variable in linearize.c offer no real benefits. I consider it more of a personal preference thing. And it is internal to linearize.c. At this point renaming variable will mess up with annotations. It is not good enough reason to do it just to make the editor happy.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
Quoted 9 lines · On Thursday 06 of August 2009 19:10:30 Christopher Li wrote:

I would just apply the change to the header file and related variables. The linearize.h is consider an API header file for other sparse application to use. So we'd better not assume too much on the sparse caller side.

I agree with Kamil that rename variable in linearize.c offer no real benefits. I consider it more of a personal preference thing. And it is internal to linearize.c. At this point renaming variable will mess up with annotations. It is not good enough reason to do it just to make the editor happy.

Well, let's make a tradeoff - we can only change the identifiers in linearize.h and the corresponding identifiers in linearize.c. I admit it could be confusing when we have different identifiers in the prototype and different identifiers in the function body. New version of the patch is attached.

Kamil

From 4d4c71eb876351d53e0f8edf0f121950ec2a9a84 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <[email protected]>
Date: Thu, 6 Aug 2009 19:20:51 +0200
Subject: [PATCH] linearize.h: sanitize header

It's unfortunate to use 'true' and 'false' as identifiers in a system header. It clashes with corresponding macros from <stdbool.h> when included before <sparse/linearize.h>.

---
 linearize.c |    6 +++---
 linearize.h |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
linearize.c +3 -3
index 1a19214..238ee5d 100644
@@ -666,7 +666,7 @@ void insert_branch(struct basic_block *bb, struct instruction *jmp, struct basic
 }
 	
 
-void insert_select(struct basic_block *bb, struct instruction *br, struct instruction *phi_node, pseudo_t true, pseudo_t false)
+void insert_select(struct basic_block *bb, struct instruction *br, struct instruction *phi_node, pseudo_t if_true, pseudo_t if_false)
 {
 	pseudo_t target;
 	struct instruction *select;
@@ -685,8 +685,8 @@ void insert_select(struct basic_block *bb, struct instruction *br, struct instru
 	select->target = target;
 	target->def = select;
 
-	use_pseudo(select, true, &select->src2);
-	use_pseudo(select, false, &select->src3);
+	use_pseudo(select, if_true, &select->src2);
+	use_pseudo(select, if_false, &select->src3);
 
 	add_instruction(&bb->insns, select);
 	add_instruction(&bb->insns, br);
linearize.h +1 -1
index 2205082..50b3601 100644
@@ -328,7 +328,7 @@ struct entrypoint {
 	struct instruction *entry;
 };
 
-extern void insert_select(struct basic_block *bb, struct instruction *br, struct instruction *phi, pseudo_t true, pseudo_t false);
+extern void insert_select(struct basic_block *bb, struct instruction *br, struct instruction *phi, pseudo_t if_true, pseudo_t if_false);
 extern void insert_branch(struct basic_block *bb, struct instruction *br, struct basic_block *target);
 
 pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, int size);
Signature · 1 line
1.6.3.3
Acked-by
#8 lore raw
Quoted 11 lines · Kamil Dudka
Quoted 9 lines · On Thursday 06 of August 2009 19:10:30 Christopher Li wrote:

I would just apply the change to the header file and related variables. The linearize.h is consider an API header file for other sparse application to use. So we'd better not assume too much on the sparse caller side.

I agree with Kamil that rename variable in linearize.c offer no real benefits. I consider it more of a personal preference thing. And it is internal to linearize.c. At this point renaming variable will mess up with annotations. It is not good enough reason to do it just to make the editor happy.

Quoted 5 lines

Well, let's make a tradeoff - we can only change the identifiers in linearize.h and the corresponding identifiers in linearize.c. I admit it could be confusing when we have different identifiers in the prototype and different identifiers in the function body. New version of the patch is attached.

LGTM

Best,
-Hannes