From: Christopher Li <sparse@chrisli.org>
To: Robert Catherall <Robert.Catherall@arm.com>
Cc: linux-sparse@vger.kernel.org
Subject: Re: bitwise with memcpy and void*
Date: Sun, 12 Jul 2009 10:37:17 -0700 [thread overview]
Message-ID: <70318cbf0907121037j6a64a565k726a389df3f034ed@mail.gmail.com> (raw)
In-Reply-To: <DD2D1CDF962D7346A5B0E5EE9CA3612711422805@ZIPPY.Emea.Arm.com>
On Sat, Jul 11, 2009 at 9:47 AM, Robert
Catherall<Robert.Catherall@arm.com> 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
prev parent reply other threads:[~2009-07-12 17:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <AcoCR0k8a89nhOCfTzWiwUhqEVZAPg==>
2009-07-11 16:47 ` bitwise with memcpy and void* Robert Catherall
2009-07-12 17:37 ` Christopher Li [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=70318cbf0907121037j6a64a565k726a389df3f034ed@mail.gmail.com \
--to=sparse@chrisli.org \
--cc=Robert.Catherall@arm.com \
--cc=linux-sparse@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).