netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Haller <thaller@redhat.com>
To: NetFilter <netfilter-devel@vger.kernel.org>
Cc: Thomas Haller <thaller@redhat.com>
Subject: [PATCH nft v2 1/4] datatype: don't return a const string from cgroupv2_get_path()
Date: Tue, 24 Oct 2023 11:57:07 +0200	[thread overview]
Message-ID: <20231024095820.1068949-2-thaller@redhat.com> (raw)
In-Reply-To: <20231024095820.1068949-1-thaller@redhat.com>

The caller is supposed to free the allocated string. Return a non-const
string to make that clearer.

Signed-off-by: Thomas Haller <thaller@redhat.com>
---
 src/datatype.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/datatype.c b/src/datatype.c
index 64e4647a605f..6362735809f7 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -1465,10 +1465,10 @@ const struct datatype policy_type = {
 
 #define SYSFS_CGROUPSV2_PATH	"/sys/fs/cgroup"
 
-static const char *cgroupv2_get_path(const char *path, uint64_t id)
+static char *cgroupv2_get_path(const char *path, uint64_t id)
 {
-	const char *cgroup_path = NULL;
 	char dent_name[PATH_MAX + 1];
+	char *cgroup_path = NULL;
 	struct dirent *dent;
 	struct stat st;
 	DIR *d;
@@ -1506,7 +1506,7 @@ static void cgroupv2_type_print(const struct expr *expr,
 				struct output_ctx *octx)
 {
 	uint64_t id = mpz_get_uint64(expr->value);
-	const char *cgroup_path;
+	char *cgroup_path;
 
 	cgroup_path = cgroupv2_get_path(SYSFS_CGROUPSV2_PATH, id);
 	if (cgroup_path)
-- 
2.41.0


  reply	other threads:[~2023-10-24 10:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-24  9:57 [PATCH nft v2 0/4] [RESENT] remove xfree() and add free_const()+nft_gmp_free() Thomas Haller
2023-10-24  9:57 ` Thomas Haller [this message]
2023-10-24  9:57 ` [PATCH nft v2 2/4] gmputil: add nft_gmp_free() to free strings from mpz_get_str() Thomas Haller
2023-10-24  9:57 ` [PATCH nft v2 3/4] all: add free_const() and use it instead of xfree() Thomas Haller
2023-10-24  9:57 ` [PATCH nft v2 4/4] all: remove xfree() and use plain free() Thomas Haller
2023-11-06 13:35 ` [PATCH nft v2 0/4] [RESENT] remove xfree() and add free_const()+nft_gmp_free() Pablo Neira Ayuso
2023-11-09 16:05 ` Pablo Neira Ayuso
2023-11-09 17:14   ` Thomas Haller
2023-11-09 19:15     ` Pablo Neira Ayuso
2023-11-09 20:02       ` Thomas Haller

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=20231024095820.1068949-2-thaller@redhat.com \
    --to=thaller@redhat.com \
    --cc=netfilter-devel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).