| Age | Commit message (Collapse) | Author | Files | Lines |
|
GCC's manual or POSIX say about the '-D' option something like:
'−D name[=value]' should be treated as if in directive
'#define name value' (with '1' as default for the value),
including its tokenization.
So an option like '-DM(X, Y)=...' should be processed like a
directive '#define M(X, Y) ...'.
However, the current code treat a space as a separator between
the macro and its definition, just like the '='. As consequence,
the above option is processed like the directive would be
'#define M(X, Y)=...', with 'M(X,' as the macro (name) and
'Y)=...' as its definition.
Fix this by stopping to treat the space character specially,
thus only using '=' as the separator.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Till now, sparse was unneedlessly strict in what it accepted in
'-D' options. More specifically, it doesn't accept:
1) separated '-D' and the macro definition, like:
sparse -D MACRO[=definition] ...
2) a space between the '-D' and the macro name, like:
sparse '-D MACRO[=definition] ...
Case 1) is clearly accepted by GCC, clang and should be
accepted for a POSIX's c99. Case 2's status is less clear
but is also accepted by GCC and clang (leaving any validation
to the corresponding internal #define).
Fix this by accepting separated command line argument for '-D'
and the macro (and removing the check that rejected the macro
part if it started with a space).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
as it will be used for dumping the IR not only just after
linearization but after other passes too.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
'fix-volatile-simplification', 'struct-asm-ops', 'restricted-pointers', 'fix-f2i-casts', 'symaddr-description', 'flush-stdout' and 'diet-simple' into tip
|
|
This is much needed for tools like test-linearize
which output on stderr & stdout and without this patch
error messages and normal output are out-of-sync.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Symbols declared or defined in files directly or indirectly
given in the command line and thus processed via sparse()
are always automatically evaluated.
Symbols processed via sparse_initialize(), thus the predefined
ones, are not systematically evaluated, which is normaly fine
as they are just declarations and will be evaluated when needed.
However, if the command line include a file via '-include <file>',
the symbols of this file will also not be evaluated, which is still
fine as long as it's only definitions. But, in the rare and odd cases
where the file should contains a function definition, this function
will not be evaluated and it's expansion and linearization won't happen
as it should have.
Fix this by evaluating the symbols issued from sparse_intialize()
like it is done for sparse().
Reported-by: Jason A. Donenfeld <Jason@zx2c4.com>
Tested-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Currently, the parsing of options is often quite ad-hoc and thus:
- need a lot of code
- is not clear at all
Improve this by making this table driven.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Until now, match_option() needed a non-const argment and returned
a non-const result. Since it is no more needed, let's use const.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
For some options with a numerical value, it is sometimes desirable,
when the value is used to limits something, to easily specify we
want to remove any limits.
This patch allow to use 'unlimited' for this by interpreting it as
the maximum value.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
For some options with a numerical value, it is sometimes desirable,
to easily specify we want the maximum possible value.
This patch allow to interpret '=0' as meaning the maximum value.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
This was used to handle a single flag but we need something
more compact when we need to handle several flags.
So, adapt this helper so that it now takes an array of flags
instead of a single flag.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
'struct warning' can be reused for flags other than warnings.
To avoid future confusion, rename it to something more general:
'struct flag' (which in its context, handling of compiler flags,
is clear enough).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The goal of this helper is:
- to avoid to have to hardoce the length od the substring
- separate the suffix/option part from the whole argument
which help for error message.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
|
|
The 'selfcheck' make target issues sparse errors for function symbols
'error_die' and 'die', like so:
CHECK lib.c
lib.c:194:6: error: symbol 'error_die' redeclared with different type \
(originally declared at lib.h:98) - different modifiers
lib.c:203:6: error: symbol 'die' redeclared with different type \
(originally declared at lib.h:94) - different modifiers
This is caused by the 'noreturn' attribute being treated similar to a
type qualifier and insisting that, not only the declaration and the
definition of the function have the 'noreturn', but that they have the
attribute in the same position.
In order to suppress the error, move the attribute(s) to the beginning
of the declaration, in the header file, and add an 'noreturn' attribute
at the beginning of the definition (in lib.c).
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This will make the selfcheck target reduce a lot of error on
test-inspect.c. The gtk header file use _Pragma().
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Some macros, structures definitions, ... are endianness specific.
This is generaly done with the help of some header files but these
headers often need information from the compiler via the macro
__BYTE_ORDER__, itself being defined to __ORDER_BIG_ENDIAN__ or
__ORDER_LITTLE_ENDIAN__.
Without these defines, sparse's pre-processor may interpret things
differently than the compiler would do which may hide errors or
warn on code that is compiled out.
Fix this by letting sparse predefine these macros like compilers do.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Acked-by: Christopher Li <sparse@chrisli.org>
|
|
Some macros, structures definitions, ... are endianness specific.
This is generaly done with the help of some header files but these
headers often need information from the compiler via the macros
__BIG_ENDIAN__ / __LITTLE_ENDIAN__.
Without these defines, sparse's pre-processor may interpret things
differently than the compiler would do which may hide errors or
warn on code that is compiled out.
Fix this by letting sparse predefine these macros like compilers do.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Acked-by: Christopher Li <sparse@chrisli.org>
|
|
Some macros, structures definitions, ... are endianness specific.
This is generaly done with the help of some header files but these
headers often need information from the compiler which then need
to be endian-aware.
In order to not interpret things differently than the compiler
would, sparse thus also need to be endian-aware, even more so
given that sparse must cover all archs and their variants.
Give this information to sparse with two flags:
-mbig-endian/-mlittle-endian, and by default use
the endianness of the platform used to compile sparse.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Acked-by: Christopher Li <sparse@chrisli.org>
|
|
By default, sparse will warn if memcpy() (or memset(),
copy_from_user(), copy_to_user()) is called with a very large
static byte-count.
But the limit is currently fixed at 100000, which may be fine
for some uses but not for others. For example, this value is
too low for sparse to be used on the git tree where, for example,
some array used to sort the index is cleared with memset().
Change this by making the limit configurable via a new flag:
-fmemcpy-max-count.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
sparse will warn if memcpy() (or memset(), copy_from_user(),
copy_to_user()) is called with a very large static byte-count.
But this warning is given unconditionaly while there are projects
where this warning may not be not desired.
Change this by making this warning conditional on a new warning
flag: -W[no-]memcpy-max-count
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
'implicit-int', 'cgcc-darwin' and 'more-builtin-decls' into rc2
|
|
Those are used by GCC testsuite.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Currently, once an error is issued, warnings are no more
issued, only others errors are.
It make sense as once an error is encountered things can
be left in an incoherent state and could cause lots of
useless warnings because of this incoherence.
However, it's also quite annoying as even unrelated warnings
are so silenced and potential bugs stay thus hidden.
Fix this by:
- use a specific flag for this: 'has_error'
- make the distinction between the current phase and some previous
phases (but for now we only care about parsing vs evaluation)
- if an error has been issued in a previous phase (at parsing)
warnings are suppressed for the current phase and all future
phases
- if an error is issued in the current phase (evaluation) the
flag is reset after each functions/symbols
For example, with this patch, a typing error in function fa()
will not suppress warnings for function fb(), while a parsing
error will still inhibit all further warnings.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
'fix-missing-reload', 'fix-insert-branch', 'fix-NULL-type', 'testsuite-clean', 'fix-bitfield-init-v3' and 'fdump-linearize' into tip
* fix missing reload
* fix boolean context for OP_AND_BOOL & OP_OR_BOOL
* fix bitfields implicit zero initializer.
* fix: kill old branch in insert_branch()
* returns the correct type when evaluating NULL
* use internal size for __INT_MAX__ & friends
* testsuite: cleanup result files
* add support for '-fdump-linearize[=only]'
* add support for '-fmem-report'
* add support for '-dD'
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The predefined macros __SCHAR_MAX__, __SHRT_MAX__, __WCHAR_MAX__ &
__CHAR_BIT__ are defined based on the size of these types on
the machine where sparse was compiled.
But since sparse has flags like -m32/-m64 and it's not unlikely
to have one day a flag like -march=<some arch>, better to use
the used by sparse for these types as stored in 'bits_in_char',
'bits_in_short', ...
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Since commit 4fae9be00 & 5466cf8f3 ("predefine __INT_MAX__ and friends" &
"predefine __SIZEOF_INT__ & friends"), macros like __INT_MAX__ and
__SIZEOF_POINTER__ are predefine twice.
Fix this by removing the old definition, based on the size of these
types on the machine where sparse was compiled.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
The effect of this flag is to dump the IR just after the
linearization, before any simplification, and to stop
further processing if '=only' is given as argument.
The motivation of this flag is of course for debugging,
to be able to inspect the raw result of the linearization,
undisturbed by an simplification.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
'sent/fix-cond-address' and 'careful-concat-user-list' into tip
|
|
Initializers of static storage duration objects shall be constant
expressions [6.7.8(4)].
Warn if that requirement is not met and the -Wstatic-initializer-not-const
flag has been given on sparse's command line.
Identify static storage duration objects by having either of
MOD_TOPLEVEL or MOD_STATIC set.
Check an initializer's constness at the lowest possible subobject
level, i.e. at the level of the "assignment-expression" production
in [6.7.8].
Signed-off-by: Nicolai Stange <nicstange@gmail.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Some tests or some code depends on these macros being predefined
by the compiler.
Predefine them.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
Some tests or some code depends on these macros being predefined
by the compiler.
Predefine them.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
This is used by GCC to report suspicious use of addresses.
So, reuse the same name for same or similar use.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
|
|
After parsing and validation, the symbols in the declaration
are added to the list given in argument, *if* they are not extern
symbols. The symbols that are extern are them not added to the list.
This is what is needed for usual declarations but ignoring extern
symbols make it impossible to emit a diagnostic in less usual
situation.
This is motivated by the validation of variable declaration inside
a for-loop initializer, which is valid in C99 but only for variable
with local storage.
The change consists in adding to external_declaration() an optional
callback 'validate_decl()' which, if present (non-null), is called
just before adding the declaration to the list.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
When an array is initialized, it may be convenient to first
initialize all entries with some default value via the
'[a ... b]' notation and then override some of these entries
with a non-default value. Unfortunately, this, of course,
is not compatible with the default warning flag '-Woverride-init'.
Fix this by introducing an exception to the usual detection
of overlapping initializers which, only for what concerns this
warning, ignore an '[a ... b]' entry if:
- it is the first one
- it covers the whole range of the array.
If needed, the previous ehaviour can be restored by using a new
warning flag, disabled by default: '-Woverride-init-whole-range'.
Suggested-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
By default, sparse only warns on the first overlapping initialier.
While this may be sensible for most situation, it's not always wanted
to hide those others errors. This is especially annoying when testing.
Change this by introducing a new warning flag '-Woverride-init-all',
disabled by default and whose intented use is sparse's testsuite.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Sparse warns unconditionally about overlapping initilalizers.
Introduces a warning flag to control this, use the same name
as GCC's and enabled it by default.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The flag -Wbitwise have no effect since patch 02a886bfa
("Introduce keyword driven attribute parsing"): the corresponding
checks are now always done.
Fix that by reintroducing it in the same way as it was:
ignore the bitwise attribute if the flag is not set.
It's less invasive that checking the flag at each place
an corresponding warning is emitted.
Also, to not perturb the current situation the flag is now
enabled by default.
Reported-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Things are greatly simplified now that such builtins can have a
prototype: the args and result are already evaluated, the
arguments number and their type are already checked, etc.
Based-on-patch-by: Christopher Li <sparse@chrisli.org>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
There was recently on the mailing list some questions
and a need to support LLP64 model.
This patch add is by adjusting a few size-related variables
under the control of a new flag: -msize-llp64 (ugly name
but we already have we have '-msize-long').
CC: Dibyendu Majumdar <mobile@majumdar.org.uk>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Now that we optimize away expressions like 'x == x' or 'x < x',
also add a warning for it (but disabled by default).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
They're part of GCC's common predefined macros and some
code & header files depends on them.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Eventually, most of what GCC predefine (gcc -E -dM)
should be defined here.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
They're part of GCC's common predefined macros and some
code & header files depend on them.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Now that support have been added for C11 new syntax we can accept
'--std={c11,gnu11}' no more dying with "Unsupported C dialect" message.
Also adjust __STDC_VERSION__ accordingly and define the few
associated feature macros (__STD_NO_ATOMICS__, ...).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Since gcc does this, it's apparently valid to write
switch (x) {
case __builtin_bswap16(12):
break;
}
but sparse will flag it as an error today.
The constant folding used to be done in the kernel's htons() and
friends, but due to gcc bugs that isn't done anymore since
commit 7322dd755e7d ("byteswap: try to avoid __builtin_constant_p
gcc bug").
To get rid of the sparse errors on every such instance now, just
add constant folding to __builtin_bswap*() in sparse.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
GCC creates new attributes quite often, generaly for specific
usages irrelevant to what sparse is used for.
Throwing errors on these create needless noise and annoyance
which is better to avoid.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Sparse emits a large number of warnings for the linux kernel source
tree of the form:
./arch/x86/include/asm/uaccess.h:735:18: \
warning: incorrect type in argument 1 (different modifiers)
./arch/x86/include/asm/uaccess.h:735:18: expected void *<noident>
./arch/x86/include/asm/uaccess.h:735:18: got void const *from
Fix by making the first parameter to __builtin_object_size()
type "const void *" instead of "void *", which is consistent with GCC
behavior (the prototype for this builtin in GCC documentation is evidently
incorrect).
Signed-off-by: Lance Richardson <lrichard@redhat.com>
Acked-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Michael Stefaniuc <mstefani@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Michael Stefaniuc <mstefani@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This suppresses some "array subscript has type 'char'" warnings from
gcc (version 4.8.3). (see also, commit cf5114a1)
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Sparse is often share compile flags. So Werror is usually
mean gcc should treat warning as error. Apply the same
option to sparse will cause the Linux kernel checking fail
the build. We don't want that.
Rename the sparse option to -Wsparse-error. It allow caller
to control gcc and sparse behavior seperately.
It also make sparse return error status only when -Wsparse-error
is present.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Make sparse fail and return an error code if a warning is encountered
and -Werror is specified or a hard error is found. This allows to use
sparse in automated build systems to more easily catch new sparse
warnings.
The validation script is extended to parse the expected output message
for an error message and validate the a non zero return value if such
a error message is found.
Also changes cgcc to die if the checker fails.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Remove the loop for short option.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Very dumb patch to just skip --param allow-store-data-races=0 introduced in
newer GCC versions.
Without this patch sparse recognizes parameter of the --param option as a file
name which obviously couldn't be found.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Allow an override to emit or not the sizeof(bool) warning.
Add a "-Wsizeof-bool" description to the manpage.
Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
gcc defines __CHAR_BIT__ as a pre-defined macro.
Define __CHAR_BIT__ in sparse so that code that needs it (e.g. code
using CHAR_BIT from limits.h) does not generate false warnings.
Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
this patch stops sparse from complaining about them not being
defined:
source/odp_spinlock.c:41:10: error: undefined identifier '__sync_lock_release'
source/odp_spinlock.c:54:10: error: undefined identifier '__sync_lock_release'
./odp_atomic.h:112:16: error: undefined identifier '__sync_fetch_and_add'
Reported-by: Mike Holmes <mike.holmes@linaro.org>
Signed-off-by: Kim Phillips <kim.phillips@linaro.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The old code was relicensed by Novafora Corporation, successor in interest to
Transmeta Corporation, in 2009. Other authors were also asked about the change
of their contributions to the MIT license and all with copyrightable changes
agreed to it.
Signed-off-by: Franz Schrober <franzschrober@yahoo.de>
Acked-by: Adam DiCarlo <adam@bikko.org>
Acked-by: Al Viro <viro@ZenIV.linux.org.uk>
Acked-by: Alberto Bertogli <albertito@blitiri.com.ar>
Acked-by: Alecs King <alecs@perlchina.org>
Acked-by: Alexander Shishkin <alexander.shishckin@gmail.com>
Acked-by: Alexey Dobriyan <adobriyan@gmail.com>
Acked-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
Acked-by: Andries E. Brouwer <Andries.Brouwer@cwi.nl>
Acked-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Acked-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Acked-by: Ben Pfaff <blp@nicira.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Bernd Petrovitsch <bernd@petrovitsch.priv.at>
Acked-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Acked-by: Blue Swirl <blauwirbel@gmail.com>
Acked-by: Chris Forbes <chrisf@ijw.co.nz>
Acked-by: Chris Wedgwood <cw@f00f.org>
Acked-by: Christopher Li <sparse@chrisli.org>
Acked-by: Damien Lespiau <damien.lespiau@gmail.com>
Acked-by: Dan Carpenter <error27@gmail.com>
Acked-by: Dan McGee <dan@archlinux.org>
Acked-by: Daniel De Graaf <danieldegraaf@gmail.com>
Acked-by: Daniel Sheridan <dan.sheridan@postman.org.uk>
Acked-by: Dave Jones <davej@redhat.com>
Acked-by: David Given <dg@cowlark.com>
Acked-by: David Miller <davem@redhat.com>
Acked-by: David Mosberger-Tang <dmosberger@gmail.com>
Acked-by: David Olien <David.Olien@lsi.com>
Acked-by: Diego Elio Pettenò <flameeyes@flameeyes.eu>
Acked-by: Emil Medve <Emilian.Medve@Freescale.com>
Acked-by: Ethan Jackson <jacksone@nicira.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Frank Zago <fzago@systemfabricworks.com>
Acked-by: Frederic Crozat <fcrozat@suse.com>
Acked-by: Geoff Johnstone <geoff.johnstone@gmail.com>
Acked-by: Hannes Eder <hannes@hanneseder.net>
Acked-by: Jan Pokorný <pokorny_jan@seznam.cz>
Acked-by: Jeff Garzik <jgarzik@redhat.com>
Acked-by: Jiri Slaby <jslaby@suse.cz>
Acked-by: Joe Perches <joe@perches.com>
Acked-by: Joel Soete <rubisher@scarlet.be>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Acked-by: Josh Triplett <josh@kernel.org>
Acked-by: Kamil Dudka <kdudka@redhat.com>
Acked-by: Kim Phillips <kim.phillips@linaro.org>
Acked-by: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Acked-by: Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Acked-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Acked-by: Martin Nagy <nagy.martin@gmail.com>
Acked-by: Masatake YAMATO <yamato@redhat.com>
Acked-by: Mauro Dreissig <mukadr@gmail.com>
Acked-by: Michael Büsch <m@bues.ch>
Acked-by: Michael Stefaniuc <mstefani@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Mika Kukkonen <mikukkon@iki.fi>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mitesh Shah <Mitesh.Shah@synopsys.com>
Acked-by: Morten Welinder <mortenw@gnome.org>
Acked-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Nicolas Kaiser <nikai@nikai.net>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Pavel Roskin <proski@gnu.org>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Acked-by: Peter Jones <pjones@redhat.com>
Acked-by: Peter A Jonsson <pj@sics.se>
Acked-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Acked-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Acked-by: Randy Dunlap <rdunlap@xenotime.net>
Acked-by: Reinhard Tartler <siretart@tauware.de>
Ached-by: Richard Knutsson <richard.knutsson@gmail.com>
Acked-by: Rob Taylor <rob.taylor@codethink.co.uk>
Acked-by: Rui Saraiva <rmpsaraiva@gmail.com>
Acked-by: Ryan Anderson <ryan@michonline.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Samuel Bronson <naesten@gmail.com>
Acked-by: Santtu Hyrkkö <santtu.hyrkko@gmail.com>
Acked-by: Shakthi Kannan <shakthimaan@gmail.com>
Acked-by: Stephen Hemminger <shemminger@linux-foundation.org>
Acked-by: Thomas Schmid <Thomas.Schmid@br-automation.com>
Acked-by: Tilman Sauerbeck <tilman@code-monkey.de>
Acked-by: Vegard Nossum <vegardno@ifi.uio.no>
Acked-by: Xi Wang <xi.wang@gmail.com>
Acked-by: Yura Pakhuchiy <pakhuchiy@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
this patch stops sparse from complaining about them not being defined:
/usr/include/bits/stdio2.h:98:25: error: undefined identifier '__builtin_va_arg_pack'
/usr/include/bits/stdio2.h:98:25: error: not a function <noident>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
GCC defines a macro __SIZEOF_POINTER__ to the size of a pointer in
bytes. Define it in sparse as well.
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This patch adds new option -Winit-cstring to sparse.
With the option sparse can Warn about initialization of a char array
with a too long constant C string. If the size of the char array and
the length of the string is the same, there is no space for the last
nul char of the string in the array.
char s[3] = "abc";
If the array is used as just a byte array, not as C string, this
warning is just noise. However, if the array is passed to functions
dealing with C string like printf(%s) and strcmp, it may cause a
trouble.
Here is a example of such trouble:
http://www.spinics.net/lists/netdev/msg229765.html
http://www.spinics.net/lists/netdev/msg229870.html
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The previous warning about bad constant is actually
mean for variable length array.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
of sparse. Add --version to see it.
Reviewed-by: Joe Perches <joe@perches.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
this patch stops sparse from complaining about them not being
defined:
include/uapi/linux/swab.h:60:16: error: undefined identifier '__builtin_bswap32'
include/uapi/linux/swab.h:60:33: error: not a function <noident>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Pull preprocessor fix from Al Viro.
1) we really, really shouldn't convert escape sequences too early;
#define A(x) #x
A('\12')
should yield "'\\12'", *not* "'\\n'".
2) literal merging handles all sequences of string/wide string
literals; result is wide if any of them is wide. string_expression() is
handling that wrong - "ab"L"c" is L"abc"
3) with support (no matter how cursory) of wide char constants
and wide string literals, we really ought to handle
#define A(x,y)
A(L,'a')
properly; it's not that tricky - combine() needs to recognize <IDENT["L"],CHAR>
and <IDENT["L"],STRING> pairs.
4) '\777' is an error, while L'\777' is valid - the value should fit
into unsigned char or unsigned counterpart of wchar_t. Note that for string
literals this happens *after* phase 6 - what matters is the type of literal
after joining the adjacent ones (see (2) above).
5) stringifying should only quote \ and " in character constants and
string literals,
#define A(x) #x
A(\n)
should produce "\n", not "\\n"
6) we are losing L when stringifying wide string literals; that's
wrong.
I've patches hopefully fixing the above. Basically, I delay interpreting
escape sequences (past the bare minimum needed to find where the token ends)
until we are handling an expression with character constant or string literal
in it.
For character constants I'm keeping the token body in token->embedded -
4-character array replacing token->character. That covers practically
all realistic instances; character constant *may* be longer than that,
but it has to be something like '\x000000000000000000000000041' - sure,
that's 100% legitimate C and it's going to be the same as '\x41' on
everything, but when was the last time you've seen something like that?
So I've split TOKEN_CHAR into 5 values - TOKEN_CHAR+1--TOKEN_CHAR+4 meaning
1--4 characters kept in ->embedded[], TOKEN_CHAR itself used for extremely
rare cases longer than that (token->string holds the body in that case).
TOKEN_WIDE_CHAR got the same treatment.
AFAICS, with those fixes we get the same behaviour as in gcc for
silently ignored by cpp if the string/char constant doesn't make it
out of preprocessor. sparse still warns about those. The situation
with this one is frustrating; on one hand C99 is saying that e.g.
'\x' is not a token. Moreover, in a footnote in 6.4.4.4 it flat-out
requires diagnostics for such. On the other hand... footnotes are
informative-only and having "other character" token match ' would
puts us in nasal daemon country, so gcc is free to do whatever it feels
like doing. I think we shouldn't play that kind of standard-lawyering
*and* sparse has always warned on that, so I've left that warning
in place.
Note that real wchar_t handling is still not there; at the very least,
we need to decide what type will be used for that sucker (for gcc it's
int on all targets we care about), fix the handling of wide string literals
in initializers and evaluate_string() and stop dropping upper bits in
get_string_constant(). That would probably mean not using struct string
for wide ones, as well... Hell knows; I don't want to touch that right
now. If anything, I'd rather wait until we get to C11 support - they've
got much saner variants of wide strings there (char16_t/char32_t with
u and U as token prefix as L is used for wchar_t; there's also u8"..." for
UTF8 strings).
|
|
-include foo.h will search not only in the current directory...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
This fix the regression report by Dan Carpenter. "x96_64" can be
a valid variable name.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This is improved version of Pekka Enberg's patch
"Fix including glibc headers on x86-64".
To avoid setting 64 bit define in the -m32 case,
the 64 bit initialization needs to delay until all
arguments are handled.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
declare_builtin_functions
Signed-off-by: Frederic Crozat <fcrozat@suse.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The new gcc complain about set but not used
variable. This should make the new gcc happy.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Convert (sizeof arr / sizeof arr[0]) to ARRAY_SIZE(arr).
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The Blackfin port uses some custom attributes to control memory placement,
and it has some custom builtins. So add the ones that the kernel actually
utilizes to avoid massive build errors with sparse.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Morten Welinder <terra@gnome.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Gcc 4.5 defines
extern void __builtin_unreachable(void);
so, add it also to sparse.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Christopher <sparse@chrisli.org>
|
|
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>
|
|
sparse's -Wall option turns on all sparse warnings, including those that
many projects will not want; for instance, warnings that enforce
particular stylistic choices, or behavior allowed by a standard but
considered questionable or error-prone. Furthermore, using -Wall means
accepting all future warnings sparse may start issuing, not just those
intentionally turned on by default.
Other compilers like GCC also use -Wall, and interpret it to mean "turn
on a sensible set of warnings". Since sparse exists to emit warnings,
it already defaults to emitting a sensible set of warnings. Many
projects pass the same options to both sparse and the C compiler,
including warning options like -Wall; this results in turning on
excessive amounts of sparse warnings.
cgcc already filtered out -Wall, but many projects invoke sparse
directly rather than using cgcc. Remove that filter, now that -Wall
does not change sparse's behavior.
Projects almost certainly don't want to use the new -Wsparse-all option;
they should choose the specific set of warnings they want, or just go
with sparse's defaults.
Also update cgcc to know about Wsparse-all and not pass it to GCC, and
update a test case that unnecessarily used -Wall.
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
For Win64 compiles Wine does
#ifndef __ms_va_list
# if defined(__x86_64__) && defined (__GNUC__)
# define __ms_va_list __builtin_ms_va_list
# define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg)
# define __ms_va_end(list) __builtin_ms_va_end(list)
# else
Wouldn't be as bad if sparse cannot handle those but it trips over
WINBASEAPI DWORD WINAPI FormatMessageA(DWORD,LPCVOID,DWORD,DWORD,LPSTR,DWORD,__ms_va_list*);
WINBASEAPI DWORD WINAPI FormatMessageW(DWORD,LPCVOID,DWORD,DWORD,LPWSTR,DWORD,__ms_va_list*);
producing this errors for basically every file:
wine/include/winbase.h:1546:96: error: Expected ) in function declarator
wine/include/winbase.h:1546:96: error: got *
wine/include/winbase.h:1547:97: error: Expected ) in function declarator
wine/include/winbase.h:1547:97: error: got *
Signed-off-by: Michael Stefaniuc <mstefaniuc@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
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>
|
|
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
It's a very annoying warning, and it's about a sparse limitation rather
than a real feature, so don't do it by default.
Sure, our lack of transparent union support will then make us warn about
the magic calling convention hacks (eg you'll see warnings like
connect.c:240:39: warning: incorrect type in argument 2 (invalid types)
connect.c:240:39: expected union __CONST_SOCKADDR_ARG [usertype] __addr
connect.c:240:39: got struct sockaddr *ai_addr
but it still doesn't mean that we have to be so noisy about just seeing
those transparent unions. One annoying warning is not an argument for
doing _another_ annoying warning too (and the calling convention
warnings at least only happen if you actually use them, unlike the
transparent union warning that happens every time we see one, used or
not).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This also fixes a possible source of bugs in parsing other
-f<whatever> options, i.e. -ftabstop=foo would set the option -ffoo.
Signed-off-by: Hannes Eder <hannes@hanneseder.net>
|
|
Make tokenizer aware of tabstops and add the commandline option:
-ftabstop=WIDTH
Set the distance between tab stops. This helps sparse report correct
column numbers in warnings or errors. If the value is less than 1 or
greater than 100, the option is ignored. The default is 8.
With simplifications suggested by Christopher Li and Junio C Hamano.
Signed-off-by: Hannes Eder <hannes@hanneseder.net>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Dirafter was probably just a mistake.
Gcc uses -idirafter.
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Alexey zaytsev <alexey.zaytsev@gmail.com>
|
|
You can now tell sparse where to look for the compiler
headers with -gcc-base-dir <dir>. Otherwise sparse will
look for headers used to build it.
Also adds $GCC_BASE/include-fixed used by newer gcc
versions.
Signed-off-by: Alexey zaytsev <alexey.zaytsev@gmail.com>
|
|
Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
|
|
Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
|
|
Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
|
|
This patch removes the pre_buffer completely. Instead,
sparse will tokenized the buffer during add_pre_buffer().
Sparse just tracks the beginning and end of pre_buffer.
Reviewed-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
Signed-Off-By: Christopher Li <spase@chrisli.org>
|
|
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>
|
|
__FORTIFY_SOURCE=2 converts memcpy() into __builtin___memcpy_chk() etc.
The patch adds some/all? of the relevant builtin prototypes.
Signed-off-by: Geoff Johnstone <geoff.johnstone@googlemail.com>
|
|
This adds support for GCC's -std=... and -ansi command line options,
i.e. defining __STDC_VERSION__ and __STRICT_ANSI__ appropriately.
This means that code that invokes #error if __STDC_VERSION__ < 199901L
will work. It will probably also affect the userland header files too.
Signed-off-by: Geoff Johnstone <geoff.johnstone@googlemail.com>
|
|
Signed-off-by: Tilman Sauerbeck <tilman@code-monkey.de>
|
|
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
2.6.23-rc3-mm1 has added a user of __builtin_labs(), so add this function
to sparse lib.c to avoid the error messages.
CHECK kernel/unwind.c
kernel/unwind.c:1016:31: error: undefined identifier '__builtin_labs'
kernel/unwind.c:1232:25: error: undefined identifier '__builtin_labs'
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
|
|
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
-Wdo-while represents a style warning only, not a correctness warning. Thus,
turn it off by default. Projects that want it should use -Wdo-while
explicitly.
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
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>
|
|
Instead of "always unsigned long" go for "unsigned int unless
-m64 is given, unsigned long otherwise". Add an option (-msize-long)
forcing to unsigned long regardless. Make __SIZE_TYPE__ expansion
match that.
The thing is, addition of checks on comparisons make for very unhappy
min() on (kernel) size_t and sizeof(something) on the targets where
the former is unsigned int. Which is to say, more than half of them...
AFAICS, the only place needing explicit -msize-long in CHECK_FLAGS
is s390 (it's using unsigned long both for 31- and 64-bit).
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
conditional on -Wreturn-void
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
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>
|
|
sparse accepts -E[anything] as directive to preprocess only. On some mips
targets -EL slips into command line resulting in 400-800M logs with
preprocessing results :^) Accept '-E' only from now.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
|
|
-Wdecl warns about global, non-static symbols with no forward declarations.
Normally, intentionally global functions called by other parts of a program
will have forward declarations, so global symbols without such declarations
often have no use outside the current file and should use static.
Note that to avoid false positives, any source file that declares functions
for export should always include the header file that forward-declares its own
functions. This also helps for other reasons, such as obtaining any Sparse
annotations declared on the function to use when analyzing calls to it from
within the same source file.
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
a NULL pointer
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
Makes __DATE__expand to a character string literal of
the form "Mmm dd yyyy" where the names of the months
are the same as those generated by the asctime function,
and the first character of dd is a space character if the
value is less than 10.
Makes __TIME__ expand to a a character string literal of
the form "hh:mm:ss" as in the time generated by the
asctime function.
Signed-off-by: Damien Lespiau <damien.lespiau@gmail.com>
|
|
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
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>
|
|
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>
|
|
Signed-Off-By: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
Signed-off-by: Christopher Li<sparse@chrisli.org>
|
|
If -Wall is specified, enable all warnings except those explicitly
disabled by -Wno-* switches.
Signed-off-by: Pavel Roskin <proski@gnu.org>
|
|
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>
|
|
Sparse only returns the used symbol. By the time it return
the symbol, it already destroyed the file scope.
This patch preserve the file scope. The caller can
examine the unused symbols. e.g. If I want to generate
ctags base on sparse, it need those unused symbols.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
|
|
|
|
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>
|
|
Context checking currently requires explicitly passing the -Wcontext option.
In a Linux build, this requires passing CF=-Wcontext. Thus, running people
running sparse over Linux or other software in the default way will not see
context warnings. Change this by enabling -Wcontext.
While context checking does generate false positives, due to both missing
annotations on kernel functions and insufficiently clever checking in sparse,
the context warnings still do provide useful information and help track down
real bugs. Furthermore, showing these warnings by default may incite more
people to add annotations or enhance sparse. As a last resort, -Wno-context
will still work.
Signed-off-by: Josh Triplett <josh@freedesktop.org>
|
|
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 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>
|
|
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>
|
|
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>
|
|
sparse_error() sets max_warnings = 0 to silence subsequent sparse_warning()s
or info()s; however, this also silences the info() after that sparse_error()
and subsequent sparse_errors() which still get shown. bad_expr_type runs into
this problem: it reports an error with sparse_error() and then provides
further information with info(), which the user never sees. Make info()
continue to print as long as the immediately preceeding warning or error does.
Signed-off-by: Josh Triplett <josh@freedesktop.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
|
|
Signed-off-by: Josh Triplett <josh@freedesktop.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
|
|
Signed-off-by: Josh Triplett <josh@freedesktop.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
|
|
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>
|
|
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>
|
|
with -D
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
|
|
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>
|
|
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>
|
|
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
|
|
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>
|
|
Noted by Mitesh Shah
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
|
|
When I ran make C=1 on linux-mips kernel, I got:
CHECK /home/cvs/linux-mips/scripts/mod/empty.c
No such file: 0
If I ran make C=1 V=1, I got:
sparse -D__linux__ -D__mips__ -D_MIPS_SZLONG=32 -D__PTRDIFF_TYPE__=int
-D__MIPSEL__ -nostdinc -isystem /usr/lib/gcc/mipsel-linux/3.4.4/include
-Wp,-MD,scripts/mod/.empty.o.d -nostdinc
-isystem /usr/lib/gcc/mipsel-linux/3.4.4/include
-D__KERNEL__ -Iinclude -Iinclude2 -I/home/cvs/linux-mips/include
-I/home/cvs/linux-mips/scripts/mod -Iscripts/mod -Wall -Wundef
-Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common
-ffreestanding -O2 -fomit-frame-pointer -I/home/cvs/linux-mips/
-I /home/cvs/linux-mips/include/asm/gcc -G 0 -mno-abicalls
^^^^
-fno-pic -pipe -finline-limit=100000 -mabi=32 -march=r3000
-Wa,-32 -Wa,-march=r3000 -Wa,-mips1
-I/home/cvs/linux-mips/include/asm-mips/mach-dec
-Iinclude/asm-mips/mach-dec
-I/home/cvs/linux-mips/include/asm-mips/mach-generic
-Iinclude/asm-mips/mach-generic -DKBUILD_BASENAME=empty
-DKBUILD_MODNAME=empty /home/cvs/linux-mips/scripts/mod/empty.c ;
No such file: 0
It seems sparse is confused by '-G 0' option.
This fixes it.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
|
|
This replaceq calls to warning() with error() at places where (I think)
the gcc reports an error. Also added a global variable die_if_error
which is set if there is one or more errors. If someone wants to stop
processing further, can check for the variable.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
|
|
Yeah, this is not the way to do them (we should have _real_ builtin
declarations instead of parsing them to create them), but this is the
simple solution to gcc-aware header files.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
|
|
It needs to have a value, since otherwise something like
#if __OPTIMIZE__ > 1
breaks.
|
|
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>
|
|
Fix logs flooding on sparc:
include/asm/bug.h:12:46: warning: undefined preprocessor identifier '__GNUC_PATCHLEVEL__'
|
|
* 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>
|
|
As noted by Arnaldo Carvalho de Melo, some of the glibc header files
expect these to be defined when compiling with optimization.
|
|
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.
|
|
This actually seems to do some sane things when parsing even complex
multiple files. In particular, it actually works right when used for
multiple kernel C files together in limited testing.
|
|
Pretty bogus right now, but at least it does more of the argument
parsing, and the infrastructure is there to handle multiple files.
It even works, sometimes. Mostly not, though - since it will actually
use global scope for global types, and complain about redefinitions of
the same struct when it sees ti in two different compilation units.
|
|
Brought on by a query from Mitesh Shah. I claimed it should be easy,
let's see if I was full of sh*t (this is just some very early
infrastructure, not the whole thing by any means!)
|
|
It just expands to the normal offsetof definition
|
|
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.
|
|
This is a bit hacky, but it tends to do what people expect most
of the time.
|
|
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
|
|
This patch add static declare to make sparse happy of checking itself.
|
|
They rate their own "ptrlist" library status, since they are
definitely potentially useful outside of sparse.
|
|
warning count.
Also make errors shut up subsequent warnings.
|
|
Search include paths in same order as gcc does.
In other words search directories specified with -I before system
directories.
This fixes a bug reported by a few persons after the kernel switched
over to use -isystem to specify where to find compiler specific include files.
Sparse now supports the following include path relevant options:
-I dir Add dir to list of directories to search for. Search dir
before system dirs. Used for both <> and "" includes.
-I- Split include path - previous -I dir paths only used for
include "".
Also disable searching same dir as input file.
-isystem dir Add dir first in row of system dirs to search.
-dirafter dir Add dir in end of system dirs to search.
-nostdinc Discard all defined system dirs
The -iwithprefix, -iprefix and -iwithprefixbefore options are not not
supported and silently ignored. gcc discourage use of these options.
|
|
With latest change to kbuild where
-isystem `gcc -print-file-name=include'
is used to specify where to locate stdarg.h sparse failed to locate
stdarg.h.
This adds support of -isystem to sparse.
|
|
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.
|
|
count.
The caller want to know how many got removed if they didn't
specify an exact count to begin with.
|
|
|
|
Right now we verify that low bits are clear when inserting,
and clear them on use.
|
|
Much prettier than "input_streams[x].name", since most
users really don't want to know about the internals of
how the preprocessor lays out its stream tracking.
|
|
Replace it with a simple pathname comparison instead.
The pathname check is not only portable (no need for any
compatibility helper functions), but we can do it much
earlier, and thus make the check much cheaper by avoiding
three extra system calls when it triggers (open/fstat/close).
And the pathname test seems to match all the cases anyway.
|
|
|
|
We didn't set the back-pointer of the "next" entry properly.
Not a lot of code cares, since most things just walk forward.
|
|
When we packed away the first entry in the list, we didn't
restart properly.
|
|
point we are now when traversing a list.
NOTE! If you traverse it forwards, the next entry you'll
see is the current entry, since we do not change where
in the list we are!
|
|
It's disgusting how intimate lib.c is with all the types,
and this is slowly trying to split things up a bit. Now
the intimate part is in allocate.c, but maybe we can get
to the point where each allocation user just declares its
own allocation strategy, and just uses the generic routines
in allocate.c
|
|
uninteresting parts only with "-v -v". Dead blocks in particular.
Also, don't even put a pseudo on the OP_RET if were a void
function. That makes the liveness analysis happier.
|
|
Which explains why the flow info was all bad. Duh.
|
|
|
|
It will assrt if it can't find that many entries.
Zero means "all the ones you can find", aka old behaviour.
|
|
You just have to be a bit crazy (*), and use "__typeof__" in
creative ways.
(*) Ok, a _lot_ crazy. But dammit, I want type-safety _and_
convenience, and I'm willing to do a few crazy macros to get
it.
|
|
|
|
Nothing uses it yet, but it's a good way to test bad
ideas (call it an "optimization", and run diff on the
result with and without).
|
|
The instruction contains everything "struct phi" had, namely
source bb and pseudo. And generating a new pseudo means that
we not only have the pointer to the instruction that defines
the phi-node (in pseudo->def), we also end up with automatic
phi-node usage tracking (pseudo->users).
The changes may look large, but almost all of this is just
direct search-and-replace of the old phi-node usage.
|
|
Let's just face the fact that nobody actually wants to care about
command line switches, builtins etc. Put it all in lib.c and make
it easy to use.
|
|
It removes empty list blocks from the list. If you remove
list entries, you should pack the list afterwards to make
sure that there aren't any empty blocks that may upset the
list walker functions.
|
|
|
|
Instead of having magic iterators over the last instruction
of a basic block, we just add a list of "children" to each
basic block.
This removes all the packing logic, because it needs to be
totally rewritten to work with the new iterators.
|
|
entries, optimize for them.
This cuts down another 10% on the test-case from
hell.
|
|
This is useful for tokens. They are nice and small and constant-sized,
and there are millions and millions of them, so re-using them when we
can actually matters.
|