MCPcopy Create free account
hub / github.com/F-Stack/f-stack / nvpair_value_common

Function nvpair_value_common

freebsd/contrib/openzfs/module/nvpair/nvpair.c:1541–1616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1539}
1540
1541static int
1542nvpair_value_common(nvpair_t *nvp, data_type_t type, uint_t *nelem, void *data)
1543{
1544 int value_sz;
1545
1546 if (nvp == NULL || nvpair_type(nvp) != type)
1547 return (EINVAL);
1548
1549 /*
1550 * For non-array types, we copy the data.
1551 * For array types (including string), we set a pointer.
1552 */
1553 switch (type) {
1554 case DATA_TYPE_BOOLEAN:
1555 if (nelem != NULL)
1556 *nelem = 0;
1557 break;
1558
1559 case DATA_TYPE_BOOLEAN_VALUE:
1560 case DATA_TYPE_BYTE:
1561 case DATA_TYPE_INT8:
1562 case DATA_TYPE_UINT8:
1563 case DATA_TYPE_INT16:
1564 case DATA_TYPE_UINT16:
1565 case DATA_TYPE_INT32:
1566 case DATA_TYPE_UINT32:
1567 case DATA_TYPE_INT64:
1568 case DATA_TYPE_UINT64:
1569 case DATA_TYPE_HRTIME:
1570#if !defined(_KERNEL)
1571 case DATA_TYPE_DOUBLE:
1572#endif
1573 if (data == NULL)
1574 return (EINVAL);
1575 if ((value_sz = i_get_value_size(type, NULL, 1)) < 0)
1576 return (EINVAL);
1577 bcopy(NVP_VALUE(nvp), data, (size_t)value_sz);
1578 if (nelem != NULL)
1579 *nelem = 1;
1580 break;
1581
1582 case DATA_TYPE_NVLIST:
1583 case DATA_TYPE_STRING:
1584 if (data == NULL)
1585 return (EINVAL);
1586 *(void **)data = (void *)NVP_VALUE(nvp);
1587 if (nelem != NULL)
1588 *nelem = 1;
1589 break;
1590
1591 case DATA_TYPE_BOOLEAN_ARRAY:
1592 case DATA_TYPE_BYTE_ARRAY:
1593 case DATA_TYPE_INT8_ARRAY:
1594 case DATA_TYPE_UINT8_ARRAY:
1595 case DATA_TYPE_INT16_ARRAY:
1596 case DATA_TYPE_UINT16_ARRAY:
1597 case DATA_TYPE_INT32_ARRAY:
1598 case DATA_TYPE_UINT32_ARRAY:

Callers 15

nvlist_lookup_commonFunction · 0.85
nvpair_value_byteFunction · 0.85
nvpair_value_int8Function · 0.85
nvpair_value_uint8Function · 0.85
nvpair_value_int16Function · 0.85
nvpair_value_uint16Function · 0.85
nvpair_value_int32Function · 0.85
nvpair_value_uint32Function · 0.85
nvpair_value_int64Function · 0.85
nvpair_value_uint64Function · 0.85
nvpair_value_doubleFunction · 0.85

Calls 2

i_get_value_sizeFunction · 0.85
nvpair_typeFunction · 0.70

Tested by

no test coverage detected