mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
dasdinfo: 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
6da56acf4b
commit
9c60ceccd4
+6
-9
@@ -386,10 +386,8 @@ static int
|
|||||||
dinfo_is_busiddir(const char *fpath, const struct stat *UNUSED(sb),
|
dinfo_is_busiddir(const char *fpath, const struct stat *UNUSED(sb),
|
||||||
int tflag, struct FTW *ftwbuf)
|
int tflag, struct FTW *ftwbuf)
|
||||||
{
|
{
|
||||||
enum { LINK_DIR_SIZE = 128 };
|
|
||||||
char linkdir[LINK_DIR_SIZE];
|
|
||||||
char *tempdir;
|
char *tempdir;
|
||||||
ssize_t i;
|
char *linkdir;
|
||||||
|
|
||||||
if (tflag != FTW_D || (strncmp((fpath + ftwbuf->base), searchbusid,
|
if (tflag != FTW_D || (strncmp((fpath + ftwbuf->base), searchbusid,
|
||||||
strlen(searchbusid)) != 0))
|
strlen(searchbusid)) != 0))
|
||||||
@@ -401,14 +399,13 @@ dinfo_is_busiddir(const char *fpath, const struct stat *UNUSED(sb),
|
|||||||
*/
|
*/
|
||||||
if (asprintf(&tempdir, "%s/driver", fpath) < 0)
|
if (asprintf(&tempdir, "%s/driver", fpath) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
i = readlink(tempdir, linkdir, LINK_DIR_SIZE);
|
linkdir = util_readlink(tempdir);
|
||||||
free(tempdir);
|
free(tempdir);
|
||||||
if (i < 0 || i >= LINK_DIR_SIZE)
|
if (strstr(linkdir, "dasd") == NULL) {
|
||||||
return -1;
|
free(linkdir);
|
||||||
/* append '\0' because readlink returns non zero terminated string */
|
|
||||||
linkdir[i] = '\0';
|
|
||||||
if (strstr(linkdir, "dasd") == NULL)
|
|
||||||
return FTW_CONTINUE;
|
return FTW_CONTINUE;
|
||||||
|
}
|
||||||
|
free(linkdir);
|
||||||
free(busiddir);
|
free(busiddir);
|
||||||
busiddir = strdup(fpath);
|
busiddir = strdup(fpath);
|
||||||
if (busiddir == NULL)
|
if (busiddir == NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user