diff mbox series

[nft,1/4] datatype: don't return a const string from cgroupv2_get_path()

Message ID 20230920131554.204899-2-thaller@redhat.com
State Changes Requested
Headers show
Series remove xfree() and add free_const()+nft_gmp_free() | expand

Commit Message

Thomas Haller Sept. 20, 2023, 1:13 p.m. UTC
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 mbox series

Patch

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)