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 5C12646114; Sat, 25 Jan 2025 19:41:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0B99D40656; Sat, 25 Jan 2025 19:40:33 +0100 (CET) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mails.dpdk.org (Postfix) with ESMTP id A027940430 for ; Sat, 25 Jan 2025 19:40:26 +0100 (CET) Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-2ee86a1a92dso4528168a91.1 for ; Sat, 25 Jan 2025 10:40:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737830426; x=1738435226; 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=eUkfFxUp0mnwBzVkcPamGMI/9Vqc3APc0qqtuVbVrvA=; b=P7Ugey5zJcEfipZ+6cGda/H9wEnSmKTQohzSdASv1qSHo4YvaYWhFkGAGy53w288UN Y+Jg4r68FrSHFZAMvTlqlzNx3UJdVYVFWP/kx5FKacZxd1zzsQLwC+sMs/MOJAc7Dvog 6J3Q8zveTKitl8+DOBFFMCeE5C9MWndPbEG3MoLOuDOsB4TxFz0Aq3IF+dfgYAVzvzZp ha7P0IsrXROpS0KDtpy0A3l4DNhg4rMXr/4wyGixcsa/5xEhkeidnWdhFLBwo42weHj5 JjqqGWQ41i4cxGWZZLYNoss7ynyIzGEKDxtmdN5LkRuZManMEzkb4e8HzvsCwka1odZE an/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737830426; x=1738435226; 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=eUkfFxUp0mnwBzVkcPamGMI/9Vqc3APc0qqtuVbVrvA=; b=X4X1uLB5yTrVRsh+g8WBL4FPzeAYVZMnvr+LdnlXn3f4Hdx/gQ8cLZP6WpBVaSQNZv h5QyZl/NpvLwH4+BxTG4jBQ9CpANIWFFs6bMtejyelsNpBaO6B/PJQNxON1ki/FKG+eG 8qemnI4oRRcAj6ckMdI7cXCYdMPzN4LvJwJ5UyRG3OgEJApB0UmdO9l5bgakpAK/EIx+ bjav9Qay92ZOW5mD7tg6G8mpEm64pSZBHjnS/mRFW9Edl16IzeZ+R6KvBifsdsztc7gF itzBO5E+dUu/PUyrfUUiT609OSqK0iJr273A4jNmPvYEggk/aU5a39FWMcRP6KeQPHAp 26cw== X-Gm-Message-State: AOJu0Yys9XF2XSZIKQoevdSLy3eOOVQNkHdmq9SwuDGAJzLd6YbpOf77 +YkObQVUyFtwtfEADMXcnnCrR4w9wuaBcw2LDk5Emi1HQqmocidjFgG/O9TA+ouoQ3lJPNJSYFP M X-Gm-Gg: ASbGnctFJa5PFYCnnJBx4kSV43TAY3r3QouYD18E7Z0NA7fB4i7o2jf3qQaPaQF02sD QrWpCPGNZFQffKuNmi+nbOvTElKopqueTlFNcbUsbMTt04WNYqT61AU20bxzl+iseG/cpTFMoSy szVH42E+0k6ETrjBlmwVi3isrLMZybx7fnLBnmk9/19c3jyOd3Bs27WIl1U/R26wtI55Pzscvb4 p5mRZMHBzzvqMXV3NAvQZjZHbHVntrQnvB2CogtRYWifIbUYTifr3VOfvixWrozrlBsnT6QwSjy nXW83EOSbVVFbSuKvo2Jmb9Whia3S8iaNB27lbP3WsDIbqH/BugouLzycA== X-Google-Smtp-Source: AGHT+IEPOvQk6DiOM4V5q2kKyuUEv2mXQt/SYGa5Yax8e6w99YPP1DOebXLcD7Y0cBp5K8AC1oQHsA== X-Received: by 2002:a05:6a00:ad8a:b0:72d:8fa2:99ac with SMTP id d2e1a72fcca58-72daf975d73mr49795777b3a.13.1737830425885; Sat, 25 Jan 2025 10:40:25 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72f8a7614f4sm4100547b3a.97.2025.01.25.10.40.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jan 2025 10:40:25 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v6 06/15] bitratestats: add allocation function attributes Date: Sat, 25 Jan 2025 10:36:40 -0800 Message-ID: <20250125184010.782330-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250125184010.782330-1-stephen@networkplumber.org> References: <20250120180550.198121-1-stephen@networkplumber.org> <20250125184010.782330-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 Use function attributes to catch cases where bitratestats is allocated but not freed correctly. Signed-off-by: Stephen Hemminger --- lib/bitratestats/rte_bitrate.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/bitratestats/rte_bitrate.h b/lib/bitratestats/rte_bitrate.h index 979a712837..75883f8779 100644 --- a/lib/bitratestats/rte_bitrate.h +++ b/lib/bitratestats/rte_bitrate.h @@ -7,6 +7,8 @@ #include +#include + #ifdef __cplusplus extern "C" { #endif @@ -17,16 +19,6 @@ extern "C" { */ struct rte_stats_bitrates; - -/** - * Allocate a bitrate statistics structure - * - * @return - * - Pointer to structure on success - * - NULL on error (zmalloc failure) - */ -struct rte_stats_bitrates *rte_stats_bitrate_create(void); - /** * Free bitrate statistics structure * @@ -36,6 +28,16 @@ struct rte_stats_bitrates *rte_stats_bitrate_create(void); */ void rte_stats_bitrate_free(struct rte_stats_bitrates *bitrate_data); +/** + * Allocate a bitrate statistics structure + * + * @return + * - Pointer to structure on success + * - NULL on error (zmalloc failure) + */ +struct rte_stats_bitrates *rte_stats_bitrate_create(void) + __rte_malloc __rte_dealloc(rte_stats_bitrate_free, 1); + /** * Register bitrate statistics with the metric library. * -- 2.45.2