diff options
| author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2019-10-30 12:03:14 +0000 |
|---|---|---|
| committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2019-10-30 12:03:14 +0000 |
| commit | eacc5467041c23968e9447b7143975ee4eaaeeee (patch) | |
| tree | e654de48d06640d11ee4b9e815fcfecab7658bac /usr/src/lib | |
| parent | d84c48b412a8b9237a5f5ebbd017bc17997a127d (diff) | |
| parent | 106e8bd44b02f4b8cd3c825790276c1c7081e67a (diff) | |
| download | illumos-joyent-eacc5467041c23968e9447b7143975ee4eaaeeee.tar.gz | |
[illumos-gate merge]
commit 106e8bd44b02f4b8cd3c825790276c1c7081e67a
11867 PCIe expansion slots mis-labelled in topo
commit 00f453f4ebc211cb928f19a54d3f4edd61f43279
11862 cleanup smatch/cstyle/wscheck issues in usr/src/lib/sun_sas/
commit 744b124e8caed130fec6baedb0c53d1b6de03e41
11885 man3m: missing symlinks
commit 6b734416901818aa8c4bbb09c12b691ea771dc94
11858 crontab could support /step
commit ece0bc848de931052064be9faf07f4e44c150a15
11883 loader: zio_checksum_verify should check byteswap
commit 1a2641f606f3bfa50cdbbe8770af78116de52563
11521 ::whereopen should be usable in a pipeline
commit 042b56085944fdf280ee8e4a93b329c206054f88
11882 loader: rs_alloc() may return NULL
commit b12258b69ac245658b0ca5ae070b3ff004186148
11866 Use -fstack-protector-strong when available
commit 241bfedfbd27da9d3f2aa7ffaafa5da978f23afe
11842 Want audit events for auditon(A_SETPMASK) and friends
commit 8675de3a4bb7d310dd672e8f2bf479154e07c678
11872 Fix incremental recursive encrypted receive
commit 7ca0d613a17085b59a8b231daa9eddfa74fd83ee
11845 acquire-spray test could be improved
11857 kmc-update test missing from runfile
commit a0ee54468d6e6b136d1ca470a03bb44165c66e6e
11871 smatch should not hammer linux procfs path
Conflicts:
usr/src/uts/intel/Makefile.intel
usr/src/cmd/cron/cron.h
usr/src/cmd/cron/cron.c
usr/src/cmd/cron/Makefile
Diffstat (limited to 'usr/src/lib')
24 files changed, 385 insertions, 256 deletions
diff --git a/usr/src/lib/fm/topo/modules/common/pcibus/did.c b/usr/src/lib/fm/topo/modules/common/pcibus/did.c index 59ba171c75..a15d722eb1 100644 --- a/usr/src/lib/fm/topo/modules/common/pcibus/did.c +++ b/usr/src/lib/fm/topo/modules/common/pcibus/did.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2019 Joyent, Inc. */ /* @@ -104,11 +105,37 @@ di_devtype_get(topo_mod_t *mp, di_node_t src, char **devtype) typedef struct smbios_slot_cb { int cb_slotnum; + int cb_bdf; const char *cb_label; } smbios_slot_cb_t; static int -di_smbios_find_slot(smbios_hdl_t *shp, const smbios_struct_t *strp, void *data) +di_smbios_find_slot_by_bdf(smbios_hdl_t *shp, const smbios_struct_t *strp, + void *data) +{ + smbios_slot_cb_t *cbp = data; + smbios_slot_t slot; + int bus, df; + + bus = (cbp->cb_bdf & 0xFF00) >> 8; + df = cbp->cb_bdf & 0xFF; + + if (strp->smbstr_type != SMB_TYPE_SLOT || + smbios_info_slot(shp, strp->smbstr_id, &slot) != 0) + return (0); + + if (slot.smbl_bus == bus && slot.smbl_df == df) { + cbp->cb_label = slot.smbl_name; + cbp->cb_slotnum = slot.smbl_id; + return (1); + } + + return (0); +} + +static int +di_smbios_find_slot_by_id(smbios_hdl_t *shp, const smbios_struct_t *strp, + void *data) { smbios_slot_cb_t *cbp = data; smbios_slot_t slot; @@ -126,9 +153,10 @@ di_smbios_find_slot(smbios_hdl_t *shp, const smbios_struct_t *strp, void *data) } static int -di_physlotinfo_get(topo_mod_t *mp, di_node_t src, int *slotnum, char **slotname) +di_physlotinfo_get(topo_mod_t *mp, di_node_t src, int bdf, int *slotnum, + char **slotname) { - char *slotbuf; + char *slotbuf = NULL; int sz; uchar_t *buf; smbios_hdl_t *shp; @@ -154,55 +182,90 @@ di_physlotinfo_get(topo_mod_t *mp, di_node_t src, int *slotnum, char **slotname) (void) sscanf((char *)&buf[4], "Slot%d", slotnum); } - if (*slotnum == -1) - return (0); - /* - * Order of preference - * 1) take slotnum and look up in SMBIOS table - * 2) use slot-names - * 3) fabricate name based on slotnum + * If the system supports SMBIOS (virtual certainty on X86) then we will + * source the label from the Type 9 (Slot) records. If we're unable + * to correlate the device with a slot record (as would happen with + * onboard PCIe devices), we return without setting slotname, which will + * ultimately result in the node inheriting the FRU label from its + * parent node. + * + * In the absence of any SMBIOS support (i.e. SPARC) then we will use + * the slot-names property, if available. Otherwise we'll fall back + * to fabricating a label based on the slot number. */ if ((shp = topo_mod_smbios(mp)) != NULL) { /* * The PCI spec describes slot number 0 as reserved for - * internal PCI devices. Not all platforms respect - * this, so we have to treat slot 0 as a valid device. - * But other platforms use 0 to identify an internal - * device. We deal with this by letting SMBIOS be the - * final decision maker. If SMBIOS is supported, but - * the given slot number is not represented in the - * SMBIOS tables, then ignore the slot entirely. + * internal PCI devices. Unfortunately, not all platforms + * respect this. For that reason, we prefer to lookup the slot + * record using the device's BDF. However, SMBIOS + * implementations prior to 2.6 don't encode the BDF in the + * slot record. In that case we resort to looking up the + * slot record using the slot number. */ smbios_slot_cb_t cbdata; + smbios_version_t smbv; + boolean_t bdf_supp = B_TRUE; cbdata.cb_slotnum = *slotnum; + cbdata.cb_bdf = bdf; cbdata.cb_label = NULL; - if (smbios_iter(shp, di_smbios_find_slot, &cbdata) <= 0) + + /* + * The bus and device/fn payload members of the SMBIOS slot + * record were added in SMBIOS 2.6. + */ + smbios_info_smbios_version(shp, &smbv); + if (smbv.smbv_major < 2 || + (smbv.smbv_major == 2 && smbv.smbv_minor < 6)) { + bdf_supp = B_FALSE; + } + + /* + * If the SMBIOS implementation is too old to look up the slot + * records by BDF and we weren't able to derive a slotnum then + * there is nothing we can do here. + */ + if (!bdf_supp && *slotnum == -1) + return (0); + + if (bdf_supp) + (void) smbios_iter(shp, di_smbios_find_slot_by_bdf, + &cbdata); + else + (void) smbios_iter(shp, di_smbios_find_slot_by_id, + &cbdata); + + if (cbdata.cb_label == NULL) return (0); + slotbuf = (char *)cbdata.cb_label; - topo_mod_dprintf(mp, "%s: node=%p: using smbios name\n", - __func__, src); - } else if (got_slotprop == B_TRUE) { + topo_mod_dprintf(mp, "%s: di_node=%p: using smbios name: %s\n", + __func__, src, slotbuf); + } else if (got_slotprop) { slotbuf = (char *)&buf[4]; - topo_mod_dprintf(mp, "%s: node=%p: found %s property\n", - __func__, src, DI_SLOTPROP); + topo_mod_dprintf(mp, "%s: di_node=%p: using %s property: %s\n", + __func__, src, DI_SLOTPROP, slotbuf); } else { /* * Make generic description string "SLOT <num>", allow up to - * 10 digits for number + * 10 digits for number. Bail, if we weren't able to derive + * a slotnum. */ + if (*slotnum == -1) + return (0); + slotbuf = alloca(16); (void) snprintf(slotbuf, 16, "SLOT %d", *slotnum); - topo_mod_dprintf(mp, "%s: node=%p: using generic slot name\n", - __func__, src); + topo_mod_dprintf(mp, "%s: di_node=%p: using fabricated slot " + "name: %s\n", __func__, src, slotbuf); } - if ((*slotname = topo_mod_strdup(mp, slotbuf)) == NULL) - return (-1); - - topo_mod_dprintf(mp, "%s: node=%p: slotname=%s\n", - __func__, src, *slotname); + if ((*slotname = topo_mod_strdup(mp, slotbuf)) == NULL) { + /* topo errno set */ + return (-1); + } return (0); } @@ -325,7 +388,7 @@ did_create(topo_mod_t *mp, di_node_t src, /* * This is a pciex node. */ - if (di_physlotinfo_get(mp, src, &np->dp_physlot, + if (di_physlotinfo_get(mp, src, np->dp_bdf, &np->dp_physlot, &np->dp_physlot_name) < 0) { if (np->dp_devtype != NULL) topo_mod_strfree(mp, np->dp_devtype); diff --git a/usr/src/lib/fm/topo/modules/common/pcibus/pcibus_labels.c b/usr/src/lib/fm/topo/modules/common/pcibus/pcibus_labels.c index a7e59ec300..1a767312a1 100644 --- a/usr/src/lib/fm/topo/modules/common/pcibus/pcibus_labels.c +++ b/usr/src/lib/fm/topo/modules/common/pcibus/pcibus_labels.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2019 Joyent, Inc. */ #include <alloca.h> @@ -245,7 +246,7 @@ pci_slot_label_lookup(topo_mod_t *mod, tnode_t *node, did_t *dp, did_t *pdp) * of a slot while the child contains the label. * * Note that this algorithm only applies to nodes which have - * a physcal slot number. (i.e. PCIE devices or PCI/PCIX + * a physical slot number. (i.e. PCIE devices or PCI/PCIX * devices off of a PCIE to PCIX switch) */ if (did_physlot(pdp) >= 0) { @@ -258,7 +259,6 @@ pci_slot_label_lookup(topo_mod_t *mod, tnode_t *node, did_t *dp, did_t *pdp) * Get this device's physical slot name. */ l = (char *)did_physlot_name(pdp, d); - anode = topo_node_parent(node); /* @@ -386,7 +386,7 @@ pci_slot_label_lookup(topo_mod_t *mod, tnode_t *node, did_t *dp, did_t *pdp) */ if ((l = (char *)pci_label_physlot_lookup(mod, pp, pdp)) == NULL) { - if ((l = (char *)did_physlot_name(pdp, d)) != NULL) { + if ((l = (char *)did_physlot_name(dp, d)) != NULL) { l = (char *) pci_label_slotname_lookup(mod, pp, l, dp); } diff --git a/usr/src/lib/libbsm/audit_class.txt b/usr/src/lib/libbsm/audit_class.txt index 30b0d84716..da241cbe77 100644 --- a/usr/src/lib/libbsm/audit_class.txt +++ b/usr/src/lib/libbsm/audit_class.txt @@ -25,8 +25,6 @@ # # User Level Class Masks # -# Developers: If you change this file you must also edit audit.h. -# # "Meta-classes" can be created; these are supersets composed of multiple base # classes, and thus will have more than 1 bit in its mask. See "ad", "all", # "am", and "pc" below for examples. diff --git a/usr/src/lib/libbsm/audit_event.txt b/usr/src/lib/libbsm/audit_event.txt index 393d98ab62..2db2fc017e 100644 --- a/usr/src/lib/libbsm/audit_event.txt +++ b/usr/src/lib/libbsm/audit_event.txt @@ -363,6 +363,11 @@ 311:AUE_AUDITON_SETAMASK:auditon(2) - set default user preselection mask:as 312:AUE_PSECFLAGS:psecflags(2) - set process security flags:pm 313:AUE_SACL:SACL-based File Access Auditing:sa +314:AUE_AUDITON_GETPINFO:auditon(2) - get process info:aa +315:AUE_AUDITON_SETPMASK:auditon(2) - set process preselection mask:as +316:AUE_AUDITON_GETKAUDIT:auditon(2) - get kernel audit characteristics:aa +317:AUE_AUDITON_SETKAUDIT:auditon(2) - set kernel audit characteristics:as +318:AUE_AUDITON_OTHER:auditon(2) - other event:aa # # user level audit events # 2048 - 6143 Reserved diff --git a/usr/src/lib/libzfs/common/libzfs_sendrecv.c b/usr/src/lib/libzfs/common/libzfs_sendrecv.c index 13e1bafa5d..36683ac8e2 100644 --- a/usr/src/lib/libzfs/common/libzfs_sendrecv.c +++ b/usr/src/lib/libzfs/common/libzfs_sendrecv.c @@ -3481,11 +3481,21 @@ zfs_setup_cmdline_props(libzfs_handle_t *hdl, zfs_type_t type, /* raw streams can't override encryption properties */ if ((zfs_prop_encryption_key_param(prop) || - prop == ZFS_PROP_ENCRYPTION) && (raw || !newfs)) { + prop == ZFS_PROP_ENCRYPTION) && raw) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "encryption property '%s' cannot " - "be set or excluded for raw or incremental " - "streams."), name); + "be set or excluded for raw streams."), name); + ret = zfs_error(hdl, EZFS_BADPROP, errbuf); + goto error; + } + + /* incremental streams can only exclude encryption properties */ + if ((zfs_prop_encryption_key_param(prop) || + prop == ZFS_PROP_ENCRYPTION) && !newfs && + nvpair_type(nvp) != DATA_TYPE_BOOLEAN) { + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "encryption property '%s' cannot " + "be set for incremental streams."), name); ret = zfs_error(hdl, EZFS_BADPROP, errbuf); goto error; } @@ -3503,10 +3513,12 @@ zfs_setup_cmdline_props(libzfs_handle_t *hdl, zfs_type_t type, */ if (nvlist_exists(origprops, name)) { nvlist_t *attrs; + char *source = NULL; attrs = fnvlist_lookup_nvlist(origprops, name); - if (strcmp(fnvlist_lookup_string(attrs, - ZPROP_SOURCE), ZPROP_SOURCE_VAL_RECVD) != 0) + if (nvlist_lookup_string(attrs, + ZPROP_SOURCE, &source) == 0 && + strcmp(source, ZPROP_SOURCE_VAL_RECVD) != 0) continue; } /* 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); |
