diff mbox series

[2/2] mcstrans: make use of context_to_str(3)

Message ID 20250226094409.41452-1-cgoettsche@seltendoof.de (mailing list archive)
State New
Delegated to: Petr Lautrbach
Headers show
Series [1/2] libselinux: introduce context_to_str(3) | expand

Commit Message

Christian Göttsche Feb. 26, 2025, 9:44 a.m. UTC
From: Christian Göttsche <cgzones@googlemail.com>

Avoid unnecessary allocations.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 mcstrans/src/mcscolor.c | 2 +-
 mcstrans/src/mcstrans.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/mcstrans/src/mcscolor.c b/mcstrans/src/mcscolor.c
index 9ff0ce2f..ef3752a0 100644
--- a/mcstrans/src/mcscolor.c
+++ b/mcstrans/src/mcscolor.c
@@ -101,7 +101,7 @@  static int check_dominance(const char *pattern, const char *raw) {
 	ctx = NULL;
 	if (context_range_set(my_tmp, pattern))
 		goto out;
-	ctx = strdup(context_str(my_tmp));
+	ctx = context_to_str(my_tmp);
 	if (!ctx)
 		goto out;
 
diff --git a/mcstrans/src/mcstrans.c b/mcstrans/src/mcstrans.c
index 7667e131..f18f9da9 100644
--- a/mcstrans/src/mcstrans.c
+++ b/mcstrans/src/mcstrans.c
@@ -925,7 +925,7 @@  new_context_str(const char *incon, const char *range) {
 		goto exit;
 	}
 	context_range_set(con, range);
-	rcon = strdup(context_str(con));
+	rcon = context_to_str(con);
 	context_free(con);
 	if (!rcon) {
 		goto exit;