- Timestamp:
- Aug 23, 2021 10:04:06 PM (3 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/strformat.cpp
r90779 r90821 49 49 * Deals with bad pointers. 50 50 */ 51 static size_trtStrFormatBadPointer(size_t cch, PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, int cchWidth,52 unsigned fFlags, void const *pvStr, char szTmp[64], const char *pszTag, int cchTag)51 DECLHIDDEN(size_t) rtStrFormatBadPointer(size_t cch, PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, int cchWidth, 52 unsigned fFlags, void const *pvStr, char szTmp[64], const char *pszTag, int cchTag) 53 53 { 54 54 static char const s_szNull[] = "<NULL>"; -
trunk/src/VBox/Runtime/common/string/strformatrt.cpp
r88200 r90821 356 356 #undef STRMEM 357 357 }; 358 static const char s_szNull[] = "<NULL>";359 358 360 359 const char *pszType = *ppszFormat - 1; … … 572 571 573 572 case RTSF_IPV6: 574 { 575 if (VALID_PTR(u.pIpv6Addr)) 573 if (RT_VALID_PTR(u.pIpv6Addr)) 576 574 return rtstrFormatIPv6(pfnOutput, pvArgOutput, u.pIpv6Addr); 577 return pfnOutput(pvArgOutput, s_szNull, sizeof(s_szNull) - 1);578 }575 return rtStrFormatBadPointer(0, pfnOutput, pvArgOutput, cchWidth, fFlags, u.pIpv6Addr, 576 szBuf, RT_STR_TUPLE("!BadIPv6")); 579 577 580 578 case RTSF_MAC: 581 { 582 if (VALID_PTR(u.pMac)) 579 if (RT_VALID_PTR(u.pMac)) 583 580 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, 584 581 "%02x:%02x:%02x:%02x:%02x:%02x", … … 589 586 u.pMac->au8[4], 590 587 u.pMac->au8[5]); 591 return pfnOutput(pvArgOutput, s_szNull, sizeof(s_szNull) - 1);592 }588 return rtStrFormatBadPointer(0, pfnOutput, pvArgOutput, cchWidth, fFlags, u.pMac, 589 szBuf, RT_STR_TUPLE("!BadMac")); 593 590 594 591 case RTSF_NETADDR: 595 { 596 if (VALID_PTR(u.pNetAddr)) 592 if (RT_VALID_PTR(u.pNetAddr)) 597 593 { 598 594 switch (u.pNetAddr->enmType) … … 639 635 } 640 636 } 641 return pfnOutput(pvArgOutput, s_szNull, sizeof(s_szNull) - 1);642 }637 return rtStrFormatBadPointer(0, pfnOutput, pvArgOutput, cchWidth, fFlags, u.pNetAddr, 638 szBuf, RT_STR_TUPLE("!BadNetAddr")); 643 639 644 640 case RTSF_UUID: 645 { 646 if (VALID_PTR(u.pUuid)) 647 { 641 if (RT_VALID_PTR(u.pUuid)) 648 642 /* cannot call RTUuidToStr because of GC/R0. */ 649 643 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, … … 660 654 u.pUuid->Gen.au8Node[4], 661 655 u.pUuid->Gen.au8Node[5]); 662 } 663 return pfnOutput(pvArgOutput, s_szNull, sizeof(s_szNull) - 1); 664 } 656 return rtStrFormatBadPointer(0, pfnOutput, pvArgOutput, cchWidth, fFlags, u.pUuid, 657 szBuf, RT_STR_TUPLE("!BadUuid")); 665 658 666 659 case RTSF_ERRINFO: 667 660 case RTSF_ERRINFO_MSG_ONLY: 668 { 669 if (VALID_PTR(u.pErrInfo) && RTErrInfoIsSet(u.pErrInfo)) 661 if (RT_VALID_PTR(u.pErrInfo) && RTErrInfoIsSet(u.pErrInfo)) 670 662 { 671 663 cch = 0; … … 690 682 } 691 683 return 0; 692 }693 684 694 685 default: … … 717 708 const char *pszLastSep; 718 709 const char *psz = pszLastSep = va_arg(*pArgs, const char *); 719 if (!VALID_PTR(psz)) 720 return pfnOutput(pvArgOutput, RT_STR_TUPLE("<null>")); 710 if (!RT_VALID_PTR(psz)) 711 return rtStrFormatBadPointer(0, pfnOutput, pvArgOutput, cchWidth, fFlags, psz, 712 szBuf, RT_STR_TUPLE("!BadBaseName")); 721 713 722 714 while ((ch = *psz) != '\0') … … 813 805 int cAngle = 0; 814 806 815 if (!VALID_PTR(psz)) 816 return pfnOutput(pvArgOutput, RT_STR_TUPLE("<null>")); 807 if (!RT_VALID_PTR(psz)) 808 return rtStrFormatBadPointer(0, pfnOutput, pvArgOutput, cchWidth, fFlags, psz, 809 szBuf, RT_STR_TUPLE("!BadFnNm")); 817 810 818 811 while ((ch = *psz) != '\0' && ch != '(') … … 1343 1336 * If it's a pointer, we'll check if it's valid before going on. 1344 1337 */ 1345 if ((s_aTypes[i].fFlags & RTST_FLAGS_POINTER) && !VALID_PTR(u.pv)) 1346 return pfnOutput(pvArgOutput, RT_STR_TUPLE("<null>")); 1338 if ((s_aTypes[i].fFlags & RTST_FLAGS_POINTER) && !RT_VALID_PTR(u.pv)) 1339 return rtStrFormatBadPointer(0, pfnOutput, pvArgOutput, cchWidth, fFlags, u.pv, 1340 szBuf, RT_STR_TUPLE("!BadRD")); 1347 1341 1348 1342 /* … … 1389 1383 ssize_t offLast; 1390 1384 1391 if (! VALID_PTR(pszStr))1385 if (!RT_VALID_PTR(pszStr)) 1392 1386 pszStr = "<NULL>"; 1393 1387 cchStr = RTStrNLen(pszStr, (unsigned)cchPrecision); … … 1451 1445 ssize_t offLast; 1452 1446 1453 if (! VALID_PTR(pszStr))1447 if (!RT_VALID_PTR(pszStr)) 1454 1448 pszStr = "<NULL>"; 1455 1449 cchStr = RTStrNLen(pszStr, (unsigned)cchPrecision); … … 1533 1527 ("Invalid IPRT format type '%.10s'!\n", pszFormatOrg)); 1534 1528 1535 if (! VALID_PTR(pszStr))1529 if (!RT_VALID_PTR(pszStr)) 1536 1530 pszStr = "<NULL>"; 1537 1531 cchStr = RTStrNLen(pszStr, (unsigned)cchPrecision); -
trunk/src/VBox/Runtime/include/internal/string.h
r82968 r90821 51 51 #endif 52 52 53 DECLHIDDEN(size_t) rtStrFormatBadPointer(size_t cch, PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, int cchWidth, 54 unsigned fFlags, void const *pvStr, char szTmp[64], const char *pszTag, int cchTag); 53 55 DECLHIDDEN(size_t) rtstrFormatRt(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char **ppszFormat, va_list *pArgs, 54 56 int cchWidth, int cchPrecision, unsigned fFlags, char chArgSize);
Note:
See TracChangeset
for help on using the changeset viewer.