VirtualBox

Changeset 59436 in vbox


Ignore:
Timestamp:
Jan 22, 2016 1:58:58 PM (9 years ago)
Author:
vboxsync
Message:

iokit.cpp: Nits, try use IO_OBJECT_NULL.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/darwin/iokit.cpp

    r59374 r59436  
    4848#include <iprt/process.h>
    4949#include <iprt/assert.h>
     50#include <iprt/system.h>
    5051#include <iprt/thread.h>
    5152#include <iprt/uuid.h>
    52 #include <iprt/system.h>
    5353#ifdef STANDALONE_TESTCASE
    5454# include <iprt/initterm.h>
     
    8585#define VBOX_OSX_EL_CAPTIAN_VER 15
    8686
     87
    8788/*********************************************************************************************************************************
    8889*   Global Variables                                                                                                             *
     
    9192static mach_port_t g_MasterPort = NULL;
    9293/** Major darwin version as returned by uname -r. */
    93 uint32_t g_uMajorDarwin = 0;
     94static uint32_t g_uMajorDarwin = 0;
    9495
    9596
     
    107108
    108109        /* Get the darwin version we are running on. */
    109         char aszVersion[16] = { 0 };
    110         int rc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, &aszVersion[0], sizeof(aszVersion));
     110        char szVersion[64];
     111        int rc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, &szVersion[0], sizeof(szVersion));
    111112        if (RT_SUCCESS(rc))
    112113        {
    113             /* Make sure it is zero terminated (paranoia). */
    114             aszVersion[15] = '\0';
    115             rc = RTStrToUInt32Ex(&aszVersion[0], NULL, 10, &g_uMajorDarwin);
    116             if (   rc != VINF_SUCCESS
    117                 && rc != VWRN_TRAILING_CHARS)
    118                 LogRel(("IOKit: Failed to convert the major part of the version string \"%s\" into an integer\n", &aszVersion[0]));
     114            rc = RTStrToUInt32Ex(&szVersion[0], NULL, 10, &g_uMajorDarwin);
     115            AssertLogRelMsg(rc == VINF_SUCCESS || rc == VWRN_TRAILING_CHARS,
     116                            ("Failed to convert the major part of the version string '%s' into an integer: %Rrc\n",
     117                             szVersion, rc));
    119118        }
    120119        else
    121             LogRel(("IOKit: Failed to query the OS release version with %Rrc\n", rc));
     120            AssertLogRelMsgFailed(("Failed to query the OS release version with %Rrc\n", rc));
    122121    }
    123122    return true;
     
    498497    {
    499498        io_object_t Child;
    500         while ((Child = IOIteratorNext(Children)))
     499        while ((Child = IOIteratorNext(Children)) != IO_OBJECT_NULL)
    501500        {
    502501            darwinDumpObjInt(Child, cIndents + 4);
     
    555554{
    556555    io_object_t Object;
    557     while ((Object = IOIteratorNext(pIterator)))
     556    while ((Object = IOIteratorNext(pIterator)) != IO_OBJECT_NULL)
    558557    {
    559558        DARWIN_IOKIT_DUMP_OBJ(Object);
     
    730729        return NULL;
    731730    io_object_t Child;
    732     while ((Child = IOIteratorNext(Children)))
     731    while ((Child = IOIteratorNext(Children)) != IO_OBJECT_NULL)
    733732    {
    734733        krc = IOObjectGetClass(Child, pszNameBuf);
     
    788787}
    789788
     789
    790790/**
    791791 * Finds the matching IOUSBHostDevice registry entry for the given legacy USB device interface (IOUSBDevice).
     
    825825     */
    826826    io_object_t USBDevice;
    827     while ((USBDevice = IOIteratorNext(USBDevices)) != 0)
     827    while ((USBDevice = IOIteratorNext(USBDevices)) != IO_OBJECT_NULL)
    828828    {
    829829        DARWIN_IOKIT_DUMP_OBJ(USBDevice);
     
    851851}
    852852
     853
    853854static bool darwinUSBDeviceIsGrabbedDetermineState(PUSBDEVICE pCur, io_object_t USBDevice)
    854855{
     
    866867    RTPROCESS Client = NIL_RTPROCESS;
    867868    io_object_t Interface;
    868     while ((Interface = IOIteratorNext(Interfaces)) != 0)
     869    while ((Interface = IOIteratorNext(Interfaces)) != IO_OBJECT_NULL)
    869870    {
    870871        io_name_t szName;
     
    903904}
    904905
     906
    905907/**
    906908 * Worker for determining the USB device state for devices which are not captured by the VBoxUSB driver
     
    926928    bool fSeizable = true;
    927929    io_object_t Interface;
    928     while ((Interface = IOIteratorNext(Interfaces)) != 0)
     930    while ((Interface = IOIteratorNext(Interfaces)) != IO_OBJECT_NULL)
    929931    {
    930932        io_name_t szName;
     
    945947            {
    946948                io_object_t Child1;
    947                 while ((Child1 = IOIteratorNext(Children1)) != 0)
     949                while ((Child1 = IOIteratorNext(Children1)) != IO_OBJECT_NULL)
    948950                {
    949951                    krc = IOObjectGetClass(Child1, szName);
     
    995997}
    996998
     999
    9971000/**
    9981001 * Worker function for DarwinGetUSBDevices() that tries to figure out
     
    10291032        if (g_uMajorDarwin >= VBOX_OSX_EL_CAPTIAN_VER)
    10301033        {
    1031             io_object_t IOUSBDeviceNew = 0;
    1032 
     1034            io_object_t IOUSBDeviceNew = IO_OBJECT_NULL;
    10331035            io_object_t krc = darwinGetUSBHostDeviceFromLegacyDevice(USBDevice, &IOUSBDeviceNew);
    10341036            if (   krc == KERN_SUCCESS
    1035                 && IOUSBDeviceNew != 0)
     1037                && IOUSBDeviceNew != IO_OBJECT_NULL)
    10361038            {
    10371039                darwinDetermineUSBDeviceStateWorker(pCur, IOUSBDeviceNew);
     
    10771079    unsigned i = 0;
    10781080    io_object_t USBDevice;
    1079     while ((USBDevice = IOIteratorNext(USBDevices)) != 0)
     1081    while ((USBDevice = IOIteratorNext(USBDevices)) != IO_OBJECT_NULL)
    10801082    {
    10811083        DARWIN_IOKIT_DUMP_OBJ(USBDevice);
     
    13351337    unsigned cMatches = 0;
    13361338    io_object_t USBDevice;
    1337     while ((USBDevice = IOIteratorNext(USBDevices)))
     1339    while ((USBDevice = IOIteratorNext(USBDevices)) != IO_OBJECT_NULL)
    13381340    {
    13391341        cMatches++;
     
    14771479    unsigned i = 0;
    14781480    io_object_t DVDService;
    1479     while ((DVDService = IOIteratorNext(DVDServices)) != 0)
     1481    while ((DVDService = IOIteratorNext(DVDServices)) != IO_OBJECT_NULL)
    14801482    {
    14811483        DARWIN_IOKIT_DUMP_OBJ(DVDService);
     
    16331635    PDARWINETHERNIC pTail = NULL;
    16341636    io_object_t EtherIfService;
    1635     while ((EtherIfService = IOIteratorNext(EtherIfServices)) != 0)
     1637    while ((EtherIfService = IOIteratorNext(EtherIfServices)) != IO_OBJECT_NULL)
    16361638    {
    16371639        /*
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