diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-08 13:35:09 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-08 13:35:09 -0700 |
commit | 4ad9f15170414086331004efc8d5d77ede5e20a0 (patch) | |
tree | 5757a4022522bce6acfff0c769373e062086dbfb /ptrlist.h | |
parent | Fix dropped type information in "add_pseudo()". (diff) | |
download | sparse-4ad9f15170414086331004efc8d5d77ede5e20a0.tar.gz sparse-4ad9f15170414086331004efc8d5d77ede5e20a0.tar.bz2 sparse-4ad9f15170414086331004efc8d5d77ede5e20a0.zip |
Avoid bogus gcc warnings about unused results
Our fancy type-safe pointer-list template macros caused gcc to spew out
incredible numbers of totally bogus warnings, just because most users
didn't actually care about the result of the "add_ptr_list()" operation.
Not caring about the result is _fine_, and gcc is just totally confused.
However, we can avoid the bogus warning by enclosing the expression in a
statement expression. While "(cast)(x)" causes a warning about the
result not being used, doing it as "({ (cast)(x); })" shuts gcc up about
it.
Not pretty, but better than the alternative (which is to drop type
information).
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'ptrlist.h')
-rw-r--r-- | ptrlist.h | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -16,6 +16,13 @@ #define TYPEOF(head) __typeof__(&(head)->list[0]) #define VRFY_PTR_LIST(head) (void)(sizeof((head)->list[0])) +/* + * The "unnecessary" statement expression is there to shut up a totally + * bogus gcc warning about unused expressions, brought on by the fact + * that we cast the result to the proper type. + */ +#define MKTYPE(head,expr) ({ (TYPEOF(head))(expr); }) + #define LIST_NODE_NR (29) struct ptr_list { @@ -46,7 +53,7 @@ extern int linearize_ptr_list(struct ptr_list *, void **, int); * extensions.. */ #define add_ptr_list_tag(list,entry,tag) \ - (TYPEOF(*(list))) (CHECK_TYPE(*(list),(entry)),__add_ptr_list((struct ptr_list **)(list), (entry), (tag))) + MKTYPE(*(list), (CHECK_TYPE(*(list),(entry)),__add_ptr_list((struct ptr_list **)(list), (entry), (tag)))) #define add_ptr_list(list,entry) \ add_ptr_list_tag(list,entry,0) #define free_ptr_list(list) \ |