Structures from -include are "weak"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello!

I'm trying to use sparse on standalone kernel drivers that use -include
to include compatibility code for slightly older kernels, so that it's
possible to have exactly the same driver sources in the kernel and in
the standalone project.

Support for multiple -include switches has been very helpful, and things
have been working fine for some time, but now I'm seeing massive error
messages about dereferencing members of incomplete structures.

I've been able to reduce the problem to the following test case.

test.h:

struct st {
        int len;
};

test.c:

struct st;
int test(struct st *s);
int test(struct st *s)
{
        return s->len;
}

Commands to run:

$ sparse -include test.h test.c
test.c:5:10: error: using member 'len' in incomplete struct st
$ gcc -c -include test.h test.c
$

It looks like the definition of struct st is sort of "weak" when it's
read from the header included on the command line, so that the forward
declaration from test.c removes the original definition.

It's also possible to define struct st to something else, and sparse
won't warn about it.  But omitting "struct st;" fixes the error, so the
original definition is known to sparse.

-- 
Regards,
Pavel Roskin
-
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux