* linux kernel warnings/errors
@ 2010-02-23 19:49 Randy Dunlap
2010-02-23 20:59 ` Josh Triplett
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Randy Dunlap @ 2010-02-23 19:49 UTC (permalink / raw)
To: linux-sparse
Hi,
You probably know that sparse produces a ton of errors & warnings when
run on the Linux kernel tree (a little over 1 MB in my latest 'make C=1'
on x86_64 arch.).
I'm wondering if all of these are valid.
Examples:
1. Use of the BUILD_BUG_ON() macro causes this error from sparse:
arch/x86/kernel/paravirt.c:101:9: error: invalid bitfield width, -1.
include/linux/kernel.h:
/* Force a compilation error if condition is true */
#define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition))
/* Force a compilation error if condition is true, but also produce a
result (of value 0 and type size_t), so the expression can be used
e.g. in a structure initializer (or where-ever else comma expressions
aren't permitted). */
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
2. drivers/block/drbd/drbd_int.h uses __protected_by(var);
this seems to be unknown to sparse.
#ifdef __CHECKER__
# define __protected_by(x) __attribute__((require_context(x,1,999,"rdwr")))
sparse says many times:
drivers/block/drbd/drbd_int.h:887:39: error: attribute 'require_context': unknown attribute
3. I don't see the problem here -- maybe it's simple (or maybe it's
related to BUILD_BUG_ON stuff):
drivers/char/ipmi/ipmi_watchdog.c:291:1: error: cannot dereference this type
referring to:
module_param_call(action, set_param_str, get_param_str, action_op, 0644);
which comes from include/linux/moduleparam.h
4. from include/linux/swab.h:
include/linux/swab.h:51:16: warning: unreplaced symbol 'val'
include/linux/swab.h:51:16: warning: unreplaced symbol 'val'
include/linux/swab.h:51:9: warning: unreplaced symbol 'return'
referring to:
static inline __attribute_const__ __u16 __fswab16(__u16 val)
{
#ifdef __arch_swab16
return __arch_swab16(val);
#else
return ___constant_swab16(val);
#endif
}
5. sparse reports (maybe correctly?):
include/linux/skbuff.h:357:41: error: invalid bitfield specifier for type restricted __be16.
on struct sk_buff, this line:
__be16 protocol:16;
6. sparse reports:
drivers/usb/gadget/zero.c:166:9: warning: advancing past deep designator
on
static struct usb_string strings_dev[] = {
[STRING_MANUFACTURER_IDX].s = manufacturer,
[STRING_PRODUCT_IDX].s = longname,
[STRING_SERIAL_IDX].s = serial,
{ } /* end of list */
};
Is that an improper initializer? The sparse warning doesn't mean much to me.
Thanks for listening, insights, etc.
---
~Randy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: linux kernel warnings/errors
2010-02-23 19:49 linux kernel warnings/errors Randy Dunlap
@ 2010-02-23 20:59 ` Josh Triplett
2010-02-23 22:20 ` Randy Dunlap
2010-02-23 22:40 ` linux kernel warnings/errors (#7) Randy Dunlap
2010-02-24 0:55 ` linux kernel warnings/errors (#8) Randy Dunlap
2 siblings, 1 reply; 5+ messages in thread
From: Josh Triplett @ 2010-02-23 20:59 UTC (permalink / raw)
To: Randy Dunlap; +Cc: linux-sparse
On Tue, Feb 23, 2010 at 11:49:06AM -0800, Randy Dunlap wrote:
> Hi,
>
> You probably know that sparse produces a ton of errors & warnings when
> run on the Linux kernel tree (a little over 1 MB in my latest 'make C=1'
> on x86_64 arch.).
>
> I'm wondering if all of these are valid.
>
> Examples:
>
>
> 1. Use of the BUILD_BUG_ON() macro causes this error from sparse:
>
> arch/x86/kernel/paravirt.c:101:9: error: invalid bitfield width, -1.
>
> include/linux/kernel.h:
>
> /* Force a compilation error if condition is true */
> #define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition))
>
> /* Force a compilation error if condition is true, but also produce a
> result (of value 0 and type size_t), so the expression can be used
> e.g. in a structure initializer (or where-ever else comma expressions
> aren't permitted). */
> #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
In theory that should only happen if the BUILD_BUG_ON_ZERO actually
triggers, and thus sparse fails to build just as GCC would. If sparse
has this problem and GCC doesn't, could you please provide a minimal
test case?
> 2. drivers/block/drbd/drbd_int.h uses __protected_by(var);
> this seems to be unknown to sparse.
>
> #ifdef __CHECKER__
> # define __protected_by(x) __attribute__((require_context(x,1,999,"rdwr")))
>
> sparse says many times:
>
> drivers/block/drbd/drbd_int.h:887:39: error: attribute 'require_context': unknown attribute
That looks broken. A few patches went around for new Sparse
context-tracking features, one of which got reverted before the 0.4.2
release, but I don't think any of them would have allowed *that*.
- Josh Triplett
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: linux kernel warnings/errors
2010-02-23 20:59 ` Josh Triplett
@ 2010-02-23 22:20 ` Randy Dunlap
0 siblings, 0 replies; 5+ messages in thread
From: Randy Dunlap @ 2010-02-23 22:20 UTC (permalink / raw)
To: Josh Triplett; +Cc: linux-sparse
[-- Attachment #1: Type: text/plain, Size: 1845 bytes --]
On 02/23/10 12:59, Josh Triplett wrote:
> On Tue, Feb 23, 2010 at 11:49:06AM -0800, Randy Dunlap wrote:
>> Hi,
>>
>> You probably know that sparse produces a ton of errors & warnings when
>> run on the Linux kernel tree (a little over 1 MB in my latest 'make C=1'
>> on x86_64 arch.).
>>
>> I'm wondering if all of these are valid.
>>
>> Examples:
>>
>>
>> 1. Use of the BUILD_BUG_ON() macro causes this error from sparse:
>>
>> arch/x86/kernel/paravirt.c:101:9: error: invalid bitfield width, -1.
>>
>> include/linux/kernel.h:
>>
>> /* Force a compilation error if condition is true */
>> #define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition))
>>
>> /* Force a compilation error if condition is true, but also produce a
>> result (of value 0 and type size_t), so the expression can be used
>> e.g. in a structure initializer (or where-ever else comma expressions
>> aren't permitted). */
>> #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
>
> In theory that should only happen if the BUILD_BUG_ON_ZERO actually
> triggers, and thus sparse fails to build just as GCC would. If sparse
> has this problem and GCC doesn't, could you please provide a minimal
> test case?
Sure, attached.
>> 2. drivers/block/drbd/drbd_int.h uses __protected_by(var);
>> this seems to be unknown to sparse.
>>
>> #ifdef __CHECKER__
>> # define __protected_by(x) __attribute__((require_context(x,1,999,"rdwr")))
>>
>> sparse says many times:
>>
>> drivers/block/drbd/drbd_int.h:887:39: error: attribute 'require_context': unknown attribute
>
> That looks broken. A few patches went around for new Sparse
> context-tracking features, one of which got reverted before the 0.4.2
> release, but I don't think any of them would have allowed *that*.
Yeah, I recall seeing some of the context patches.
Thanks.
--
~Randy
[-- Attachment #2: build_bug_on.c --]
[-- Type: text/x-csrc, Size: 713 bytes --]
/* Force a compilation error if condition is true */
#define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition))
/* Force a compilation error if condition is true, but also produce a
result (of value 0 and type size_t), so the expression can be used
e.g. in a structure initializer (or where-ever else comma expressions
aren't permitted). */
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
struct branch {
unsigned char opcode;
int delta;
} __attribute__((packed));
unsigned paravirt_patch_call(void *insnbuf)
{
struct branch *b = insnbuf;
b->opcode = 0xe8; /* call */
b->delta = 0x1234;
BUILD_BUG_ON(sizeof(*b) != 5);
return 5;
}
int main(int argc, char *argv[])
{
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: linux kernel warnings/errors (#7)
2010-02-23 19:49 linux kernel warnings/errors Randy Dunlap
2010-02-23 20:59 ` Josh Triplett
@ 2010-02-23 22:40 ` Randy Dunlap
2010-02-24 0:55 ` linux kernel warnings/errors (#8) Randy Dunlap
2 siblings, 0 replies; 5+ messages in thread
From: Randy Dunlap @ 2010-02-23 22:40 UTC (permalink / raw)
To: linux-sparse
On 02/23/10 11:49, Randy Dunlap wrote:
> Hi,
>
> You probably know that sparse produces a ton of errors & warnings when
> run on the Linux kernel tree (a little over 1 MB in my latest 'make C=1'
> on x86_64 arch.).
>
> I'm wondering if all of these are valid.
>
> Examples:
(one addition)
7. from drivers/gpu/drm/radeon/atombios.h:
#define VESA_OEM_PRODUCT_REV '01.00'
#define VESA_MODE_ATTRIBUTE_MODE_SUPPORT 0xBB /* refer to VBE spec p.32, no TTY support */
causes sparse to say:
drivers/gpu/drm/radeon/atombios.h:4091:63: error: Bad character constant
drivers/gpu/drm/radeon/atombios.h:4092:1: error: Bad character constant
That second one is a bit confusing. It's just a remnant of the first one...
--
~Randy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: linux kernel warnings/errors (#8)
2010-02-23 19:49 linux kernel warnings/errors Randy Dunlap
2010-02-23 20:59 ` Josh Triplett
2010-02-23 22:40 ` linux kernel warnings/errors (#7) Randy Dunlap
@ 2010-02-24 0:55 ` Randy Dunlap
2 siblings, 0 replies; 5+ messages in thread
From: Randy Dunlap @ 2010-02-24 0:55 UTC (permalink / raw)
To: linux-sparse
[-- Attachment #1: Type: text/plain, Size: 1427 bytes --]
On 02/23/10 11:49, Randy Dunlap wrote:
> Hi,
>
> You probably know that sparse produces a ton of errors & warnings when
> run on the Linux kernel tree (a little over 1 MB in my latest 'make C=1'
> on x86_64 arch.).
>
> I'm wondering if all of these are valid.
>
> Examples:
8. There are many cases of sparse "error: bad integer constant expression"
that gcc handles without a problem, when the constant expression uses a
macro or static inline function:
a. drivers/gpu/drm/drm_drv.c:59:9: error: bad integer constant expression
static struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, 0),
b. drivers/media/video/v4l2-ioctl.c:185:10: error: bad integer constant expression
static const char *v4l1_ioctls[] = {
[_IOC_NR(VIDIOCGCAP)] = "VIDIOCGCAP",
};
c. fs/proc/array.c:154:9: error: bad integer constant expression
BUILD_BUG_ON(1 + ilog2(TASK_STATE_MAX) != ARRAY_SIZE(task_state_array));
d. sound/pci/hda/hda_proc.c:422:18: error: bad integer constant expression
static char *names[] = {
[ilog2(AC_PWRST_D0SUP)] = "D0",
};
e. drivers/gpu/drm/drm_ioc32.c:1017:10: error: bad integer constant expression
drm_ioctl_compat_t *drm_compat_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
};
I have a test case for "d." above.
(attached)
> sparse const_sound.c
const_sound.c:114:18: error: bad integer constant expression
--
~Randy
[-- Attachment #2: const_sound.c --]
[-- Type: text/x-csrc, Size: 2798 bytes --]
#include <asm-generic/ioctl.h>
static inline __attribute__((const))
int fls(unsigned int n)
{
return 0;
}
static inline __attribute__((const))
int fls64(unsigned int n)
{
return 63;
}
static inline __attribute__((const))
int __ilog2_u32(unsigned int n)
{
return fls(n) - 1;
}
static inline __attribute__((const))
int __ilog2_u64(unsigned long n)
{
return fls64(n) - 1;
}
static inline __attribute__((const))
int ____ilog2_NaN(void)
{
return -1;
}
#define ilog2(n) \
( \
__builtin_constant_p(n) ? ( \
(n) < 1 ? ____ilog2_NaN() : \
(n) & (1ULL << 63) ? 63 : \
(n) & (1ULL << 62) ? 62 : \
(n) & (1ULL << 61) ? 61 : \
(n) & (1ULL << 60) ? 60 : \
(n) & (1ULL << 59) ? 59 : \
(n) & (1ULL << 58) ? 58 : \
(n) & (1ULL << 57) ? 57 : \
(n) & (1ULL << 56) ? 56 : \
(n) & (1ULL << 55) ? 55 : \
(n) & (1ULL << 54) ? 54 : \
(n) & (1ULL << 53) ? 53 : \
(n) & (1ULL << 52) ? 52 : \
(n) & (1ULL << 51) ? 51 : \
(n) & (1ULL << 50) ? 50 : \
(n) & (1ULL << 49) ? 49 : \
(n) & (1ULL << 48) ? 48 : \
(n) & (1ULL << 47) ? 47 : \
(n) & (1ULL << 46) ? 46 : \
(n) & (1ULL << 45) ? 45 : \
(n) & (1ULL << 44) ? 44 : \
(n) & (1ULL << 43) ? 43 : \
(n) & (1ULL << 42) ? 42 : \
(n) & (1ULL << 41) ? 41 : \
(n) & (1ULL << 40) ? 40 : \
(n) & (1ULL << 39) ? 39 : \
(n) & (1ULL << 38) ? 38 : \
(n) & (1ULL << 37) ? 37 : \
(n) & (1ULL << 36) ? 36 : \
(n) & (1ULL << 35) ? 35 : \
(n) & (1ULL << 34) ? 34 : \
(n) & (1ULL << 33) ? 33 : \
(n) & (1ULL << 32) ? 32 : \
(n) & (1ULL << 31) ? 31 : \
(n) & (1ULL << 30) ? 30 : \
(n) & (1ULL << 29) ? 29 : \
(n) & (1ULL << 28) ? 28 : \
(n) & (1ULL << 27) ? 27 : \
(n) & (1ULL << 26) ? 26 : \
(n) & (1ULL << 25) ? 25 : \
(n) & (1ULL << 24) ? 24 : \
(n) & (1ULL << 23) ? 23 : \
(n) & (1ULL << 22) ? 22 : \
(n) & (1ULL << 21) ? 21 : \
(n) & (1ULL << 20) ? 20 : \
(n) & (1ULL << 19) ? 19 : \
(n) & (1ULL << 18) ? 18 : \
(n) & (1ULL << 17) ? 17 : \
(n) & (1ULL << 16) ? 16 : \
(n) & (1ULL << 15) ? 15 : \
(n) & (1ULL << 14) ? 14 : \
(n) & (1ULL << 13) ? 13 : \
(n) & (1ULL << 12) ? 12 : \
(n) & (1ULL << 11) ? 11 : \
(n) & (1ULL << 10) ? 10 : \
(n) & (1ULL << 9) ? 9 : \
(n) & (1ULL << 8) ? 8 : \
(n) & (1ULL << 7) ? 7 : \
(n) & (1ULL << 6) ? 6 : \
(n) & (1ULL << 5) ? 5 : \
(n) & (1ULL << 4) ? 4 : \
(n) & (1ULL << 3) ? 3 : \
(n) & (1ULL << 2) ? 2 : \
(n) & (1ULL << 1) ? 1 : \
(n) & (1ULL << 0) ? 0 : \
____ilog2_NaN() \
) : \
(sizeof(n) <= 4) ? \
__ilog2_u32(n) : \
__ilog2_u64(n) \
)
// d. sound/pci/hda/hda_proc.c:422:18: error: bad integer constant expression
#define AC_PWRST_D0SUP (1<<0)
static char *names[] = {
[ilog2(AC_PWRST_D0SUP)] = "D0",
};
int main(int argc, char *argv[])
{
}
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-02-24 0:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-23 19:49 linux kernel warnings/errors Randy Dunlap
2010-02-23 20:59 ` Josh Triplett
2010-02-23 22:20 ` Randy Dunlap
2010-02-23 22:40 ` linux kernel warnings/errors (#7) Randy Dunlap
2010-02-24 0:55 ` linux kernel warnings/errors (#8) Randy Dunlap
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).