VirtualBox

Changeset 24898 in vbox for trunk/src


Ignore:
Timestamp:
Nov 24, 2009 12:45:15 PM (15 years ago)
Author:
vboxsync
Message:

VbglR3: Make use of improved RTStrVersionCompare().

File:
1 edited

Legend:

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

    r24660 r24898  
    3434
    3535#include "VBGLR3Internal.h"
    36 
    37 /**
    38  * Compares two VirtualBox version strings and returns the result.
    39  *
    40  * Requires strings in form of "majorVer.minorVer.build".
    41  *
    42  * @returns 0 if equal, 1 if Ver1 is greater, 2 if Ver2 is greater.
    43  *
    44  * @param   pszVer1     First version string to compare.
    45  * @param   pszVer2     First version string to compare.
    46  *
    47  * @todo Move this to IPRT and add support for more dots, suffixes and whatnot.
    48  */
    49 VBGLR3DECL(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;
    66     return rc;
    67 }
    68 
    6936
    7037/**
     
    166133    if (RT_SUCCESS(rc) && *pfUpdate)
    167134    {
    168         if (VbglR3HostVersionCompare(*ppszHostVersion, *ppszGuestVersion) == 1) /* Is host version greater than guest add version? */
     135        uint8_t u8Res;
     136        rc = RTStrVersionCompare(*ppszHostVersion, *ppszGuestVersion, &u8Res);
     137        if (RT_FAILURE(rc))
     138            LogFlow(("Error while comparing host versions! %s <-> %s, rc = %Rrc\n",
     139                *ppszHostVersion, *ppszGuestVersion, rc));
     140
     141        if (u8Res == 1) /* Is host version greater than guest add version? */
    169142        {
    170143            /* 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