Re: bitwise with memcpy and void*

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

 



On Sat, Jul 11, 2009 at 9:47 AM, Robert
Catherall<Robert.Catherall@xxxxxxx> wrote:
> 1. Specifically data was copied from a buffer in BE format to a buffer
> in LE format using memcpy(). Using memcpy is kind of implying that the
> programmer believes the types of the source and destination buffers are
> compatible, so it would be nice if sparse could issue a warning when
> they are not.

I think what you want is:

memcpy(pLE, pBE, len); // warning
memcpy(pBE, pLE, len); // warning
memcpy(pLE1, pLE2, len); // no warning
memcpy(pBE1, pBE2, len); // no warning

That can no be done with stock sparse checking.
Because you need correlation between the first and
second argument.

You can get that kind of feature by extending your own
version of the checking. You just need to implement your
own version of check_memcpy in sparse.c.

>
> 2. Next I tried writing my own memcpy in the hope that I would then get
> warnings in the normal way but got a warning implying that sparse knows
> about memcpy
>
> warning: conflicting types for built-in function "memcpy"
> foo.c: In function "memcpy":

Are you sure it is from sparse not gcc? Sparse has prototypes for
the built-in function "__builtin_memcpy" that is about it.

>

> Is this treatment of void* expected behaviour?

Right. void* means you don't care about the type of the pointer.

BTW, I just find out the Wbitwise is not used any where.
Which means you can't turn Wbitwise off. Should be easy enough to
fix though.

Chris
--
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