mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zconf/lscss: 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
9c60ceccd4
commit
d4ee1ff01f
@@ -20,7 +20,6 @@
|
||||
#include "lib/util_prg.h"
|
||||
#include "lib/util_rec.h"
|
||||
#include "lib/util_scandir.h"
|
||||
#include "lib/util_panic.h"
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
@@ -376,20 +375,17 @@ static int fill_device_info(struct util_rec *rec, char *path, char *device)
|
||||
|
||||
static bool is_sch_vfio(char *path)
|
||||
{
|
||||
char lnk[PATH_MAX], driver_path[PATH_MAX];
|
||||
ssize_t rc;
|
||||
char lnk[PATH_MAX];
|
||||
char *driver_path;
|
||||
|
||||
snprintf(lnk, PATH_MAX, "%s/driver", path);
|
||||
rc = readlink(lnk, driver_path, PATH_MAX);
|
||||
if (rc < 0)
|
||||
return false;
|
||||
driver_path = util_readlink(lnk);
|
||||
|
||||
util_assert(rc < (PATH_MAX - 1),
|
||||
"Internal error: Symlink name too long");
|
||||
driver_path[rc] = '\0';
|
||||
|
||||
if (strcmp(basename(driver_path), "vfio_ccw") == 0)
|
||||
if (strcmp(basename(driver_path), "vfio_ccw") == 0) {
|
||||
free(driver_path);
|
||||
return true;
|
||||
}
|
||||
free(driver_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user