X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/3903760236c30e3b5ace7a4eefac3a269d68957c..a39ff7e25e19b3a8c3020042a3872ca9ec9659f1:/iokit/Kernel/IOHistogramReporter.cpp diff --git a/iokit/Kernel/IOHistogramReporter.cpp b/iokit/Kernel/IOHistogramReporter.cpp index 929a830f2..4c288ccdb 100644 --- a/iokit/Kernel/IOHistogramReporter.cpp +++ b/iokit/Kernel/IOHistogramReporter.cpp @@ -43,7 +43,7 @@ IOHistogramReporter::with(IOService *reportingService, IOReportCategories categories, uint64_t channelID, const char *channelName, - IOReportUnits unit, + IOReportUnit unit, int nSegments, IOHistogramSegmentConfig *config) { @@ -74,7 +74,7 @@ IOHistogramReporter::initWith(IOService *reportingService, IOReportCategories categories, uint64_t channelID, const OSSymbol *channelName, - IOReportUnits unit, + IOReportUnit unit, int nSegments, IOHistogramSegmentConfig *config) { @@ -272,34 +272,35 @@ IOHistogramReporter::free(void) IOReportLegendEntry* IOHistogramReporter::handleCreateLegend(void) { - OSData *tmpConfigData; - OSDictionary *tmpDict; - IOReportLegendEntry *legendEntry = NULL; + IOReportLegendEntry *rval = NULL, *legendEntry = NULL; + OSData *tmpConfigData = NULL; + OSDictionary *tmpDict; // no refcount legendEntry = super::handleCreateLegend(); + if (!legendEntry) goto finish; - if (legendEntry) { - - PREFL_MEMOP_PANIC(_segmentCount, IOHistogramSegmentConfig); - tmpConfigData = OSData::withBytes(_histogramSegmentsConfig, - (unsigned)_segmentCount * - (unsigned)sizeof(IOHistogramSegmentConfig)); - if (!tmpConfigData) { - legendEntry->release(); - goto finish; - } - - tmpDict = OSDynamicCast(OSDictionary, legendEntry->getObject(kIOReportLegendInfoKey)); - if (!tmpDict) { - legendEntry->release(); - goto finish; - } - - tmpDict->setObject(kIOReportLegendConfigKey, tmpConfigData); - } - + PREFL_MEMOP_PANIC(_segmentCount, IOHistogramSegmentConfig); + tmpConfigData = OSData::withBytes(_histogramSegmentsConfig, + (unsigned)_segmentCount * + sizeof(IOHistogramSegmentConfig)); + if (!tmpConfigData) goto finish; + + tmpDict = OSDynamicCast(OSDictionary, + legendEntry->getObject(kIOReportLegendInfoKey)); + if (!tmpDict) goto finish; + + tmpDict->setObject(kIOReportLegendConfigKey, tmpConfigData); + + // success + rval = legendEntry; + finish: - return legendEntry; + if (tmpConfigData) tmpConfigData->release(); + if (!rval && legendEntry) { + legendEntry->release(); + } + + return rval; } IOReturn