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

Function llliGetNumber

freebsd/kern/kern_ubsan.c:1474–1515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1472#endif
1473
1474static longest
1475llliGetNumber(char *szLocation, struct CTypeDescriptor *pType, unsigned long ulNumber)
1476{
1477 size_t zNumberWidth;
1478 longest L = 0;
1479
1480 ASSERT(szLocation);
1481 ASSERT(pType);
1482
1483 zNumberWidth = zDeserializeTypeWidth(pType);
1484 switch (zNumberWidth) {
1485 default:
1486 Report(true, "UBSan: Unexpected %zu-Bit Type in %s\n", zNumberWidth, szLocation);
1487 /* NOTREACHED */
1488 case WIDTH_128:
1489#ifdef __SIZEOF_INT128__
1490 memcpy(&L, REINTERPRET_CAST(longest *, ulNumber), sizeof(longest));
1491#else
1492 Report(true, "UBSan: Unexpected 128-Bit Type in %s\n", szLocation);
1493 /* NOTREACHED */
1494#endif
1495 break;
1496 case WIDTH_64:
1497 if (sizeof(ulNumber) * CHAR_BIT < WIDTH_64) {
1498 L = *REINTERPRET_CAST(int64_t *, ulNumber);
1499 } else {
1500 L = STATIC_CAST(int64_t, STATIC_CAST(uint64_t, ulNumber));
1501 }
1502 break;
1503 case WIDTH_32:
1504 L = STATIC_CAST(int32_t, STATIC_CAST(uint32_t, ulNumber));
1505 break;
1506 case WIDTH_16:
1507 L = STATIC_CAST(int16_t, STATIC_CAST(uint16_t, ulNumber));
1508 break;
1509 case WIDTH_8:
1510 L = STATIC_CAST(int8_t, STATIC_CAST(uint8_t, ulNumber));
1511 break;
1512 }
1513
1514 return L;
1515}
1516
1517static ulongest
1518llluGetNumber(char *szLocation, struct CTypeDescriptor *pType, unsigned long ulNumber)

Callers 2

DeserializeNumberFunction · 0.85
isNegativeNumberFunction · 0.85

Calls 3

zDeserializeTypeWidthFunction · 0.85
ReportFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected