[cfe-dev] FixIt idea: memset(buf, sizeof(buf), fill_val) => memset(buf, fill_val, sizeof(buf))
David Chisnall
David.Chisnall at cl.cam.ac.uk
Mon Mar 24 10:39:51 PDT 2014
On 24 Mar 2014, at 17:03, Jevin Sweval <jevinsweval at gmail.com> wrote:
> I just found myself making the mistake mentioned in the subject. No
> warnings, even with -Weverything. The fixit would recognize a sizeof()
> in the fill value position and suggest the swap.
I think there is a general case where you have:
- A function that takes a buffer and a size as arguments
- A parameter pair that is a buffer and the size of that buffer
- The size not being the size of the buffer.
It would be great to have this warning for the general case. I think there's an attribute that lets you mark a parameter as the size of another, but we could treat things like memset() as special cases if they lack this attribute.
David
More information about the cfe-dev
mailing list