aboutsummaryrefslogtreecommitdiff
path: root/lib.h
Commit message (Collapse)AuthorAgeFilesLines
* New attribute designated_init: mark a struct as requiring designated initJosh Triplett2010-03-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Some structure types provide a set of fields of which most users will only initialize the subset they care about. Users of these types should always use designated initializers, to avoid relying on the specific structure layout. Examples of this type of structure include the many *_operations structures in Linux, which contain a set of function pointers; these structures occasionally gain a new field, lose an obsolete field, or change the function signature for a field. Add a new attribute designated_init; when used on a struct, it tells Sparse to warn on any positional initialization of a field in that struct. The new flag -Wdesignated-init controls these warnings. Since these warnings only fire for structures explicitly tagged with the attribute, enable the warning by default. Includes documentation and test case. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Declare ignored attributres into a list of string.Christopher Li2010-03-281-0/+4
| | | | | | Adding ignored attributes is much easier now. Signed-off-by: Christopher Li <sparse@chrisli.org>
* sparse: Add GCC pre-defined macros for user-spacePekka Enberg2009-08-211-0/+3
| | | | | | | | | | | | | | | | | | | Sparse produces a bunch of warnings like this when compiling against glibc: /usr/lib/gcc/i486-linux-gnu/4.3.2//include-fixed/limits.h:33:22: warning: undefined preprocessor identifier '__INT_MAX__' /usr/lib/gcc/i486-linux-gnu/4.3.2//include-fixed/limits.h:64:5: warning: undefined preprocessor identifier '__SHRT_MAX__' /usr/lib/gcc/i486-linux-gnu/4.3.2//include-fixed/limits.h:64:21: warning: undefined preprocessor identifier '__INT_MAX__' /usr/include/bits/xopen_lim.h:95:6: warning: undefined preprocessor identifier '__INT_MAX__' /usr/include/bits/xopen_lim.h:98:7: warning: undefined preprocessor identifier '__INT_MAX__' Fix that up by adding some add_pre_buffer() calls to create_builtin_define(). For future reference, GCC defines the builtins in the c_cpp_builtins() function in gcc/c-cppbuiltin.c. Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi> Acked-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Mark handle_switch as static and don't export it from lib.hAlexey Zaytsev2008-12-181-1/+0
| | | | Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
* Add -Wno-declaration-after-statementGeoff Johnstone2008-04-211-0/+1
| | | | | | | | | This adds -W[no-]declaration-after-statement, which makes warnings about declarations after statements a command-line option. (The code to implement the warning was already in there via a #define; the patch just exposes it at runtime.) Rationale: C99 allows them, C89 doesn't. Signed-off-by: Geoff Johnstone <geoff.johnstone@googlemail.com>
* Rename Wundefined_preprocessor to Wundef to match the command-line argumentJosh Triplett2007-08-311-1/+1
| | | | Signed-off-by: Josh Triplett <josh@freedesktop.org>
* Rename Wcast_to_address_space to Wcast_to_as to match the command-line argumentJosh Triplett2007-08-311-1/+1
| | | | Signed-off-by: Josh Triplett <josh@freedesktop.org>
* Sort warning options in lib.c and lib.hJosh Triplett2007-08-301-11/+14
| | | | Signed-off-by: Josh Triplett <josh@freedesktop.org>
* add sparse_keep_tokens api to lib.hRob Taylor2007-07-131-0/+1
| | | | | | | | Adds sparse_keep_tokens, which is the same as __sparse, but doesn't free the tokens after parsing. Useful fow ehen you want to inspect macro symbols after parsing. Signed-off-by: Rob Taylor <rob.taylor@codethink.co.uk>
* [PATCH] warn on return <void expression>;Al Viro2007-06-251-0/+1
| | | | | | conditional on -Wreturn-void Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* [PATCH] rewrite of initializer handlingAl Viro2007-06-181-0/+1
| | | | | | | | | Remaining known problems: * size of array is still miscalculated in cases with missing braces * expand still mishandles [0 ... 1].a et.al. * expand still doesn't deal with overlaps correctly. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* Add -Wno-non-pointer-null to turn off warning about using a plain integer as ↵Josh Triplett2007-05-221-0/+1
| | | | | | a NULL pointer Signed-off-by: Josh Triplett <josh@freedesktop.org>
* Add -Wno-old-initializer to turn off warnings about non-C99 struct initializersJosh Triplett2007-05-221-0/+1
| | | | Signed-off-by: Josh Triplett <josh@freedesktop.org>
* Declare gcc_patchlevel extern in lib.hJosh Triplett2007-04-201-1/+1
| | | | | | lib.h exported gcc_major and gcc_minor, but not gcc_patchlevel. Signed-off-by: Josh Triplett <josh@freedesktop.org>
* Declare die_if_error extern in lib.hJosh Triplett2007-04-201-0/+1
| | | | Signed-off-by: Josh Triplett <josh@freedesktop.org>
* Use noreturn on die() and error_die()Josh Triplett2007-04-201-2/+4
| | | | Signed-off-by: Josh Triplett <josh@freedesktop.org>
* Use GCC format and sentinel attributes on appropriate functionsJosh Triplett2007-03-091-2/+3
| | | | | | | | | | | | | Expose the FORMAT_ATTR portability macro in lib.h, and use it on the various printf-like functions in sparse. Add a new SENTINEL_ATTR portability macro for the GCC sentinel attribute, and use it on match_idents in parse.c. match_oplist in expression.c should use SENTINEL_ATTR, but GCC does not accept an integer 0 as a sentinel, only a pointer 0 like NULL. Signed-off-by: Josh Triplett <josh@freedesktop.org>
* Disable liveness "dead" instruction by default.Christopher Li2007-02-281-0/+1
| | | | | | | | | | | The liveness instruction takes up about 10% of the bytecode bloat file. It is not very useful, it is duplicate information that can be obtained from the def/user chain. This change disables the liveness instruction by default. The caller can track_pseudo_death() if needed. Signed-Off-By: Christopher Li <sparse@chrisli.org>
* Introduce expression_errorChristopher Li2007-02-271-0/+1
| | | | | | | Add a new function expression_error, which works just like sparse_error but also installs a bad_ctype into the expression. Signed-Off-By: Christopher Li <sparse@chrisli.org>
* Adding debug option for showing the linearized instruction.Christopher Li2007-02-251-0/+2
| | | | Signed-Off-By: Christopher Li <sparse@chrisli.org>
* Coding style fix: in a pointer type, * goes with the name, not the type.Josh Triplett2007-01-271-7/+7
| | | | Signed-off-by: Josh Triplett <josh@freedesktop.org>
* Allow more than one command line include file.Christopher Li2007-01-271-0/+9
| | | | Signed-off-by: Christopher Li<sparse@chrisli.org>
* cleanup write to argument array hackChristopher Li2006-12-041-3/+4
| | | | | | | | | | | | The sparse interface is a kind of snaky that it change the input argument array. The function sparse() does the same hack just to skip the files. This patch add the ptr list for string. So sparse_initialize will return list of file to compile. The string pointer is not aligned at word boundary. This patch introduce non taged version of the ptr list iteration function. Signed-off-by: Christopher Li <sparse@chrisli.org>
* merge branch 'more-warning-flags' into staging and fix conflictsJosh Triplett2006-10-161-0/+1
|\
| * Add -Wno-uninitializedJosh Triplett2006-09-141-0/+1
| | | | | | | | | | | | | | | | | | | | Add the ability to turn off warnings for possibly uninitialized variables using -Wno-uninitialized, helpful when attempting to track down a particular class of warnings only without losing them amongst others. Warnings for possibly uninitialized variables default to on, so this does not change the default behavior of sparse. Signed-off-by: Josh Triplett <josh@freedesktop.org>
* | Add warning message for naked do-whileLinus Torvalds2006-10-011-0/+1
|/ | | | | | | | | | Does it necessarily make sense? Dunno, but it does tend to be bad practice, or at least result in code that can be hard to mentally parse. Maybe that mental parsing is just me. Or maybe it should be warned about. You decide. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] Add -Wno-cast-truncateJosh Triplett2006-08-291-0/+1
| | | | | | | | | | | Add the ability to turn off checks for casts that truncate constant values using -Wno-cast-truncate, helpful when attempting to track down a particular class of warnings only without losing them amongst others. Checks for truncating casts default to on, so this does not change the default behavior of sparse. Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] Add -Wno-enum-mismatchJosh Triplett2006-08-291-0/+1
| | | | | | | | | | | Add the ability to turn off enum type mismatch warnings using -Wno-enum-mismatch, helpful when attempting to track down a particular class of warnings only without losing them amongst others. Enum type mismatch checking defaults to on, so this does not change the default behavior of sparse. Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] Add -Wno-address-spaceJosh Triplett2006-08-291-0/+1
| | | | | | | | | | Add the ability to turn off address-space mismatch warnings using -Wno-address-space, helpful when attempting to track down a particular class of warnings only without losing them amongst others. Address space checking defaults to on, so this does not change the default behavior of sparse. Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* First cut at something that approaches a sane -WshadowLinus Torvalds2006-07-311-0/+1
| | | | | | | Let's see if it's useful. The ones it reported for git seemed reasonable, certainly more so than the gcc ones. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] introduce __sparse() functionOleg Nesterov2005-12-201-0/+1
| | | | | | | | | | | This patch adds __sparse() function for those users which don't need evaluate.c (see the next patch). Without this patch it is not possible to link test-dissect statically, it has to redefine evaluate_symbol_list(). Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] new flag - Wone-bit-signed-bitfieldAl Viro2005-11-221-0/+1
| | | | | | | | Make the warnings about one-bit signed bitfields conditional; default is the old behaviour Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] new flag - -WdeclAl Viro2005-11-221-0/+1
| | | | | | | | Make "should it be static?" warnings conditional on a new flag (-Wdecl); default is to be quiet. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* Re-name "error()" function to "sparse_error()"Linus Torvalds2005-11-161-1/+1
| | | | | | | | | Mitesh Shah (and others) report that broken libc's will have their own "error()" that the sparse naming clashes with. So use a sed-script to rewrite all the occurrences. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* Handle symbols from "-include" file tooLinus Torvalds2005-11-021-1/+1
| | | | | | Noted by Mitesh Shah Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] add support for -imacrosSam Ravnborg2005-09-141-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Gcc has two ways to specify on the commandline files to be read before processign normal files: "-include file" will include file in ordinary way. "-imacros file" will include file but do not generate any output gcc will include files specified with -imacros before files specified with -include. This adds some very basic support for -imacros, just duplicating the code used for -include. To obtain the real functionality we would have to build a list of filenames specified, and process all files specifed with -imacros before files specified with -include. In -mm a patch is now included that uses -imacros, so applying following patch will let us stay compatible with kernel source. The last bit deletes two references from lib.h that are there for no good reason. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* [PATCH] More address space checkingviro@ZenIV.linux.org.uk2005-09-091-0/+1
| | | | | | | | | | | | | * generate a warning when we cast _between_ address spaces (e.g. cast from __user to __iomem). * optional (on -Wcast-to-as) warning when casting _TO_ address space (e.g. when normal pointer is cast to __iomem one - that caught a lot of crap in drivers). casts from unsigned long are still OK, so's cast from 0, so's __force cast, of course. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
* Add __OPTIMIZE[_SIZE]__ predefinesLinus Torvalds2005-08-151-1/+1
| | | | | As noted by Arnaldo Carvalho de Melo, some of the glibc header files expect these to be defined when compiling with optimization.
* Make delete_last_instruction() use the new undo_ptr_list_last() fnLinus Torvalds2005-08-111-1/+1
| | | | | | Not only are we always going to replace the last instruction with something else, we can't afford to free the ptrlist, because the caller is usually walking over it in a loop.
* Have more bits for "stream number" in "struct pos"Linus Torvalds2005-08-061-2/+2
| | | | | Now that we do multiple files at a time, the stream numbers grow alarmingly.
* Update the calling interface to "sparse()".Linus Torvalds2005-08-031-3/+2
| | | | | | | | | | | | | | Start off with sparse_initialize(argc, argv); which will return the number of filenames found. You can then use that, or just check if *argv is NULL in a loop like while (*argv) list = sparse(argv); where you get the declaration list for each file in turn.
* [PATCH] __attribute__ handling for attributes used in the userlandPeter Jones2005-06-201-0/+1
| | | | | | | | Here's a patch that adds stubs for several attributes used in userland. This version of the patch includes a warning, which defaults to on, if you use gcc's "transparent_union" attribute, and has a flag (-Wno-transparent-union) to turn the warning off.
* [LIB] allow changing the gcc version in the definesArnaldo Carvalho de Melo2005-06-041-0/+1
| | | | Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
* Move the ptrlist macros out of the sparse "lib.[ch]" files.Linus Torvalds2005-04-071-248/+1
| | | | | They rate their own "ptrlist" library status, since they are definitely potentially useful outside of sparse.
* Add option "-Wptr-subtraction-blows" to warn about expensiveLinus Torvalds2005-04-071-0/+1
| | | | | | | | | | pointer subtractions. Not only does it generate bad code (that can often be rewritten to not do that), it also causes gcc to go into horrible contortions, and Al Viro reports that it can make a factor of 2.5 difference in kernel build times to have just a few of these in common header file inline functions.
* When removing/replacing pointer list entries, return the finalLinus Torvalds2005-04-071-2/+2
| | | | | | | count. The caller want to know how many got removed if they didn't specify an exact count to begin with.
* Support tagged add_ptr_listLinus Torvalds2005-04-071-2/+9
|
* Add macros to set/read the pointer list tags.Linus Torvalds2005-04-071-0/+9
|
* Beginning infrastructure for tagged lists.Linus Torvalds2005-04-071-9/+11
| | | | | Right now we verify that low bits are clear when inserting, and clear them on use.
* Make OP_PHISOURCE track the OP_PHI instructions that it defines.Linus Torvalds2005-04-071-0/+2
| | | | | | | | This allows us to always see which pseudos are nonlocally affected by the phi source. We can only do this after the instruction flow is fixed, together with the OP_DEATHNOTE phase.