summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mptutil/mpt_cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/mptutil/mpt_cmd.c')
-rw-r--r--usr.sbin/mptutil/mpt_cmd.c50
1 files changed, 20 insertions, 30 deletions
diff --git a/usr.sbin/mptutil/mpt_cmd.c b/usr.sbin/mptutil/mpt_cmd.c
index 2d6000c..8104fc9 100644
--- a/usr.sbin/mptutil/mpt_cmd.c
+++ b/usr.sbin/mptutil/mpt_cmd.c
@@ -310,18 +310,15 @@ mpt_lookup_volume(int fd, const char *name, U8 *VolumeBus, U8 *VolumeID)
id = strtol(cp + 1, &cp, 0);
if (*cp == '\0') {
if (bus < 0 || bus > 0xff || id < 0 || id > 0xff) {
- errno = EINVAL;
- return (-1);
+ return (EINVAL);
}
*VolumeBus = bus;
*VolumeID = id;
return (0);
}
} else if (*cp == '\0') {
- if (bus < 0 || bus > 0xff) {
- errno = EINVAL;
- return (-1);
- }
+ if (bus < 0 || bus > 0xff)
+ return (EINVAL);
*VolumeBus = 0;
*VolumeID = bus;
return (0);
@@ -329,7 +326,7 @@ mpt_lookup_volume(int fd, const char *name, U8 *VolumeBus, U8 *VolumeID)
ioc2 = mpt_read_ioc_page(fd, 2, NULL);
if (ioc2 == NULL)
- return (-1);
+ return (errno);
vol = ioc2->RaidVolume;
for (i = 0; i < ioc2->NumActiveVolumes; vol++, i++) {
@@ -343,8 +340,7 @@ mpt_lookup_volume(int fd, const char *name, U8 *VolumeBus, U8 *VolumeID)
}
}
free(ioc2);
- errno = EINVAL;
- return (-1);
+ return (EINVAL);
}
int
@@ -360,15 +356,14 @@ mpt_read_config_page_header(int fd, U8 PageType, U8 PageNumber, U32 PageAddress,
req.header.PageNumber = PageNumber;
req.page_address = PageAddress;
if (ioctl(fd, MPTIO_READ_CFG_HEADER, &req) < 0)
- return (-1);
+ return (errno);
if (!IOC_STATUS_SUCCESS(req.ioc_status)) {
if (IOCStatus != NULL)
*IOCStatus = req.ioc_status;
else
warnx("Reading config page header failed: %s",
mpt_ioc_status(req.ioc_status));
- errno = EIO;
- return (-1);
+ return (EIO);
}
*header = req.header;
return (0);
@@ -380,7 +375,7 @@ mpt_read_config_page(int fd, U8 PageType, U8 PageNumber, U32 PageAddress,
{
struct mpt_cfg_page_req req;
void *buf;
- int save_errno;
+ int error;
if (IOCStatus != NULL)
*IOCStatus = MPI_IOCSTATUS_SUCCESS;
@@ -404,9 +399,9 @@ mpt_read_config_page(int fd, U8 PageType, U8 PageNumber, U32 PageAddress,
req.buf = buf;
bcopy(&req.header, buf, sizeof(req.header));
if (ioctl(fd, MPTIO_READ_CFG_PAGE, &req) < 0) {
- save_errno = errno;
+ error = errno;
free(buf);
- errno = save_errno;
+ errno = error;
return (NULL);
}
if (!IOC_STATUS_SUCCESS(req.ioc_status)) {
@@ -428,7 +423,7 @@ mpt_read_extended_config_page(int fd, U8 ExtPageType, U8 PageVersion,
{
struct mpt_ext_cfg_page_req req;
void *buf;
- int save_errno;
+ int error;
if (IOCStatus != NULL)
*IOCStatus = MPI_IOCSTATUS_SUCCESS;
@@ -453,9 +448,9 @@ mpt_read_extended_config_page(int fd, U8 ExtPageType, U8 PageVersion,
req.buf = buf;
bcopy(&req.header, buf, sizeof(req.header));
if (ioctl(fd, MPTIO_READ_EXT_CFG_PAGE, &req) < 0) {
- save_errno = errno;
+ error = errno;
free(buf);
- errno = save_errno;
+ errno = error;
return (NULL);
}
if (!IOC_STATUS_SUCCESS(req.ioc_status)) {
@@ -484,7 +479,7 @@ mpt_write_config_page(int fd, void *buf, U16 *IOCStatus)
hdr = buf;
req.len = hdr->PageLength * 4;
if (ioctl(fd, MPTIO_WRITE_CFG_PAGE, &req) < 0)
- return (-1);
+ return (errno);
if (!IOC_STATUS_SUCCESS(req.ioc_status)) {
if (IOCStatus != NULL) {
*IOCStatus = req.ioc_status;
@@ -492,8 +487,7 @@ mpt_write_config_page(int fd, void *buf, U16 *IOCStatus)
}
warnx("Writing config page failed: %s",
mpt_ioc_status(req.ioc_status));
- errno = EIO;
- return (-1);
+ return (EIO);
}
return (0);
}
@@ -507,10 +501,8 @@ mpt_raid_action(int fd, U8 Action, U8 VolumeBus, U8 VolumeID, U8 PhysDiskNum,
if (IOCStatus != NULL)
*IOCStatus = MPI_IOCSTATUS_SUCCESS;
- if (datalen < 0 || (unsigned)datalen > sizeof(raid_act.action_data)) {
- errno = EINVAL;
- return (-1);
- }
+ if (datalen < 0 || (unsigned)datalen > sizeof(raid_act.action_data))
+ return (EINVAL);
bzero(&raid_act, sizeof(raid_act));
raid_act.action = Action;
raid_act.volume_bus = VolumeBus;
@@ -524,7 +516,7 @@ mpt_raid_action(int fd, U8 Action, U8 VolumeBus, U8 VolumeID, U8 PhysDiskNum,
}
if (ioctl(fd, MPTIO_RAID_ACTION, &raid_act) < 0)
- return (-1);
+ return (errno);
if (!IOC_STATUS_SUCCESS(raid_act.ioc_status)) {
if (IOCStatus != NULL) {
@@ -533,8 +525,7 @@ mpt_raid_action(int fd, U8 Action, U8 VolumeBus, U8 VolumeID, U8 PhysDiskNum,
}
warnx("RAID action failed: %s",
mpt_ioc_status(raid_act.ioc_status));
- errno = EIO;
- return (-1);
+ return (EIO);
}
if (ActionStatus != NULL)
@@ -544,8 +535,7 @@ mpt_raid_action(int fd, U8 Action, U8 VolumeBus, U8 VolumeID, U8 PhysDiskNum,
return (0);
warnx("RAID action failed: %s",
mpt_raid_status(raid_act.action_status));
- errno = EIO;
- return (-1);
+ return (EIO);
}
if (VolumeStatus != NULL)
OpenPOWER on IntegriCloud