summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Johnston <rob.johnston@joyent.com>2019-10-23 01:02:17 -0700
committerRobert Mustacchi <rm@fingolfin.org>2019-10-29 23:39:28 +0000
commit00f453f4ebc211cb928f19a54d3f4edd61f43279 (patch)
tree97e12e66fea37516c781020b3feaf5a99b05dd2f
parent744b124e8caed130fec6baedb0c53d1b6de03e41 (diff)
downloadillumos-joyent-00f453f4ebc211cb928f19a54d3f4edd61f43279.tar.gz
11862 cleanup smatch/cstyle/wscheck issues in usr/src/lib/sun_sas/
Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk> Reviewed by: Andy Stormont <astormont@racktopsystems.com> Reviewed by: Igor Kozhukhov <igor@dilos.org> Reviewed by: Kody Kantor <kody.kantor@joyent.com> Approved by: Robert Mustacchi <rm@fingolfin.org>
-rw-r--r--usr/src/lib/sun_sas/Makefile.com56
-rw-r--r--usr/src/lib/sun_sas/common/Sun_sasFreeLibrary.c84
-rw-r--r--usr/src/lib/sun_sas/common/Sun_sasGetAdapterAttributes.c23
-rw-r--r--usr/src/lib/sun_sas/common/Sun_sasGetAdapterName.c41
-rw-r--r--usr/src/lib/sun_sas/common/Sun_sasGetAdapterPortAttributes.c37
-rw-r--r--usr/src/lib/sun_sas/common/Sun_sasGetDiscoveredPortAttributes.c88
-rw-r--r--usr/src/lib/sun_sas/common/Sun_sasGetNumberOfAdapters.c12
-rw-r--r--usr/src/lib/sun_sas/common/Sun_sasGetPhyStatistics.c14
-rw-r--r--usr/src/lib/sun_sas/common/Sun_sasGetPortAttributesByWWN.c7
-rw-r--r--usr/src/lib/sun_sas/common/Sun_sasGetPortType.c12
-rw-r--r--usr/src/lib/sun_sas/common/Sun_sasOpenAdapter.c5
-rw-r--r--usr/src/lib/sun_sas/common/Sun_sasRefreshAdapterConfiguration.c5
-rw-r--r--usr/src/lib/sun_sas/common/Sun_sasScsiInquiry.c13
-rw-r--r--usr/src/lib/sun_sas/common/Sun_sasSendSMPPassThru.c16
-rw-r--r--usr/src/lib/sun_sas/common/devlink_disco.c5
-rw-r--r--usr/src/lib/sun_sas/common/devtree_device_disco.c29
-rw-r--r--usr/src/lib/sun_sas/common/devtree_hba_disco.c9
-rw-r--r--usr/src/lib/sun_sas/common/event.c11
-rw-r--r--usr/src/lib/sun_sas/common/sun_sas.c12
19 files changed, 265 insertions, 214 deletions
diff --git a/usr/src/lib/sun_sas/Makefile.com b/usr/src/lib/sun_sas/Makefile.com
index a4c1ea4b0b..853108091f 100644
--- a/usr/src/lib/sun_sas/Makefile.com
+++ b/usr/src/lib/sun_sas/Makefile.com
@@ -22,47 +22,47 @@
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# Copyright (c) 2018, Joyent, Inc.
+# Copyright 2019 Joyent, Inc.
LIBRARY = libsun_sas.a
VERS = .1
OBJECTS = devtree_hba_disco.o \
- devtree_device_disco.o \
- devtree_phy_disco.o \
- devlink_disco.o \
- event.o \
- verify.o \
- SMHBA_RegisterLibrary.o \
- Sun_sasLoadLibrary.o \
- Sun_sasGetNumberOfAdapters.o \
- Sun_sasGetTargetMapping.o \
- Sun_sasGetAdapterName.o \
+ devtree_device_disco.o \
+ devtree_phy_disco.o \
+ devlink_disco.o \
+ event.o \
+ verify.o \
+ SMHBA_RegisterLibrary.o \
+ Sun_sasLoadLibrary.o \
+ Sun_sasGetNumberOfAdapters.o \
+ Sun_sasGetTargetMapping.o \
+ Sun_sasGetAdapterName.o \
Sun_sasGetAdapterAttributes.o \
Sun_sasGetAdapterPortAttributes.o \
Sun_sasGetDiscoveredPortAttributes.o \
Sun_sasGetPortAttributesByWWN.o \
Sun_sasGetSASPhyAttributes.o \
Sun_sasGetPortType.o \
- Sun_sasGetNumberOfPorts.o \
- Sun_sasGetVersion.o \
- Sun_sasGetPhyStatistics.o \
- Sun_sasGetVendorLibraryAttributes.o \
- Sun_sasFreeLibrary.o \
- Sun_sasOpenAdapter.o \
- Sun_sasCloseAdapter.o \
- Sun_sasRefreshInformation.o \
- Sun_sasRefreshAdapterConfiguration.o \
- Sun_sasGetLUNStatistics.o \
- Sun_sasGetProtocolStatistics.o \
- Sun_sasGetPersistentBinding.o \
- Sun_sasSetPersistentBinding.o \
+ Sun_sasGetNumberOfPorts.o \
+ Sun_sasGetVersion.o \
+ Sun_sasGetPhyStatistics.o \
+ Sun_sasGetVendorLibraryAttributes.o \
+ Sun_sasFreeLibrary.o \
+ Sun_sasOpenAdapter.o \
+ Sun_sasCloseAdapter.o \
+ Sun_sasRefreshInformation.o \
+ Sun_sasRefreshAdapterConfiguration.o \
+ Sun_sasGetLUNStatistics.o \
+ Sun_sasGetProtocolStatistics.o \
+ Sun_sasGetPersistentBinding.o \
+ Sun_sasSetPersistentBinding.o \
Sun_sasSendSMPPassThru.o \
Sun_sasScsiInquiry.o \
Sun_sasScsiReportLUNs.o \
Sun_sasScsiReadCapacity.o \
sun_sas.o \
- log.o
+ log.o
include ../../Makefile.lib
@@ -81,12 +81,6 @@ CFLAGS64 += $(CCVERBOSE)
CPPFLAGS += $(INCS) -D_POSIX_PTHREAD_SEMANTICS
CPPFLAGS += -DBUILD_TIME='"Wed Feb 4 12:00:00 2009"'
-CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-unused-value
-
-# not linted
-SMATCH=off
-
LDLIBS += -ldevinfo
LDLIBS += -lsysevent
LDLIBS += -lnvpair
diff --git a/usr/src/lib/sun_sas/common/Sun_sasFreeLibrary.c b/usr/src/lib/sun_sas/common/Sun_sasFreeLibrary.c
index caffe52de1..b30e975fe1 100644
--- a/usr/src/lib/sun_sas/common/Sun_sasFreeLibrary.c
+++ b/usr/src/lib/sun_sas/common/Sun_sasFreeLibrary.c
@@ -23,7 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sun_sas.h>
@@ -31,8 +33,10 @@
* Frees the HBA Library. Must be called after all HBA library functions
* to free all resources
*/
-HBA_STATUS Sun_sasFreeLibrary() {
- HBA_STATUS status;
+HBA_STATUS
+Sun_sasFreeLibrary(void)
+{
+ HBA_STATUS status;
lock(&all_hbas_lock);
@@ -58,7 +62,9 @@ HBA_STATUS Sun_sasFreeLibrary() {
/*
* Internal routine to free up hba_ptr's (and all sub-structures)
*/
-HBA_STATUS FreeHBA(struct sun_sas_hba *hba) {
+HBA_STATUS
+FreeHBA(struct sun_sas_hba *hba)
+{
struct sun_sas_hba *hba_ptr = NULL;
struct sun_sas_hba *last_hba_ptr = NULL;
struct sun_sas_port *hba_port = NULL;
@@ -74,57 +80,55 @@ HBA_STATUS FreeHBA(struct sun_sas_hba *hba) {
last_hba_ptr = NULL;
/* walk through global_hba_head list freeing each handle */
- for (hba_ptr = hba;
- hba_ptr != NULL;
- hba_ptr = hba_ptr->next) {
+ for (hba_ptr = hba; hba_ptr != NULL; hba_ptr = hba_ptr->next) {
/* Free the nested structures (port and attached port) */
hba_port = hba_ptr->first_port;
while (hba_port != NULL) {
- /* Free discovered port structure list. */
- tgt_port = hba_port->first_attached_port;
- while (tgt_port != NULL) {
- /* Free target mapping data list first. */
- scsi_info = tgt_port->scsiInfo;
- while (scsi_info != NULL) {
- last_scsi_info = scsi_info;
- scsi_info = scsi_info->next;
- free(last_scsi_info);
- }
- last_tgt_port = tgt_port;
- tgt_port = tgt_port->next;
- free(last_tgt_port->port_attributes.\
+ /* Free discovered port structure list. */
+ tgt_port = hba_port->first_attached_port;
+ while (tgt_port != NULL) {
+ /* Free target mapping data list first. */
+ scsi_info = tgt_port->scsiInfo;
+ while (scsi_info != NULL) {
+ last_scsi_info = scsi_info;
+ scsi_info = scsi_info->next;
+ free(last_scsi_info);
+ }
+ last_tgt_port = tgt_port;
+ tgt_port = tgt_port->next;
+ free(last_tgt_port->port_attributes.\
+ PortSpecificAttribute.SASPort);
+ free(last_tgt_port);
+ }
+
+ phy_ptr = hba_port->first_phy;
+ while (phy_ptr != NULL) {
+ last_phy = phy_ptr;
+ phy_ptr = phy_ptr->next;
+ free(last_phy);
+ }
+
+ last_hba_port = hba_port;
+ hba_port = hba_port->next;
+ free(last_hba_port->port_attributes.\
PortSpecificAttribute.SASPort);
- free(last_tgt_port);
- }
-
- phy_ptr = hba_port->first_phy;
- while (phy_ptr != NULL) {
- last_phy = phy_ptr;
- phy_ptr = phy_ptr->next;
- free(last_phy);
- }
-
- last_hba_port = hba_port;
- hba_port = hba_port->next;
- free(last_hba_port->port_attributes.\
- PortSpecificAttribute.SASPort);
- free(last_hba_port);
+ free(last_hba_port);
}
open_handle = hba_ptr->open_handles;
while (open_handle != NULL) {
- last_open_handle = open_handle;
- open_handle = open_handle->next;
- free(last_open_handle);
+ last_open_handle = open_handle;
+ open_handle = open_handle->next;
+ free(last_open_handle);
}
/* Free up the top level HBA structure from the last spin */
if (last_hba_ptr != NULL) {
- free(last_hba_ptr);
+ free(last_hba_ptr);
}
last_hba_ptr = hba_ptr;
}
if (last_hba_ptr != NULL) {
- free(last_hba_ptr);
+ free(last_hba_ptr);
}
return (HBA_STATUS_OK);
diff --git a/usr/src/lib/sun_sas/common/Sun_sasGetAdapterAttributes.c b/usr/src/lib/sun_sas/common/Sun_sasGetAdapterAttributes.c
index d5e5e55ec1..07dae789b9 100644
--- a/usr/src/lib/sun_sas/common/Sun_sasGetAdapterAttributes.c
+++ b/usr/src/lib/sun_sas/common/Sun_sasGetAdapterAttributes.c
@@ -23,6 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sun_sas.h>
/*
@@ -30,14 +33,15 @@
*/
HBA_STATUS
Sun_sasGetAdapterAttributes(HBA_HANDLE handle,
- PSMHBA_ADAPTERATTRIBUTES attributes) {
+ PSMHBA_ADAPTERATTRIBUTES attributes)
+{
const char ROUTINE[] = "Sun_sasGetAdapterAttributes";
- struct sun_sas_hba *hba_ptr;
- int index = 0;
+ struct sun_sas_hba *hba_ptr;
+ int index = 0;
if (attributes == NULL) {
- log(LOG_DEBUG, ROUTINE, "NULL attributes pointer");
- return (HBA_STATUS_ERROR_ARG);
+ log(LOG_DEBUG, ROUTINE, "NULL attributes pointer");
+ return (HBA_STATUS_ERROR_ARG);
}
lock(&all_hbas_lock);
@@ -45,11 +49,10 @@ Sun_sasGetAdapterAttributes(HBA_HANDLE handle,
lock(&open_handles_lock);
hba_ptr = RetrieveHandle(index);
if (hba_ptr == NULL) {
- log(LOG_DEBUG, ROUTINE,
- "Invalid handle %08lx", handle);
- unlock(&open_handles_lock);
- unlock(&all_hbas_lock);
- return (HBA_STATUS_ERROR_INVALID_HANDLE);
+ log(LOG_DEBUG, ROUTINE, "Invalid handle %08lx", handle);
+ unlock(&open_handles_lock);
+ unlock(&all_hbas_lock);
+ return (HBA_STATUS_ERROR_INVALID_HANDLE);
}
(void) memcpy(attributes, &hba_ptr->adapter_attributes,
diff --git a/usr/src/lib/sun_sas/common/Sun_sasGetAdapterName.c b/usr/src/lib/sun_sas/common/Sun_sasGetAdapterName.c
index bf945aedb9..041874e1d6 100644
--- a/usr/src/lib/sun_sas/common/Sun_sasGetAdapterName.c
+++ b/usr/src/lib/sun_sas/common/Sun_sasGetAdapterName.c
@@ -23,6 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include "sun_sas.h"
@@ -31,36 +34,40 @@
* open the adapter with the library.
*
* Arguments:
- * index the index to which adapter to retrive the name
+ * index the index to which adapter to retrieve the name
* name buffer to which the adapter name will be placed
*/
-HBA_STATUS Sun_sasGetAdapterName(HBA_UINT32 index, char *name) {
+HBA_STATUS
+Sun_sasGetAdapterName(HBA_UINT32 index, char *name)
+{
const char ROUTINE[] = "Sun_sasGetAdapterName";
struct sun_sas_hba *hba_ptr;
if (name == NULL) {
- log(LOG_DEBUG, ROUTINE, "NULL adapter name");
- return (HBA_STATUS_ERROR_ARG);
+ log(LOG_DEBUG, ROUTINE, "NULL adapter name");
+ return (HBA_STATUS_ERROR_ARG);
}
lock(&all_hbas_lock);
for (hba_ptr = global_hba_head; hba_ptr != NULL;
- hba_ptr = hba_ptr->next) {
- if (hba_ptr->index == index) {
- if (hba_ptr->handle_name == NULL) {
- hba_ptr = NULL;
+ hba_ptr = hba_ptr->next) {
+ if (hba_ptr->index == index) {
+ if (hba_ptr->handle_name[0] == '\0') {
+ hba_ptr = NULL;
+ break;
+ }
+ /*
+ * Flaw in the spec! How do we know the size of name?
+ */
+ (void) strlcpy(name, hba_ptr->handle_name,
+ strlen(hba_ptr->handle_name)+1);
break;
- }
- /* Flaw in the spec! How do we know the size of name? */
- (void) strlcpy(name, hba_ptr->handle_name,
- strlen(hba_ptr->handle_name)+1);
- break;
- }
+ }
}
unlock(&all_hbas_lock);
if (hba_ptr == NULL) {
- log(LOG_DEBUG, ROUTINE,
- "Unable to find adapter index %d.", index);
- return (HBA_STATUS_ERROR_ILLEGAL_INDEX);
+ log(LOG_DEBUG, ROUTINE,
+ "Unable to find adapter index %d.", index);
+ return (HBA_STATUS_ERROR_ILLEGAL_INDEX);
}
return (HBA_STATUS_OK);
diff --git a/usr/src/lib/sun_sas/common/Sun_sasGetAdapterPortAttributes.c b/usr/src/lib/sun_sas/common/Sun_sasGetAdapterPortAttributes.c
index cd60698a72..175df42a47 100644
--- a/usr/src/lib/sun_sas/common/Sun_sasGetAdapterPortAttributes.c
+++ b/usr/src/lib/sun_sas/common/Sun_sasGetAdapterPortAttributes.c
@@ -23,15 +23,18 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sun_sas.h>
/*
* Retrieves the attributes for a specified port of an adapter
*/
HBA_STATUS
-Sun_sasGetAdapterPortAttributes(HBA_HANDLE handle,
- HBA_UINT32 port, PSMHBA_PORTATTRIBUTES attributes) {
+Sun_sasGetAdapterPortAttributes(HBA_HANDLE handle, HBA_UINT32 port,
+ PSMHBA_PORTATTRIBUTES attributes)
+{
const char ROUTINE[] = "Sun_sasGetAdapterPortAttributes";
HBA_STATUS status;
struct sun_sas_hba *hba_ptr;
@@ -41,8 +44,8 @@ Sun_sasGetAdapterPortAttributes(HBA_HANDLE handle,
/* Validate the arguments */
if ((attributes == NULL) ||
(attributes->PortSpecificAttribute.SASPort == NULL)) {
- log(LOG_DEBUG, ROUTINE, "NULL attributes");
- return (HBA_STATUS_ERROR_ARG);
+ log(LOG_DEBUG, ROUTINE, "NULL attributes");
+ return (HBA_STATUS_ERROR_ARG);
}
lock(&all_hbas_lock);
@@ -66,19 +69,17 @@ Sun_sasGetAdapterPortAttributes(HBA_HANDLE handle,
}
if (hba_ptr->first_port == NULL) {
- /* This is probably an internal failure of the library */
- if (hba_ptr->device_path) {
- log(LOG_DEBUG, ROUTINE,
- "Internal failure: Adapter %s contains no port data",
- hba_ptr->device_path);
- } else {
- log(LOG_DEBUG, ROUTINE,
- "Internal failure: Adapter at index %d contains no port "
- "data", hba_ptr->index);
- }
- unlock(&open_handles_lock);
- unlock(&all_hbas_lock);
- return (HBA_STATUS_ERROR);
+ /* This is probably an internal failure of the library */
+ if (hba_ptr->device_path[0] != '\0') {
+ log(LOG_DEBUG, ROUTINE, "Internal failure: Adapter "
+ "%s contains no port data", hba_ptr->device_path);
+ } else {
+ log(LOG_DEBUG, ROUTINE, "Internal failure: Adapter at"
+ " index %d contains no port data", hba_ptr->index);
+ }
+ unlock(&open_handles_lock);
+ unlock(&all_hbas_lock);
+ return (HBA_STATUS_ERROR);
}
for (hba_port_ptr = hba_ptr->first_port;
hba_port_ptr != NULL; hba_port_ptr = hba_port_ptr->next) {
diff --git a/usr/src/lib/sun_sas/common/Sun_sasGetDiscoveredPortAttributes.c b/usr/src/lib/sun_sas/common/Sun_sasGetDiscoveredPortAttributes.c
index 10de1cbcff..75609ffbc2 100644
--- a/usr/src/lib/sun_sas/common/Sun_sasGetDiscoveredPortAttributes.c
+++ b/usr/src/lib/sun_sas/common/Sun_sasGetDiscoveredPortAttributes.c
@@ -23,6 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sun_sas.h>
@@ -31,8 +34,9 @@
*/
HBA_STATUS
Sun_sasGetDiscoveredPortAttributes(HBA_HANDLE handle,
- HBA_UINT32 port, HBA_UINT32 discoveredport,
- SMHBA_PORTATTRIBUTES *attributes) {
+ HBA_UINT32 port, HBA_UINT32 discoveredport,
+ SMHBA_PORTATTRIBUTES *attributes)
+{
const char ROUTINE[] =
"Sun_sasGetDiscoveredPortAttributes";
HBA_STATUS status;
@@ -42,10 +46,10 @@ Sun_sasGetDiscoveredPortAttributes(HBA_HANDLE handle,
int index;
if (attributes == NULL) {
- log(LOG_DEBUG, ROUTINE,
- "NULL attributes argument. Handle %08lx, port %d, "
- "discovered port %d", handle, port, discoveredport);
- return (HBA_STATUS_ERROR_ARG);
+ log(LOG_DEBUG, ROUTINE,
+ "NULL attributes argument. Handle %08lx, port %d, "
+ "discovered port %d", handle, port, discoveredport);
+ return (HBA_STATUS_ERROR_ARG);
}
lock(&all_hbas_lock);
@@ -53,37 +57,34 @@ Sun_sasGetDiscoveredPortAttributes(HBA_HANDLE handle,
lock(&open_handles_lock);
hba_ptr = RetrieveHandle(index);
if (hba_ptr == NULL) {
- log(LOG_DEBUG, ROUTINE,
- "Invalid handle %08lx.", handle);
- unlock(&open_handles_lock);
- unlock(&all_hbas_lock);
- return (HBA_STATUS_ERROR_INVALID_HANDLE);
+ log(LOG_DEBUG, ROUTINE, "Invalid handle %08lx.", handle);
+ unlock(&open_handles_lock);
+ unlock(&all_hbas_lock);
+ return (HBA_STATUS_ERROR_INVALID_HANDLE);
}
/* Check for stale data */
status = verifyAdapter(hba_ptr);
if (status != HBA_STATUS_OK) {
- log(LOG_DEBUG, ROUTINE, "Verify Adapter failed");
- unlock(&open_handles_lock);
- unlock(&all_hbas_lock);
- return (status);
+ log(LOG_DEBUG, ROUTINE, "Verify Adapter failed");
+ unlock(&open_handles_lock);
+ unlock(&all_hbas_lock);
+ return (status);
}
if (hba_ptr->first_port == NULL) {
- /* This is probably an internal failure of the library */
- if (hba_ptr->device_path) {
- log(LOG_DEBUG, ROUTINE,
- "Internal failure: Adapter %s contains no port data",
- hba_ptr->device_path);
- } else {
- log(LOG_DEBUG, ROUTINE,
- "Internal failure: Adapter at index %d contains no port "
- "data", hba_ptr->index);
- }
- unlock(&open_handles_lock);
- unlock(&all_hbas_lock);
- return (HBA_STATUS_ERROR);
+ /* This is probably an internal failure of the library */
+ if (hba_ptr->device_path[0] != '\0') {
+ log(LOG_DEBUG, ROUTINE, "Internal failure: Adapter %s"
+ " contains no port data", hba_ptr->device_path);
+ } else {
+ log(LOG_DEBUG, ROUTINE, "Internal failure: Adapter at"
+ " index %d contains no port data", hba_ptr->index);
+ }
+ unlock(&open_handles_lock);
+ unlock(&all_hbas_lock);
+ return (HBA_STATUS_ERROR);
}
for (hba_port_ptr = hba_ptr->first_port;
@@ -105,11 +106,11 @@ Sun_sasGetDiscoveredPortAttributes(HBA_HANDLE handle,
/* check to make sure there are devices attached to this port */
if (hba_port_ptr->first_attached_port != NULL) {
for (hba_disco_port = hba_port_ptr->first_attached_port;
- hba_disco_port != NULL;
- hba_disco_port = hba_disco_port->next) {
- if (hba_disco_port->index == discoveredport) {
- break;
- }
+ hba_disco_port != NULL;
+ hba_disco_port = hba_disco_port->next) {
+ if (hba_disco_port->index == discoveredport) {
+ break;
+ }
}
if (hba_disco_port == NULL) {
log(LOG_DEBUG, ROUTINE,
@@ -118,16 +119,17 @@ Sun_sasGetDiscoveredPortAttributes(HBA_HANDLE handle,
discoveredport, port, handle);
ret = HBA_STATUS_ERROR_ILLEGAL_INDEX;
} else {
- attributes->PortType =
- hba_disco_port->port_attributes.PortType;
- attributes->PortState =
- hba_disco_port->port_attributes.PortState;
- (void) strlcpy(attributes->OSDeviceName,
- hba_disco_port->port_attributes.OSDeviceName,
- sizeof (attributes->OSDeviceName));
- (void) memcpy(attributes->PortSpecificAttribute.SASPort,
- hba_disco_port->port_attributes.PortSpecificAttribute.
- SASPort, sizeof (struct SMHBA_SAS_Port));
+ attributes->PortType =
+ hba_disco_port->port_attributes.PortType;
+ attributes->PortState =
+ hba_disco_port->port_attributes.PortState;
+ (void) strlcpy(attributes->OSDeviceName,
+ hba_disco_port->port_attributes.OSDeviceName,
+ sizeof (attributes->OSDeviceName));
+ (void) memcpy(attributes->PortSpecificAttribute.SASPort,
+ hba_disco_port->port_attributes.\
+ PortSpecificAttribute.SASPort,
+ sizeof (struct SMHBA_SAS_Port));
}
} else {
/* No ports, so we can't possibly return anything */
diff --git a/usr/src/lib/sun_sas/common/Sun_sasGetNumberOfAdapters.c b/usr/src/lib/sun_sas/common/Sun_sasGetNumberOfAdapters.c
index 71bf0fc315..2d114e8486 100644
--- a/usr/src/lib/sun_sas/common/Sun_sasGetNumberOfAdapters.c
+++ b/usr/src/lib/sun_sas/common/Sun_sasGetNumberOfAdapters.c
@@ -23,17 +23,21 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sun_sas.h>
/*
* Returns the number of HBAs supported by the library. This returns the
* current number of HBAs, even if this changes
- *
*/
-HBA_UINT32 Sun_sasGetNumberOfAdapters() {
- int count;
- struct sun_sas_hba *hba_ptr;
+HBA_UINT32
+Sun_sasGetNumberOfAdapters(void)
+{
+ int count;
+ struct sun_sas_hba *hba_ptr;
lock(&all_hbas_lock);
/* goes through hba list counting all the hbas found */
diff --git a/usr/src/lib/sun_sas/common/Sun_sasGetPhyStatistics.c b/usr/src/lib/sun_sas/common/Sun_sasGetPhyStatistics.c
index 10f73604cf..4839c5860a 100644
--- a/usr/src/lib/sun_sas/common/Sun_sasGetPhyStatistics.c
+++ b/usr/src/lib/sun_sas/common/Sun_sasGetPhyStatistics.c
@@ -23,15 +23,19 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <kstat.h>
#include <sun_sas.h>
/*
* Retrieves the statistics for a specified port.phy on an adapter
*/
-HBA_STATUS Sun_sasGetPhyStatistics(HBA_HANDLE handle,
- HBA_UINT32 port, HBA_UINT32 phy, SMHBA_PHYSTATISTICS *pStatistics) {
+HBA_STATUS
+Sun_sasGetPhyStatistics(HBA_HANDLE handle, HBA_UINT32 port, HBA_UINT32 phy,
+ SMHBA_PHYSTATISTICS *pStatistics)
+{
const char ROUTINE[] = "Sun_sasGetPhyStatistics";
HBA_STATUS status = HBA_STATUS_OK;
struct sun_sas_hba *hba_ptr;
@@ -125,7 +129,7 @@ HBA_STATUS Sun_sasGetPhyStatistics(HBA_HANDLE handle,
/* First, we need the deivce path to locate the devinfo node. */
- (void *) strlcpy(path, hba_port_ptr->device_path,
+ (void) strlcpy(path, hba_port_ptr->device_path,
sizeof (path));
charptr = strrchr(path, ':');
if (charptr) {
@@ -216,7 +220,7 @@ HBA_STATUS Sun_sasGetPhyStatistics(HBA_HANDLE handle,
for (i = 0; i < ksp->ks_ndata; i++, kname++) {
if (strcmp(kname->name,
"SecondsSinceLastReset") == 0) {
- psas->SecondsSinceLastReset = kname->value.ull;
+ psas->SecondsSinceLastReset = kname->value.ull;
continue;
}
if (strcmp(kname->name, "TxFrames") == 0) {
diff --git a/usr/src/lib/sun_sas/common/Sun_sasGetPortAttributesByWWN.c b/usr/src/lib/sun_sas/common/Sun_sasGetPortAttributesByWWN.c
index 5c4723791a..321eb5b441 100644
--- a/usr/src/lib/sun_sas/common/Sun_sasGetPortAttributesByWWN.c
+++ b/usr/src/lib/sun_sas/common/Sun_sasGetPortAttributesByWWN.c
@@ -23,6 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sun_sas.h>
@@ -70,8 +73,8 @@ Sun_sasGetPortAttributesByWWN(HBA_HANDLE handle, HBA_WWN portWWN,
}
if (hba_ptr->first_port == NULL) {
- /* This is probably an internal failure of the library */
- if (hba_ptr->device_path) {
+ /* This is probably an internal failure of the library */
+ if (hba_ptr->device_path[0] != '\0') {
log(LOG_DEBUG, ROUTINE,
"Internal failure: Adapter %s contains "
"no port data", hba_ptr->device_path);
diff --git a/usr/src/lib/sun_sas/common/Sun_sasGetPortType.c b/usr/src/lib/sun_sas/common/Sun_sasGetPortType.c
index 3c422e4777..b1c81cb3b3 100644
--- a/usr/src/lib/sun_sas/common/Sun_sasGetPortType.c
+++ b/usr/src/lib/sun_sas/common/Sun_sasGetPortType.c
@@ -23,7 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sun_sas.h>
/*
@@ -31,8 +33,8 @@
* current number of HBAs, even if this changes
*
*/
-HBA_UINT32 Sun_sasGetPortType(HBA_HANDLE handle, HBA_UINT32 port,
- HBA_PORTTYPE *porttype)
+HBA_UINT32
+Sun_sasGetPortType(HBA_HANDLE handle, HBA_UINT32 port, HBA_PORTTYPE *porttype)
{
const char ROUTINE[] = "Sun_sasGetPortType";
int index;
@@ -58,8 +60,8 @@ HBA_UINT32 Sun_sasGetPortType(HBA_HANDLE handle, HBA_UINT32 port,
}
if (hba_ptr->first_port == NULL) {
- /* This is probably an internal failure of the library */
- if (hba_ptr->device_path) {
+ /* This is probably an internal failure of the library */
+ if (hba_ptr->device_path[0] != '\0') {
log(LOG_DEBUG, ROUTINE,
"Internal failure: Adapter %s contains no port "
"data.", hba_ptr->device_path);
diff --git a/usr/src/lib/sun_sas/common/Sun_sasOpenAdapter.c b/usr/src/lib/sun_sas/common/Sun_sasOpenAdapter.c
index 4556b4f86e..f4f515efd0 100644
--- a/usr/src/lib/sun_sas/common/Sun_sasOpenAdapter.c
+++ b/usr/src/lib/sun_sas/common/Sun_sasOpenAdapter.c
@@ -23,6 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sun_sas.h>
@@ -36,7 +39,7 @@
*/
HBA_HANDLE Sun_sasOpenAdapter(char *name) {
const char ROUTINE[] = "Sun_sasOpenAdapter";
- struct sun_sas_hba *hba_ptr;
+ struct sun_sas_hba *hba_ptr;
if (name == NULL) {
log(LOG_DEBUG, ROUTINE, "NULL adapter name.");
diff --git a/usr/src/lib/sun_sas/common/Sun_sasRefreshAdapterConfiguration.c b/usr/src/lib/sun_sas/common/Sun_sasRefreshAdapterConfiguration.c
index 591342ad39..b3b22fe991 100644
--- a/usr/src/lib/sun_sas/common/Sun_sasRefreshAdapterConfiguration.c
+++ b/usr/src/lib/sun_sas/common/Sun_sasRefreshAdapterConfiguration.c
@@ -23,6 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sun_sas.h>
@@ -56,7 +59,7 @@ find_matching_hba(di_node_t node, void *arg)
devpath);
if ((strstr(fulldevpath, wa->devpath)) != NULL) {
- *wa->flag = B_TRUE;
+ *wa->flag = B_TRUE;
/* Found a node. No need to walk any more. */
di_devfs_path_free(devpath);
return (DI_WALK_TERMINATE);
diff --git a/usr/src/lib/sun_sas/common/Sun_sasScsiInquiry.c b/usr/src/lib/sun_sas/common/Sun_sasScsiInquiry.c
index 144a85d89d..f6dc9f367a 100644
--- a/usr/src/lib/sun_sas/common/Sun_sasScsiInquiry.c
+++ b/usr/src/lib/sun_sas/common/Sun_sasScsiInquiry.c
@@ -23,6 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sun_sas.h>
@@ -67,9 +70,9 @@ SendScsiInquiry(const char *devpath, HBA_UINT8 cdb1, HBA_UINT8 cdb2,
*/
HBA_STATUS
Sun_sasScsiInquiry(HBA_HANDLE handle, HBA_WWN portWWN, HBA_WWN targetPortWWN,
- HBA_WWN domainPortWWN, SMHBA_SCSILUN smhbaLUN, HBA_UINT8 cdb1,
- HBA_UINT8 cdb2, void *responseBuffer, HBA_UINT32 *responseSize,
- HBA_UINT8 *scsiStatus, void *senseBuffer, HBA_UINT32 *senseSize)
+ HBA_WWN domainPortWWN, SMHBA_SCSILUN smhbaLUN, HBA_UINT8 cdb1,
+ HBA_UINT8 cdb2, void *responseBuffer, HBA_UINT32 *responseSize,
+ HBA_UINT8 *scsiStatus, void *senseBuffer, HBA_UINT32 *senseSize)
{
const char ROUTINE[] = "Sun_sasScsiInquiry";
HBA_STATUS status;
@@ -131,9 +134,9 @@ Sun_sasScsiInquiry(HBA_HANDLE handle, HBA_WWN portWWN, HBA_WWN targetPortWWN,
* By verifying this information here, we will take a big performance
* hit. This check will be done later only if the Inquiry ioctl fails
*/
- if (hba_ptr->device_path == NULL) {
+ if (hba_ptr->device_path[0] == '\0') {
log(LOG_DEBUG, ROUTINE,
- "HBA handle had NULL device path. \
+ "HBA handle had empty device path. \
Unable to send SCSI cmd");
unlock(&open_handles_lock);
unlock(&all_hbas_lock);
diff --git a/usr/src/lib/sun_sas/common/Sun_sasSendSMPPassThru.c b/usr/src/lib/sun_sas/common/Sun_sasSendSMPPassThru.c
index 914f47de06..74eccacf24 100644
--- a/usr/src/lib/sun_sas/common/Sun_sasSendSMPPassThru.c
+++ b/usr/src/lib/sun_sas/common/Sun_sasSendSMPPassThru.c
@@ -23,6 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sun_sas.h>
#include <sys/scsi/impl/usmp.h>
@@ -32,7 +35,8 @@
*/
static HBA_STATUS
SendSMPPassThru(const char *devpath, void *reqframe, HBA_UINT32 *reqsize,
- void *rspframe, HBA_UINT32 *rspsize) {
+ void *rspframe, HBA_UINT32 *rspsize)
+{
const char ROUTINE[] = "SendSMPPassThru";
int fd;
usmp_cmd_t ucmd_buf;
@@ -63,11 +67,11 @@ SendSMPPassThru(const char *devpath, void *reqframe, HBA_UINT32 *reqsize,
if (ioctl(fd, USMPFUNC, &ucmd_buf) == -1) {
if ((errno == ETIME) || (errno == ETIMEDOUT) ||
(errno == EAGAIN)) {
- ret = HBA_STATUS_ERROR_TRY_AGAIN;
+ ret = HBA_STATUS_ERROR_TRY_AGAIN;
} else if (errno == EBUSY) {
- ret = HBA_STATUS_ERROR_BUSY;
+ ret = HBA_STATUS_ERROR_BUSY;
} else {
- ret = HBA_STATUS_ERROR;
+ ret = HBA_STATUS_ERROR;
}
log(LOG_DEBUG, ROUTINE, "ioctl:USMPFUNC failed due to %s",
strerror(errno));
@@ -133,9 +137,9 @@ Sun_sasSendSMPPassThru(HBA_HANDLE handle, HBA_WWN hbaPortWWN,
* hit. This check will be done later only if the Inquiry ioctl fails
*/
- if (hba_ptr->device_path == NULL) {
+ if (hba_ptr->device_path[0] == '\0') {
log(LOG_DEBUG, ROUTINE,
- "HBA handle had NULL device path.\
+ "HBA handle had empty device path.\
Unable to send SCSI cmd");
unlock(&all_hbas_lock);
return (HBA_STATUS_ERROR);
diff --git a/usr/src/lib/sun_sas/common/devlink_disco.c b/usr/src/lib/sun_sas/common/devlink_disco.c
index 9b616e2293..96f5b7bbcb 100644
--- a/usr/src/lib/sun_sas/common/devlink_disco.c
+++ b/usr/src/lib/sun_sas/common/devlink_disco.c
@@ -23,6 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sun_sas.h>
#include <sys/types.h>
@@ -198,7 +201,7 @@ lookupLink(char *path, char *link, const char *dir, const char *mname)
charptr = dirp->d_name;
(void) snprintf(node, strlen(charptr) + strlen(dir) + 2,
"%s/%s", dir, charptr);
- if (count = readlink(node, buf, sizeof (buf))) {
+ if ((count = readlink(node, buf, sizeof (buf))) > 0) {
subpath = NULL;
subpath = strstr(buf, path);
buf[count] = '\0';
diff --git a/usr/src/lib/sun_sas/common/devtree_device_disco.c b/usr/src/lib/sun_sas/common/devtree_device_disco.c
index 53254766ac..452a2bf70a 100644
--- a/usr/src/lib/sun_sas/common/devtree_device_disco.c
+++ b/usr/src/lib/sun_sas/common/devtree_device_disco.c
@@ -23,6 +23,7 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2019 Joyent, Inc.
*/
#include <sun_sas.h>
@@ -84,8 +85,8 @@ get_minor(char *devpath, char *minor)
static void
free_attached_port(struct sun_sas_port *port_ptr)
{
- struct sun_sas_port *tgt_port, *last_tgt_port;
- struct ScsiEntryList *scsi_info = NULL, *last_scsi_info = NULL;
+ struct sun_sas_port *tgt_port, *last_tgt_port;
+ struct ScsiEntryList *scsi_info = NULL, *last_scsi_info = NULL;
tgt_port = port_ptr->first_attached_port;
while (tgt_port != NULL) {
@@ -228,6 +229,7 @@ get_attached_devices_info(di_node_t node, struct sun_sas_port *port_ptr)
char *devpath, link[MAXNAMELEN];
char fullpath[MAXPATHLEN+1];
char minorname[MAXNAMELEN+1];
+ SMHBA_PORTATTRIBUTES *portattrs;
struct ScsiEntryList *mapping_ptr;
HBA_WWN SASAddress, AttachedSASAddress;
struct sun_sas_port *disco_port_ptr;
@@ -488,11 +490,11 @@ get_attached_devices_info(di_node_t node, struct sun_sas_port *port_ptr)
}
/* SMP device was handled already */
- if (disco_port_ptr->port_attributes.OSDeviceName[0] == '\0') {
- /* indentation change due to ctysle check on sizeof. */
- size = sizeof (disco_port_ptr->port_attributes.OSDeviceName);
- (void) strlcpy(disco_port_ptr->port_attributes.
- OSDeviceName, fullpath, size);
+ portattrs = &disco_port_ptr->port_attributes;
+ if (portattrs->OSDeviceName[0] == '\0') {
+ size = sizeof (portattrs->OSDeviceName);
+ (void) strlcpy(portattrs->OSDeviceName,
+ fullpath, size);
}
/* add new discovered port into the list */
@@ -651,6 +653,7 @@ get_attached_paths_info(di_path_t path, struct sun_sas_port *port_ptr)
char *pathdevpath = NULL;
char fullpath[MAXPATHLEN+1];
char minorname[MAXNAMELEN+1];
+ SMHBA_PORTATTRIBUTES *portattrs;
struct ScsiEntryList *mapping_ptr;
HBA_WWN SASAddress, AttachedSASAddress;
struct sun_sas_port *disco_port_ptr;
@@ -678,7 +681,7 @@ get_attached_paths_info(di_path_t path, struct sun_sas_port *port_ptr)
port_state = HBA_PORTSTATE_OFFLINE;
}
- if (clientnode = di_path_client_node(path)) {
+ if ((clientnode = di_path_client_node(path)) != DI_NODE_NIL) {
if (di_retired(clientnode)) {
log(LOG_DEBUG, ROUTINE,
"client node of path (%s) is retired. Skipping.",
@@ -904,12 +907,12 @@ get_attached_paths_info(di_path_t path, struct sun_sas_port *port_ptr)
SASPort->PortProtocol = HBA_SASPORTPROTOCOL_SSP;
}
- if (disco_port_ptr->port_attributes.OSDeviceName[0] == '\0') {
- /* indentation change due to ctysle check on sizeof. */
- size = sizeof (disco_port_ptr->port_attributes.OSDeviceName);
+ portattrs = &disco_port_ptr->port_attributes;
+ if (portattrs->OSDeviceName[0] == '\0') {
+ size = sizeof (portattrs->OSDeviceName);
if (pathdevpath != NULL) {
- (void) strlcpy(disco_port_ptr->port_attributes.
- OSDeviceName, pathdevpath, size);
+ (void) strlcpy(portattrs->OSDeviceName,
+ pathdevpath, size);
}
}
diff --git a/usr/src/lib/sun_sas/common/devtree_hba_disco.c b/usr/src/lib/sun_sas/common/devtree_hba_disco.c
index 2ba9ef6e57..bfd584008b 100644
--- a/usr/src/lib/sun_sas/common/devtree_hba_disco.c
+++ b/usr/src/lib/sun_sas/common/devtree_hba_disco.c
@@ -22,6 +22,9 @@
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
*/
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sun_sas.h>
#include <sys/modctl.h>
@@ -595,9 +598,9 @@ devtree_get_one_hba(di_node_t hbaNode)
static int
lookup_smhba_sas_hba(di_node_t node, void *arg)
{
- const char ROUTINE[] = "lookup_smhba_sas_hba";
- int *propData, rval;
- walkarg_t *wa = (walkarg_t *)arg;
+ const char ROUTINE[] = "lookup_smhba_sas_hba";
+ int *propData, rval;
+ walkarg_t *wa = (walkarg_t *)arg;
/* Skip stub(instance -1) nodes */
if (IS_STUB_NODE(node)) {
diff --git a/usr/src/lib/sun_sas/common/event.c b/usr/src/lib/sun_sas/common/event.c
index a4030d5d1b..f565b9bd92 100644
--- a/usr/src/lib/sun_sas/common/event.c
+++ b/usr/src/lib/sun_sas/common/event.c
@@ -22,6 +22,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sun_sas.h>
#include <libsysevent.h>
@@ -133,10 +136,10 @@ syseventHandler(sysevent_t *ev)
{
const char ROUTINE[] = "syseventHandler";
- nvlist_t *attrList = NULL;
+ nvlist_t *attrList = NULL;
char *eventStr, *portAddrStr, *charptr;
int update;
- uint64_t addr;
+ uint64_t addr;
uint8_t phyId, linkRate;
HBA_WWN portAddr;
@@ -226,8 +229,8 @@ syseventHandler(sysevent_t *ev)
/* Registers events to the sysevent framework */
HBA_STATUS
-registerSysevent() {
-
+registerSysevent(void)
+{
const char ROUTINE[] = "registerSysevent";
const char *hba_subclass_list[] = {
ESC_SAS_PHY_EVENT
diff --git a/usr/src/lib/sun_sas/common/sun_sas.c b/usr/src/lib/sun_sas/common/sun_sas.c
index 0494238137..5dee35d5b2 100644
--- a/usr/src/lib/sun_sas/common/sun_sas.c
+++ b/usr/src/lib/sun_sas/common/sun_sas.c
@@ -23,7 +23,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
#include <sys/byteorder.h>
#include <sun_sas.h>
@@ -156,7 +158,7 @@ RetrieveOpenHandle(HBA_HANDLE handle)
struct sun_sas_hba *
RetrieveHandle(int index)
{
- struct sun_sas_hba *hba_ptr = NULL;
+ struct sun_sas_hba *hba_ptr = NULL;
for (hba_ptr = global_hba_head; hba_ptr != NULL;
hba_ptr = hba_ptr->next) {
@@ -176,8 +178,8 @@ RetrieveHandle(int index)
struct sun_sas_hba *
ExtractHandle(int index)
{
- struct sun_sas_hba *last = NULL;
- struct sun_sas_hba *hba_ptr = NULL;
+ struct sun_sas_hba *last = NULL;
+ struct sun_sas_hba *hba_ptr = NULL;
for (hba_ptr = global_hba_head;
hba_ptr != NULL;
@@ -344,7 +346,7 @@ getFirstAdapterPortWWN(HBA_HANDLE handle)
if (hba_ptr->first_port == NULL) {
/* This is probably an internal failure of the library */
- if (hba_ptr->device_path) {
+ if (hba_ptr->device_path[0] != '\0') {
log(LOG_DEBUG, ROUTINE,
"Internal failure: Adapter %s contains no "
"port data", hba_ptr->device_path);