From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 427B043F09; Thu, 25 Apr 2024 20:28:11 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A5FC84395E; Thu, 25 Apr 2024 20:27:55 +0200 (CEST) Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mails.dpdk.org (Postfix) with ESMTP id A22EE4394A for ; Thu, 25 Apr 2024 20:27:51 +0200 (CEST) Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6ece8991654so1296263b3a.3 for ; Thu, 25 Apr 2024 11:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1714069671; x=1714674471; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4lICNWD6f1kOwiNNkYWwsph11CvhG6Y5VOkX6jzLgqs=; b=ZSyOfuXA4INhieou9uUr2KM027hf7mJjkNd24492Qs9XizGs809RYdrglaMwRQq0hf mGVUZUQlYjOKcFtw8MUTPNJvEpNYzTbqgJkX4mfbLDuLziP55mJVOnXGo/PZxN3L/Rs2 QNUx+NrRvyb1C6K+BOOOttbzMsx/6OT71O+7iM2QWlY9WUSlYuA5OQ6wYKLoIrftRB53 vPLsSZufDSkwsGfF4m/rpFjGgFsdpwZTB5sTzT0VPKT6cs5CLckk8DWJXR7HxIIi5jx3 TNbXqgPHpqlfS7FmZKeogt8y9svHP0RCjLVqRdFhuc9Tj3oYC56kV58Y7b7ZbSH/XoEU auNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714069671; x=1714674471; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4lICNWD6f1kOwiNNkYWwsph11CvhG6Y5VOkX6jzLgqs=; b=qWs/xn4sciLmhm86/mFfXmhnYDv4gyeFg2fBCJur4rnET4y5dBhK7Oi4pqB/6IqQrZ 47F66s+EOmJG5aqEiAU3aUixGNQQpXTUcUaqPUtSKUVfxeI8FDewxJBvFXhdrgro9MZm kPPDlCs5nFlWFk9WG6VSilrqqpoE7k6eo170xviGpcvrwqgurmeGLTwnnb3JeMYLegdc Z4cGa7CchFIS9aJISF+t3nIA031wW91VqiLvrdm+DaTXHgJtBk+7sTddJJHagqaeiEGl lt4tQvpAIfhK0Mrq7qhb0hACwRaNAjju1/IR915apR/lWk+mpBdOhpdcE0O2aVunGW44 1YpA== X-Gm-Message-State: AOJu0YwBOzpPxyk79okwYBEE1iblYovO9IDjmWfgA1ogh9YNuIPDAOjw tJDYj/pskz+DzIWn/BxjQG2T6ZVAdxhHF0fOappsNAP7IC0Mqv/KXIbwmuWvvCkbFMMwaYWVitf S X-Google-Smtp-Source: AGHT+IHt5aAEtBtPlg+ucnYleBU5io9I7MyceFH68UnWKhfNAtHQeyE7nM2tp9A7HhRNK/2IcQqkPQ== X-Received: by 2002:a05:6a20:918e:b0:1aa:92b3:acd0 with SMTP id v14-20020a056a20918e00b001aa92b3acd0mr696849pzd.25.1714069670831; Thu, 25 Apr 2024 11:27:50 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d7-20020a056a00244700b006f0ba1c8ddesm4067006pfj.184.2024.04.25.11.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 11:27:50 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [RFC 3/4] devtools/cocci: add script to find where rte_calloc should be used Date: Thu, 25 Apr 2024 11:24:00 -0700 Message-ID: <20240425182738.4771-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240425182738.4771-1-stephen@networkplumber.org> References: <20240425182738.4771-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Better to use ret_calloc() than directly multiply up the sizes of objects. Signed-off-by: Stephen Hemminger --- devtools/cocci/prefer-calloc.cocci | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 devtools/cocci/prefer-calloc.cocci diff --git a/devtools/cocci/prefer-calloc.cocci b/devtools/cocci/prefer-calloc.cocci new file mode 100644 index 0000000000..77defed9f6 --- /dev/null +++ b/devtools/cocci/prefer-calloc.cocci @@ -0,0 +1,19 @@ +// +// Prefer use of calloc over zmalloc when allocating multiple objects +// +@@ +expression name, T, num, socket, align; +@@ +( +- rte_zmalloc(name, num * sizeof(T), align) ++ rte_calloc(name, num, sizeof(T), align) +| +- rte_zmalloc(name, sizeof(T) * num, align) ++ rte_calloc(name, num, sizeof(T), align) +| +- rte_zmalloc_socket(name, num * sizeof(T), align, socket) ++ rte_calloc_socket(name, num, sizeof(T), align, socket) +| +- rte_zmalloc_socket(name, sizeof(T) * num, align, socket) ++ rte_calloc_socket(name, num, sizeof(T), align, socket) +) -- 2.43.0