mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
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:
committed by
Jan Höppner
parent
e7203069cc
commit
dd818ccc15
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user