From dd818ccc15594ff94b0202873bc20dc4bf62f323 Mon Sep 17 00:00:00 2001 From: Jan Polensky Date: Wed, 15 Oct 2025 16:35:18 +0200 Subject: [PATCH] lsqeth: Use util_readlink() for consistent error handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid code duplication and inconsistent error handling by replacing readlink() with util_readlink(), which is used project-wide to standardize readlink() usage. Reviewed-by: Jan Höppner Signed-off-by: Jan Polensky Signed-off-by: Jan Höppner --- zconf/qeth/misc.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/zconf/qeth/misc.c b/zconf/qeth/misc.c index 984e179f..ee3b40e1 100644 --- a/zconf/qeth/misc.c +++ b/zconf/qeth/misc.c @@ -20,7 +20,6 @@ #include #include "lib/util_libc.h" -#include "lib/util_panic.h" #include "misc.h" @@ -59,20 +58,14 @@ char *misc_link_target(const char *fmt, ...) { char *lnk, *path; va_list ap; - ssize_t rc; - path = util_malloc(PATH_MAX); /* Construct the file name */ UTIL_VASPRINTF(&lnk, fmt, ap); - rc = readlink(lnk, path, PATH_MAX); + path = util_readlink(lnk); free(lnk); - if (rc < 0) { - free(path); + if (!path) return NULL; - } - util_assert(rc < (PATH_MAX - 1), - "Internal error: Symlink name too long"); - path[rc] = '\0'; + return path; }