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

Function nvpair_unpack_bool

freebsd/contrib/libnv/bsd_nvpair.c:716–745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

714}
715
716const unsigned char *
717nvpair_unpack_bool(bool isbe __unused, nvpair_t *nvp, const unsigned char *ptr,
718 size_t *leftp)
719{
720 uint8_t value;
721
722 PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_BOOL);
723
724 if (nvp->nvp_datasize != sizeof(value)) {
725 ERRNO_SET(EINVAL);
726 return (NULL);
727 }
728 if (*leftp < sizeof(value)) {
729 ERRNO_SET(EINVAL);
730 return (NULL);
731 }
732
733 memcpy(&value, ptr, sizeof(value));
734 ptr += sizeof(value);
735 *leftp -= sizeof(value);
736
737 if (value != 0 && value != 1) {
738 ERRNO_SET(EINVAL);
739 return (NULL);
740 }
741
742 nvp->nvp_data = (uint64_t)value;
743
744 return (ptr);
745}
746
747const unsigned char *
748nvpair_unpack_number(bool isbe, nvpair_t *nvp, const unsigned char *ptr,

Callers 1

nvlist_xunpackFunction · 0.85

Calls 1

memcpyFunction · 0.50

Tested by

no test coverage detected