mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zdev: 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
dd818ccc15
commit
8ad28f7856
@@ -14,6 +14,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/util_path.h"
|
||||
|
||||
#include "attrib.h"
|
||||
@@ -533,7 +534,7 @@ char *ccw_get_driver(struct ccw_devid *devid)
|
||||
id = ccw_devid_to_str(devid);
|
||||
path = path_get_ccw_device(NULL, id);
|
||||
driver_path = misc_asprintf("%s/driver", path);
|
||||
link = misc_readlink(driver_path);
|
||||
link = util_readlink(driver_path);
|
||||
if (link)
|
||||
drv = misc_strdup(basename(link));
|
||||
free(link);
|
||||
@@ -552,7 +553,7 @@ static char *ccw_get_module(struct ccw_devid *devid)
|
||||
id = ccw_devid_to_str(devid);
|
||||
path = path_get_ccw_device(NULL, id);
|
||||
driver_path = misc_asprintf("%s/driver/module", path);
|
||||
link = misc_readlink(driver_path);
|
||||
link = util_readlink(driver_path);
|
||||
if (link)
|
||||
module = misc_strdup(basename(link));
|
||||
free(link);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/util_path.h"
|
||||
|
||||
#include "attrib.h"
|
||||
@@ -574,7 +575,7 @@ static bool read_full_id(struct ccwgroup_devid *devid_ptr, const char *drv,
|
||||
for (i = 0; i < CCWGROUP_MAX_DEVIDS; i++) {
|
||||
/* Read cdev<n> link target. */
|
||||
link_path = misc_asprintf("%s/cdev%u", path, i);
|
||||
link = misc_readlink(link_path);
|
||||
link = util_readlink(link_path);
|
||||
free(link_path);
|
||||
if (!link) {
|
||||
result = false;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/util_path.h"
|
||||
|
||||
#include "attrib.h"
|
||||
@@ -464,7 +465,7 @@ char *device_read_active_attrib(struct device *dev, const char *name)
|
||||
value = misc_read_text_file(path, 1, err_ignore);
|
||||
if (!value) {
|
||||
/* Symbolic links count as read-only attributes. */
|
||||
link = misc_readlink(path);
|
||||
link = util_readlink(path);
|
||||
if (link) {
|
||||
value = misc_strdup(basename(link));
|
||||
free(link);
|
||||
@@ -560,7 +561,7 @@ void device_read_active_settings(struct device *dev, read_scope_t scope)
|
||||
goto next;
|
||||
|
||||
/* Register symbolic links as readonly attributes. */
|
||||
link = misc_readlink(path);
|
||||
link = util_readlink(path);
|
||||
if (!link)
|
||||
goto next;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <sys/sysmacros.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/util_path.h"
|
||||
|
||||
#include "devnode.h"
|
||||
@@ -155,7 +156,7 @@ static struct devnode *devnode_from_majmin(devnode_t type, unsigned int major,
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
link = misc_readlink(path);
|
||||
link = util_readlink(path);
|
||||
if (!link)
|
||||
goto out;
|
||||
|
||||
@@ -359,7 +360,7 @@ char *devnode_readlink(struct devnode *devnode)
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
link = misc_readlink(path);
|
||||
link = util_readlink(path);
|
||||
free(path);
|
||||
|
||||
return link;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <libgen.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/util_path.h"
|
||||
|
||||
#include "attrib.h"
|
||||
@@ -133,7 +134,7 @@ static exit_code_t add_cb(const char *abs_path, const char *rel_path,
|
||||
unsigned int i, major, minor;
|
||||
struct devnode *devnode;
|
||||
|
||||
link = misc_readlink(abs_path);
|
||||
link = util_readlink(abs_path);
|
||||
if (!link)
|
||||
return EXIT_OK;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/util_path.h"
|
||||
|
||||
#include "misc.h"
|
||||
@@ -209,7 +210,7 @@ char *scsi_hctl_to_zfcp_lun_id(const char *hctl)
|
||||
char *buspath, *link = NULL, *zfcp_lun_id = NULL;
|
||||
|
||||
buspath = path_get_sys_bus_dev("scsi", hctl);
|
||||
link = misc_readlink(buspath);
|
||||
link = util_readlink(buspath);
|
||||
if (!link)
|
||||
goto out;
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/util_path.h"
|
||||
|
||||
#include "attrib.h"
|
||||
@@ -1077,7 +1078,7 @@ static char *zfcp_lun_st_resolve_devnode(struct subtype *st,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
link = misc_readlink(path);
|
||||
link = util_readlink(path);
|
||||
if (!link)
|
||||
goto out;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user