lsqeth: Use util_readlink() for consistent error handling

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 <hoeppner@linux.ibm.com>
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Jan Polensky
2025-10-15 16:35:18 +02:00
committed by Jan Höppner
parent e7203069cc
commit dd818ccc15

View File

@@ -20,7 +20,6 @@
#include <unistd.h>
#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;
}