From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343955AbiHZJcz (ORCPT ); Fri, 26 Aug 2022 05:32:55 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB118D9D7D for ; Fri, 26 Aug 2022 02:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : content-type : in-reply-to : mime-version; s=corp-2022-7-12; bh=9Too0i8hJGqqGAUw3lUHAeTGVmCciarl0X5xJ8MMEsQ=; b=H5UbNFg8DzX3q0v0pvTFNJQytASgZul7OwgGPRgoP+fIApoqQp0tarxZr+dXmEDAL4Co MUtxm0rPC7OrUoAorOawyJdj9gWx8PweBj87NvMYNlx+IT/Vs/anP+Ww63WDWR8NNujw BekQqtLFF+LnHNSvIzH/D8KhQ+EhK0YSotHcZbJib4xsZTjXwd4XLAk/i6eeTZgzga5x sNj1+IrmcBN5VMJ9vmROLIzusxpTXs4XZpVDn0Ro61+PGpQQe7uA+9ggKGv/AJ1UMgHC JTLv4Brrz1Qsea231eD9nX7Bdbh9gQRzvLaiIVz35bp5IaP1zTKU0mm7CpqbgQ8vqCEh FA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9Too0i8hJGqqGAUw3lUHAeTGVmCciarl0X5xJ8MMEsQ=; b=ujvbVRe6lkRUwjnLL1z6mvemKDzoo9spuibLuFq99miZK1qU6hjae3UWcs51NP+5BD+4oPBEjEfSMMforPEPORr17self6d1nJU4PzYhwMIXNz5UuXbA3/jheyjPO0UgDyFoXanFn7f05YeLzBBv9cDnHvDkQaXtbCTqPIFuysU= Date: Fri, 26 Aug 2022 12:31:30 +0300 From: Dan Carpenter Subject: Re: [PATCH] allocation: Track the size of allocated elements Message-ID: <20220826093130.GD2071@kadam> References: <62f7440119bd4f2601ac581ed12bb24fbbb63ea9.1661450049.git.christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <62f7440119bd4f2601ac581ed12bb24fbbb63ea9.1661450049.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 List-ID: To: Christophe JAILLET Cc: smatch@vger.kernel.org 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 > --- > 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