From: Dan Carpenter <dan.carpenter@oracle.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: smatch@vger.kernel.org
Subject: Re: [PATCH] allocation: Track the size of allocated elements
Date: Fri, 26 Aug 2022 12:31:30 +0300 [thread overview]
Message-ID: <20220826093130.GD2071@kadam> (raw)
In-Reply-To: <62f7440119bd4f2601ac581ed12bb24fbbb63ea9.1661450049.git.christophe.jaillet@wanadoo.fr>
On Thu, Aug 25, 2022 at 07:54:20PM +0200, Christophe JAILLET wrote:
> Add a new parameter, 'elem_size', which tells which argument holds the
> size of an individual element.
>
> Many checks need this parameter, and up to now, we only have an expression
> that shows how to compute the total amount of memory that is allocated.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Not sure it is the best way to do it.
>
> In smatch.h, how are populated:
> struct expression *total_size;
> struct expression *nr_elems;
> struct expression *elem_size;
> ?
>
> With my first trials, these expr are always NULL.
Yeah. That code is not implemented yet. Or more accurately, I
implemented it last week but I haven't tested it yet or published it.
I think once I publish that (later today probably) then it's a better
option than passing the strings.
I guess what I'm thinking there is that I quite like the size_str the
way it is. It's easier to fill in the alloc_fns[] table with just the
size_str. It's ultimate in flexibility.
Then I think for kmalloc() I'll fill in the ->total_size expression.
For kmalloc_array(), I'll leave total_size NULL and fill in the
->nr_elements and ->elem_size. It feels like there should be another
way set of expressions for struct_size().
That's sort of roughly where I'd like to go.
If you really want this then I can apply it but hopefully you won't
want it if you have the expressions instead. Expression pointers are
better.
regards,
dan carpenter
next prev parent reply other threads:[~2022-08-26 9:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-25 17:54 [PATCH] allocation: Track the size of allocated elements Christophe JAILLET
2022-08-26 9:31 ` Dan Carpenter [this message]
2022-08-26 10:05 ` Marion & Christophe JAILLET
2022-08-26 10:33 ` Dan Carpenter
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=20220826093130.GD2071@kadam \
--to=dan.carpenter@oracle.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=smatch@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.