* [PATCH] sparse: gcc 4.1 warnings
@ 2006-04-08 4:14 Jeff Garzik
2006-04-10 13:21 ` Morten Welinder
0 siblings, 1 reply; 6+ messages in thread
From: Jeff Garzik @ 2006-04-08 4:14 UTC (permalink / raw)
To: linux-sparse
This patch kills the sparse warnings that appeared for me on FC5/x86-64,
which uses gcc 4.1.0.
Note this MAY OR MAY NOT be the right thing to do; I didn't audit each
location to see if checking the return value would be more appropriate.
Signed-off-by: Jeff Garzik <jeff@garzik.org>
diff --git a/compile-i386.c b/compile-i386.c
index d61652e..158b879 100644
--- a/compile-i386.c
+++ b/compile-i386.c
@@ -472,12 +472,12 @@ static inline void push_cstring(struct f
atom->string = str;
atom->label = label;
- add_ptr_list(&f->str_list, atom); /* note: _not_ atom_list */
+ (void) add_ptr_list(&f->str_list, atom); /* note: _not_ atom_list */
}
static inline void push_atom(struct function *f, struct atom *atom)
{
- add_ptr_list(&f->atom_list, atom);
+ (void) add_ptr_list(&f->atom_list, atom);
}
static void push_text_atom(struct function *f, const char *text)
@@ -518,7 +518,7 @@ static struct storage *stack_alloc(int n
f->stack_size += n_bytes;
f->pseudo_nr++;
- add_ptr_list(&f->pseudo_list, stor);
+ (void) add_ptr_list(&f->pseudo_list, stor);
return stor;
}
diff --git a/example.c b/example.c
index 7e30c22..42e64c1 100644
--- a/example.c
+++ b/example.c
@@ -230,7 +230,7 @@ static struct storage_hash *find_or_crea
if (!entry) {
entry = alloc_storage_hash(alloc_storage());
entry->pseudo = pseudo;
- add_ptr_list(listp, entry);
+ (void) add_ptr_list(listp, entry);
}
return entry;
}
@@ -460,7 +460,7 @@ static void mark_reg_dead(struct bb_stat
static void add_pseudo_reg(struct bb_state *state, pseudo_t pseudo, struct hardreg *reg)
{
output_comment(state, "added pseudo %s to reg %s", show_pseudo(pseudo), reg->name);
- add_ptr_list_tag(®->contains, pseudo, TAG_DIRTY);
+ (void) add_ptr_list_tag(®->contains, pseudo, TAG_DIRTY);
}
static struct hardreg *preferred_reg(struct bb_state *state, pseudo_t target)
diff --git a/lib.h b/lib.h
index a61b2dd..7c31dd2 100644
--- a/lib.h
+++ b/lib.h
@@ -168,17 +168,17 @@ static inline void concat_instruction_li
static inline void add_symbol(struct symbol_list **list, struct symbol *sym)
{
- add_ptr_list(list, sym);
+ (void) add_ptr_list(list, sym);
}
static inline void add_statement(struct statement_list **list, struct statement *stmt)
{
- add_ptr_list(list, stmt);
+ (void) add_ptr_list(list, stmt);
}
static inline void add_expression(struct expression_list **list, struct expression *expr)
{
- add_ptr_list(list, expr);
+ (void) add_ptr_list(list, expr);
}
#define hashval(x) ((unsigned long)(x))
diff --git a/linearize.c b/linearize.c
index f47bad9..6986517 100644
--- a/linearize.c
+++ b/linearize.c
@@ -1664,7 +1664,7 @@ static void add_asm_input(struct entrypo
rule->ident = ident;
rule->constraint = constraint;
use_pseudo(pseudo, &rule->pseudo);
- add_ptr_list(&insn->asm_rules->inputs, rule);
+ (void) add_ptr_list(&insn->asm_rules->inputs, rule);
}
static void add_asm_output(struct entrypoint *ep, struct instruction *insn, struct expression *expr,
@@ -1682,7 +1682,7 @@ static void add_asm_output(struct entryp
rule->ident = ident;
rule->constraint = constraint;
use_pseudo(pseudo, &rule->pseudo);
- add_ptr_list(&insn->asm_rules->outputs, rule);
+ (void) add_ptr_list(&insn->asm_rules->outputs, rule);
}
static pseudo_t linearize_asm_statement(struct entrypoint *ep, struct statement *stmt)
diff --git a/linearize.h b/linearize.h
index 5f021a3..fa37c8b 100644
--- a/linearize.h
+++ b/linearize.h
@@ -224,17 +224,17 @@ static inline int is_branch_goto(struct
static inline void add_bb(struct basic_block_list **list, struct basic_block *bb)
{
- add_ptr_list(list, bb);
+ (void) add_ptr_list(list, bb);
}
static inline void add_instruction(struct instruction_list **list, struct instruction *insn)
{
- add_ptr_list(list, insn);
+ (void) add_ptr_list(list, insn);
}
static inline void add_multijmp(struct multijmp_list **list, struct multijmp *multijmp)
{
- add_ptr_list(list, multijmp);
+ (void) add_ptr_list(list, multijmp);
}
static inline void *add_pseudo(struct pseudo_list **list, struct pseudo *pseudo)
@@ -263,7 +263,7 @@ static inline int bb_reachable(struct ba
static inline void add_pseudo_ptr(pseudo_t *ptr, struct pseudo_ptr_list **list)
{
- add_ptr_list(list, ptr);
+ (void) add_ptr_list(list, ptr);
}
static inline int has_use_list(pseudo_t p)
diff --git a/liveness.c b/liveness.c
index 8b0dfd8..5a8bb06 100644
--- a/liveness.c
+++ b/liveness.c
@@ -288,7 +288,7 @@ static void track_phi_uses(struct instru
continue;
def = phi->def;
assert(def->opcode == OP_PHISOURCE);
- add_ptr_list(&def->phi_users, insn);
+ (void) add_ptr_list(&def->phi_users, insn);
} END_FOR_EACH_PTR(phi);
}
diff --git a/parse.c b/parse.c
index 4339657..d2d24e1 100644
--- a/parse.c
+++ b/parse.c
@@ -278,7 +278,7 @@ static struct token *parse_enum_declarat
sym->initializer = expr;
sym->ctype.base_type = parent;
- add_ptr_list(&entries, sym);
+ (void) add_ptr_list(&entries, sym);
if (base_type != &bad_ctype) {
if (ctype->type == SYM_NODE)
diff --git a/storage.c b/storage.c
index acbc477..1b34e1e 100644
--- a/storage.c
+++ b/storage.c
@@ -52,7 +52,7 @@ struct storage_hash_list *gather_storage
struct storage_hash *hash;
FOR_EACH_PTR(storage_hash_table[i], hash) {
if (hash->bb == bb && hash->inout == inout)
- add_ptr_list(&list, hash);
+ (void) add_ptr_list(&list, hash);
} END_FOR_EACH_PTR(hash);
}
sort_hash_list(&list);
@@ -106,7 +106,7 @@ void add_storage(struct storage *storage
hash->pseudo = pseudo;
hash->inout = inout;
- add_ptr_list(listp, hash);
+ (void) add_ptr_list(listp, hash);
}
@@ -203,7 +203,7 @@ static struct storage * combine_storage(
FOR_EACH_PTR(src->users, usep) {
assert(*usep == src);
*usep = dst;
- add_ptr_list(&dst->users, usep);
+ (void) add_ptr_list(&dst->users, usep);
} END_FOR_EACH_PTR(usep);
/* Mark it unused */
diff --git a/storage.h b/storage.h
index c1822e5..fee106f 100644
--- a/storage.h
+++ b/storage.h
@@ -69,7 +69,7 @@ static inline struct storage_hash *alloc
struct storage **usep = &entry->storage;
*usep = s;
- add_ptr_list(&s->users, usep);
+ (void) add_ptr_list(&s->users, usep);
return entry;
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] sparse: gcc 4.1 warnings
2006-04-08 4:14 [PATCH] sparse: gcc 4.1 warnings Jeff Garzik
@ 2006-04-10 13:21 ` Morten Welinder
2006-04-11 0:30 ` Jeff Garzik
0 siblings, 1 reply; 6+ messages in thread
From: Morten Welinder @ 2006-04-10 13:21 UTC (permalink / raw)
To: jeff; +Cc: linux-sparse
This doesn't look quite right.
So it looks like gcc 4.1 complains over non-used values that are the
result of a cast. That feels obnoxious, but in this case maybe you
could try just casting to void in add_ptr_list -- is the value ever
used?
Morten
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sparse: gcc 4.1 warnings
2006-04-10 13:21 ` Morten Welinder
@ 2006-04-11 0:30 ` Jeff Garzik
2006-04-11 8:56 ` Jörn Engel
0 siblings, 1 reply; 6+ messages in thread
From: Jeff Garzik @ 2006-04-11 0:30 UTC (permalink / raw)
To: Morten Welinder; +Cc: linux-sparse
Morten Welinder wrote:
> This doesn't look quite right.
>
> So it looks like gcc 4.1 complains over non-used values that are the
> result of a cast. That feels obnoxious, but in this case maybe you
Yes, it is :) See below for vanilla sparse build under gcc 4.1...
> could try just casting to void in add_ptr_list -- is the value ever
> used?
All uses except for add_pseudo() ignore the return value.
Jeff
gcc -O -g -Wall -Wwrite-strings -fpic -DDEBUG -c -o lib.o lib.c
In file included from lib.c:21:
lib.h: In function ‘add_symbol’:
lib.h:171: warning: value computed is not used
lib.h: In function ‘add_statement’:
lib.h:176: warning: value computed is not used
lib.h: In function ‘add_expression’:
lib.h:181: warning: value computed is not used
In file included from lib.c:28:
linearize.h: In function ‘add_bb’:
linearize.h:227: warning: value computed is not used
linearize.h: In function ‘add_instruction’:
linearize.h:232: warning: value computed is not used
linearize.h: In function ‘add_multijmp’:
linearize.h:237: warning: value computed is not used
linearize.h: In function ‘add_pseudo_ptr’:
linearize.h:266: warning: value computed is not used
gcc -O -g -Wall -Wwrite-strings -fpic -DDEBUG -c -o scope.o scope.c
In file included from scope.c:15:
lib.h: In function ‘add_symbol’:
lib.h:171: warning: value computed is not used
lib.h: In function ‘add_statement’:
lib.h:176: warning: value computed is not used
lib.h: In function ‘add_expression’:
lib.h:181: warning: value computed is not used
gcc -O -g -Wall -Wwrite-strings -fpic -DDEBUG -c -o expression.o
expression.c
In file included from expression.c:21:
lib.h: In function ‘add_symbol’:
lib.h:171: warning: value computed is not used
lib.h: In function ‘add_statement’:
lib.h:176: warning: value computed is not used
lib.h: In function ‘add_expression’:
lib.h:181: warning: value computed is not used
[...]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sparse: gcc 4.1 warnings
2006-04-11 0:30 ` Jeff Garzik
@ 2006-04-11 8:56 ` Jörn Engel
2006-04-11 9:10 ` Chris Wedgwood
0 siblings, 1 reply; 6+ messages in thread
From: Jörn Engel @ 2006-04-11 8:56 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Morten Welinder, linux-sparse
On Mon, 10 April 2006 20:30:28 -0400, Jeff Garzik wrote:
> Morten Welinder wrote:
> >This doesn't look quite right.
> >
> >So it looks like gcc 4.1 complains over non-used values that are the
> >result of a cast. That feels obnoxious, but in this case maybe you
>
> Yes, it is :) See below for vanilla sparse build under gcc 4.1...
>
>
> >could try just casting to void in add_ptr_list -- is the value ever
> >used?
>
> All uses except for add_pseudo() ignore the return value.
How about making this two functions instead? Something like
void add_ptr_list(...)
{
(void) __add_ptr_list(...);
}
And use the __add_ptr_list version in add_pseudo().
Hmm. Except that this is userspace and double underscores are not
allowed. Maybe do_add_ptr_list(...) then?
And yes, this is really obnoxious. I have read code before that
constantly does
(void) this(...);
(void) that(...);
and didn't like it much. Ignoring the issue and fixing the code
checker instead might be a better idea.
Jörn
--
More computing sins are committed in the name of efficiency (without
necessarily achieving it) than for any other single reason - including
blind stupidity.
-- W. A. Wulf
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sparse: gcc 4.1 warnings
2006-04-11 8:56 ` Jörn Engel
@ 2006-04-11 9:10 ` Chris Wedgwood
2006-04-11 9:19 ` Jörn Engel
0 siblings, 1 reply; 6+ messages in thread
From: Chris Wedgwood @ 2006-04-11 9:10 UTC (permalink / raw)
To: J?rn Engel; +Cc: Jeff Garzik, Morten Welinder, linux-sparse
On Tue, Apr 11, 2006 at 10:56:02AM +0200, J?rn Engel wrote:
> And yes, this is really obnoxious. I have read code before that
> constantly does
> (void) this(...);
> (void) that(...);
> and didn't like it much. Ignoring the issue and fixing the code
> checker instead might be a better idea.
why not leave it just as it is?
making code ugly and unreadable because some random very of gcc is
being stilly doesn't seem ideal
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sparse: gcc 4.1 warnings
2006-04-11 9:10 ` Chris Wedgwood
@ 2006-04-11 9:19 ` Jörn Engel
0 siblings, 0 replies; 6+ messages in thread
From: Jörn Engel @ 2006-04-11 9:19 UTC (permalink / raw)
To: Chris Wedgwood; +Cc: Jeff Garzik, Morten Welinder, linux-sparse
On Tue, 11 April 2006 02:10:44 -0700, Chris Wedgwood wrote:
> On Tue, Apr 11, 2006 at 10:56:02AM +0200, J?rn Engel wrote:
>
> > And yes, this is really obnoxious. I have read code before that
> > constantly does
> > (void) this(...);
> > (void) that(...);
> > and didn't like it much. Ignoring the issue and fixing the code
> > checker instead might be a better idea.
>
> why not leave it just as it is?
>
> making code ugly and unreadable because some random very of gcc is
> being stilly doesn't seem ideal
Absolutely!
Jörn
--
You can't tell where a program is going to spend its time. Bottlenecks
occur in surprising places, so don't try to second guess and put in a
speed hack until you've proven that's where the bottleneck is.
-- Rob Pike
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-04-11 9:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-08 4:14 [PATCH] sparse: gcc 4.1 warnings Jeff Garzik
2006-04-10 13:21 ` Morten Welinder
2006-04-11 0:30 ` Jeff Garzik
2006-04-11 8:56 ` Jörn Engel
2006-04-11 9:10 ` Chris Wedgwood
2006-04-11 9:19 ` Jörn Engel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.