VirtualBox

Ignore:
Timestamp:
Nov 14, 2009 11:37:03 PM (15 years ago)
Author:
vboxsync
Message:

VBoxGuestLib: Backed out 54807 and 54806 because the code doesn't work. See comments attached to RTStrVersionToUInt32.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibHostVersion.cpp

    r24643 r24660  
    4040 * Requires strings in form of "majorVer.minorVer.build".
    4141 *
    42  * @returns iprt status code.
     42 * @returns 0 if equal, 1 if Ver1 is greater, 2 if Ver2 is greater.
    4343 *
    4444 * @param   pszVer1     First version string to compare.
    4545 * @param   pszVer2     First version string to compare.
    46  * @param   uint8_t     Pointer to comparison result:
    47  *                      0 if equal, 1 if Ver1 is greater, 2 if Ver2 is greater.
    48  *
    49  * @todo Move this to IPRT - where?
    50  */
    51 VBGLR3DECL(int) VbglR3HostVersionCompare(const char *pszVer1, const char *pszVer2, uint8_t *puRes)
    52 {
    53     uint32_t u32Ver1;
    54     uint32_t u32Ver2;
    55 
    56     AssertPtr(puRes);
    57     int rc = RTStrVersionToUInt32(pszVer1, &u32Ver1);
    58     if (RT_SUCCESS(rc))
    59         rc = RTStrVersionToUInt32(pszVer2, &u32Ver2);
    60 
    61     *puRes = 0;
    62     if (RT_SUCCESS(rc))
    63     {
    64         if (u32Ver1 > u32Ver2)
    65             *puRes = 1;
    66         else if (u32Ver2 > u32Ver1)
    67             *puRes = 2;
    68     }
     46 *
     47 * @todo Move this to IPRT and add support for more dots, suffixes and whatnot.
     48 */
     49VBGLR3DECL(int) VbglR3HostVersionCompare(const char *pszVer1, const char *pszVer2)
     50{
     51    /** @todo r=bird: not checking the return code, may be using uninitialized
     52     *        variables... I'll fix this when moving into the runtime.  */
     53    int iVer1Major, iVer1Minor, iVer1Build;
     54    sscanf(pszVer1, "%d.%d.%d", &iVer1Major, &iVer1Minor, &iVer1Build);
     55    int iVer2Major, iVer2Minor, iVer2Build;
     56    sscanf(pszVer2, "%d.%d.%d", &iVer2Major, &iVer2Minor, &iVer2Build);
     57
     58    int iVer1Final = (iVer1Major * 10000) + (iVer1Minor * 100) + iVer1Build;
     59    int iVer2Final = (iVer2Major * 10000) + (iVer2Minor * 100) + iVer2Build;
     60
     61    int rc = 0;
     62    if (iVer1Final > iVer2Final)
     63        rc = 1;
     64    else if (iVer2Final > iVer1Final)
     65        rc = 2;
    6966    return rc;
    7067}
     
    169166    if (RT_SUCCESS(rc) && *pfUpdate)
    170167    {
    171         uint8_t u8Res;
    172         rc = VbglR3HostVersionCompare(*ppszHostVersion, *ppszGuestVersion, &u8Res);
    173         if (RT_SUCCESS(rc) && u8Res == 1) /* Is host version greater than guest add version? */
     168        if (VbglR3HostVersionCompare(*ppszHostVersion, *ppszGuestVersion) == 1) /* Is host version greater than guest add version? */
    174169        {
    175170            /* Yay, we have an update! */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette