sparse: gcc 4.1 warnings
PATCH 1/1 sparse: gcc 4.1 warnings
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.
compile-i386.c +3 -3
@@ -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; }
example.c +2 -2
@@ -230,7 +230,7 @@ static struct storage_hash *find_or_creaif (!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_statstatic 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)
lib.h +3 -3
@@ -168,17 +168,17 @@ static inline void concat_instruction_listatic 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))
linearize.c +2 -2
@@ -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)
linearize.h +4 -4
@@ -224,17 +224,17 @@ static inline int is_branch_goto(structstatic 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 bastatic 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)
liveness.c +1 -1
@@ -288,7 +288,7 @@ static void track_phi_uses(struct instrucontinue ; 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); }
parse.c +1 -1
@@ -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 )
storage.c +3 -3
@@ -52,7 +52,7 @@ struct storage_hash_list *gather_storagestruct 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 */
storage.h +1 -1
@@ -69,7 +69,7 @@ static inline struct storage_hash *allocstruct storage **usep = &entry->storage; *usep = s; -add_ptr_list (&s->users, usep); + (void )add_ptr_list (&s->users, usep);return entry; }
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
Quoted 4 lines · Morten Welinder
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...
Quoted 2 lines
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 [...]
Quoted 6 lines · Jeff Garzik
Quoted 4 lines · Morten Welinder
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
Quoted 7 lines
Yes, it is :) See below for vanilla sparse build under gcc 4.1...
Quoted 2 lines
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
Signature · 4 lines
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
Quoted 6 lines · J?rn Engel
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
Quoted 9 lines · Chris Wedgwood
Quoted 6 lines · J?rn Engel
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.
Quoted 4 lines
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
Signature · 4 lines
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