Novafora license grant using MIT license.

Novafora licenses IP formerly owned by Transmeta Corporation under the MIT license.  (Novafora purchased Transmeta January of 2009.)

signed-off-by: Robert Bedichek <rbedichek@novafora.com>
Larger buffer size for token concatenation

Currently there are a few source file in the kernel can't
parse property due to over run of the concatenation buffer.
They either have a large string concatnation or huge macro
expand.  The TRACE macro is a common one.

Now show_token_sequence and quote_token_sequence is combined
into one function with a bigger buffer. It works for most
of the kernel source except the config_data.h. The kernel
config is about 70K, larger than the string allocator chunk size.
It needs some plumbing work in the allocator before we can
allow bigger string token.

Signed-off-by: Christopher Li <sparse@chrisli.org>
There's no current way to know the version
of sparse.  Add --version to see it.

Reviewed-by: Joe Perches <joe@perches.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Proper variable length array warning

The previous warning about bad constant is actually
mean for variable length array.

Signed-off-by: Christopher Li <sparse@chrisli.org>
Warn about initialization of a char array with a too long constant C string.

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>
Test case for -Winit-cstring option

This patch added a test case for -Winit-cstring option
to validation directory.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Add description for -Winit-cstring option

This patch added description for -Winit-cstring option
to sparse.1.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Define __SIZEOF_POINTER__

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>
Support #pragma once

"#pragma once" acts like a multiple-inclusion guard affecting the entire file,
without an associated preprocessor symbol.

This allows use of sparse on projects that rely on #pragma once without
also using an ifndef-based multiple-inclusion guard, such as systemd;
without this change, sparse will get into an include loop.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Allow forced attribute in function argument

It will indicate this argument will skip the type compatible check.
It allow PTR_ERR() to accept __iomem pointer without complaining.

Signed-off-by: Christopher Li <sparse@chrisli.org>
fix SIGFPE caused by signed division overflow

Avoid evaluating INT_MIN / -1 and INT_MIN % -1, which will trap on x86
and crash sparse.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
sparse, llvm: fix link errors

This patch fixes the following link errors.

    libLLVMSupport.a(Signals.o): In function `llvm::sys::PrintStackTrace(_IO_FILE*)':
    Signals.inc:269: undefined reference to `dladdr'
    Signals.inc:281: undefined reference to `dladdr'

Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Trivial: Remove redundant Makefile variable

Signed-off-by: Christopher Li <sparse@chrisli.org>
char.c: Fix parsing of escapes

When parsing a string or character constant, the parse_escape()
function returns a pointer to the character at which to resume
parsing. However, in the case of an hex or octal escape, it was
returning a one-past-the-end pointer. Thus, a string like:

    char str[3] = "\x61\x62\x63";

was being parsed as:

    '\x61', 'x', '6', '2', '\x63'

which, in turn, provokes an 'too long initializer' warning.

Also, fix an off-by-one error in get_char_constant() when setting
the 'end' pointer for a TOKEN_CHAR or TOKEN_WIDE_CHAR. Despite the
name, the string->length of the token is actually the size of the
allocated memory (ie len+1), so we need to compensate by using
'token->string->length - 1'.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
sparse, llvm: fix phi generation

PHI in LLVM is different from that in sparse.  LLVM requires PHI "for
each predecessor basic block of the current block" even if the current
block doesn't use it.  It's tricky to correctly place PHI.

This patch implements a simpler and safer strategy:
1) allocate an alloca for each phi, and
2) translate phi/phisrc to load/store alloca.
LLVM optimizations will promote load/store to registers.

Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
sparse, llvm: simplify function generation

Remove repeated code, such as get_func_type() vs sym_func_type(),
pseudo_type() vs symbol_type().

Fix generating variadic functions.

Add a test case using printf().

Cc: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
sparse, llvm: Fix resulting type of store address calculations

Use the fix from d5bd3662 ("sparse, llvm: Fix type of loaded values").

Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
sparse, llvm: de-duplicate load/store address calculation code

Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
sparse, llvm: base load/store address type on insn_symbol_type()

LLVM needs to be correctly told about the type of the object
being accessed.

This patch also fixes code generation for struct accesses.

Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
sparse, llvm: add a struct access test case

Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Pekka Enberg <penberg@kernel.org>