From: Thomas Haller <thaller@redhat.com>
To: NetFilter <netfilter-devel@vger.kernel.org>
Cc: Thomas Haller <thaller@redhat.com>
Subject: [PATCH nft 1/4] datatype: don't return a const string from cgroupv2_get_path()
Date: Wed, 20 Sep 2023 15:13:38 +0200 [thread overview]
Message-ID: <20230920131554.204899-2-thaller@redhat.com> (raw)
In-Reply-To: <20230920131554.204899-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 70c84846f70e..8015f3869ece 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -1464,10 +1464,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;
@@ -1505,7 +1505,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
next prev parent reply other threads:[~2023-09-20 13:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 13:13 [PATCH nft 0/4] remove xfree() and add free_const()+nft_gmp_free() Thomas Haller
2023-09-20 13:13 ` Thomas Haller [this message]
2023-09-20 13:13 ` [PATCH nft 2/4] gmputil: add nft_gmp_free() to free strings from mpz_get_str() Thomas Haller
2023-09-20 14:05 ` Phil Sutter
2023-09-20 14:46 ` Thomas Haller
2023-09-20 16:04 ` Phil Sutter
2023-09-20 13:13 ` [PATCH nft 3/4] all: add free_const() and use it instead of xfree() Thomas Haller
2023-09-20 14:13 ` Phil Sutter
2023-09-20 16:06 ` Pablo Neira Ayuso
2023-09-20 16:49 ` Phil Sutter
2023-09-20 16:52 ` Pablo Neira Ayuso
2023-09-20 18:03 ` Thomas Haller
2023-09-20 18:22 ` Phil Sutter
2023-09-20 19:48 ` Thomas Haller
2023-09-20 22:50 ` Phil Sutter
2023-09-21 9:08 ` Thomas Haller
2023-09-20 13:13 ` [PATCH nft 4/4] all: remove xfree() and use plain free() 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=20230920131554.204899-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).