key_obj = CFStringCreateWithCString (kCFAllocatorDefault, key,
kCFStringEncodingASCII);
if (key_obj == NULL)
+ {
+ DBG ("CFStringCreateWithCString (%s) failed.", key);
return (-1LL);
+ }
/* get => we don't need to release (== free) the object */
val_obj = (CFNumberRef) CFDictionaryGetValue (dict, key_obj);
CFRelease (key_obj);
if (val_obj == NULL)
+ {
+ DBG ("CFDictionaryGetValue (%s) failed.", key);
return (-1LL);
+ }
- if (CFNumberGetValue (val_obj, kCFNumberSInt64Type, &val_int)
- != kIOReturnSuccess)
+ if (!CFNumberGetValue (val_obj, kCFNumberSInt64Type, &val_int))
+ {
+ DBG ("CFNumberGetValue (%s) failed.", key);
return (-1LL);
+ }
return (val_int);
}
CFDictionaryRef props_dict;
CFDictionaryRef stats_dict;
CFDictionaryRef child_dict;
+ kern_return_t status;
signed long long read_ops;
signed long long read_byt;
stats_dict = NULL;
child_dict = NULL;
+ /* `disk_child' must be released */
+ if ((status = IORegistryEntryGetChildEntry (disk, kIOServicePlane, &disk_child))
+ != kIOReturnSuccess)
+ {
+ /* This fails for example for DVD/CD drives.. */
+ DBG ("IORegistryEntryGetChildEntry (disk) failed: 0x%08x", status);
+ IOObjectRelease (disk);
+ continue;
+ }
+
/* We create `props_dict' => we need to release it later */
if (IORegistryEntryCreateCFProperties (disk,
(CFMutableDictionaryRef *) &props_dict,
!= kIOReturnSuccess)
{
syslog (LOG_ERR, "disk-plugin: IORegistryEntryCreateCFProperties failed.");
+ IOObjectRelease (disk_child);
IOObjectRelease (disk);
continue;
}
if (props_dict == NULL)
{
DBG ("IORegistryEntryCreateCFProperties (disk) failed.");
+ IOObjectRelease (disk_child);
IOObjectRelease (disk);
continue;
}
DBG ("CFDictionaryGetValue (%s) failed.",
kIOBlockStorageDriverStatisticsKey);
CFRelease (props_dict);
- IOObjectRelease (disk);
- continue;
- }
-
- /* `disk_child' must be released */
- if (IORegistryEntryGetChildEntry (disk, kIOServicePlane, &disk_child)
- != kIOReturnSuccess)
- {
- DBG ("IORegistryEntryGetChildEntry (disk) failed.");
- CFRelease (props_dict);
+ IOObjectRelease (disk_child);
IOObjectRelease (disk);
continue;
}
IOObjectRelease (disk);
continue;
}
+ DBG ("disk_name = %s", disk_name);
if ((read_ops != -1LL)
|| (read_byt != -1LL)