MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / llliGetNumber

Function llliGetNumber

Library/OcGuardLib/Ubsan.c:1483–1526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

DeserializeNumberFunction · 0.85
isNegativeNumberFunction · 0.85

Calls 3

zDeserializeTypeWidthFunction · 0.85
ReportFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected