Fix unused variable warnings

Remove some unused variables and add unused attribute to other variables

PiperOrigin-RevId: 481706551
This commit is contained in:
MediaPipe Team 2022-10-17 12:13:09 -07:00 committed by Copybara-Service
parent f6c2f86086
commit 5e543c506f
4 changed files with 10 additions and 19 deletions

View File

@ -244,7 +244,7 @@
if ([_session canAddOutput:_depthDataOutput]) {
[_session addOutput:_depthDataOutput];
AVCaptureConnection* connection =
AVCaptureConnection* __unused connection =
[_depthDataOutput connectionWithMediaType:AVMediaTypeDepthData];
// Set this when we have a handler.
@ -327,7 +327,6 @@
if (depthData.depthDataType != kCVPixelFormatType_DepthFloat32) {
depthData = [depthData depthDataByConvertingToDepthDataType:kCVPixelFormatType_DepthFloat32];
}
CVPixelBufferRef depthBuffer = depthData.depthDataMap;
[self.delegate processDepthData:depthData timestamp:timestamp fromSource:self];
}

View File

@ -134,12 +134,12 @@ void CallFrameDelegate(void* wrapperVoid, const std::string& streamName,
if (format == mediapipe::ImageFormat::SRGBA) {
// Swap R and B channels.
const uint8_t permuteMap[4] = {2, 1, 0, 3};
vImage_Error vError = vImagePermuteChannels_ARGB8888(
&vSource, &vDestination, permuteMap, kvImageNoFlags);
vImage_Error __unused vError =
vImagePermuteChannels_ARGB8888(&vSource, &vDestination, permuteMap, kvImageNoFlags);
_GTMDevAssert(vError == kvImageNoError, @"vImagePermuteChannels failed: %zd", vError);
} else {
// Convert grayscale back to BGRA
vImage_Error vError = vImageGrayToBGRA(&vSource, &vDestination);
vImage_Error __unused vError = vImageGrayToBGRA(&vSource, &vDestination);
_GTMDevAssert(vError == kvImageNoError, @"vImageGrayToBGRA failed: %zd", vError);
}

View File

@ -32,7 +32,8 @@ static UIImage* UIImageWithPixelBuffer(CVPixelBufferRef pixelBuffer) {
static void EnsureOutputDirFor(NSString *outputFile) {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;
BOOL result = [fileManager createDirectoryAtPath:[outputFile stringByDeletingLastPathComponent]
BOOL __unused result =
[fileManager createDirectoryAtPath:[outputFile stringByDeletingLastPathComponent]
withIntermediateDirectories:YES
attributes:nil
error:&error];
@ -89,17 +90,10 @@ static void EnsureOutputDirFor(NSString *outputFile) {
__block CVPixelBufferRef output;
graph.delegate = self;
// The XCTAssert macros contain references to self, which causes a retain cycle,
// since the block retains self and self retains the block. The cycle is broken
// at the end of this method, with _pixelBufferOutputBlock = nil, but Clang does
// not realize that and outputs a warning. WEAKIFY and STRONGIFY, though not
// strictly necessary, are used here to avoid the warning.
WEAKIFY(self);
if (!_pixelBufferOutputBlock) {
XCTestExpectation* outputReceived = [self expectationWithDescription:@"output received"];
_pixelBufferOutputBlock = ^(MPPGraph* outputGraph, CVPixelBufferRef outputBuffer,
const std::string& outputStreamName) {
STRONGIFY(self);
XCTAssertEqualObjects(outputGraph, graph);
XCTAssertEqual(outputStreamName, outputStream);
CFRetain(outputBuffer);

View File

@ -287,9 +287,7 @@ REGISTER_CALCULATOR(ErrorCalculator);
CFHolder<CVPixelBufferRef> inputBuffer;
absl::Status status = CreateCVPixelBufferFromCGImage(_sourceImage.CGImage, &inputBuffer);
XCTAssert(status.ok());
CVPixelBufferRef outputBuffer = [self runGraph:_graph
withPixelBuffer:*inputBuffer
packetType:MPPPacketTypePixelBuffer];
[self runGraph:_graph withPixelBuffer:*inputBuffer packetType:MPPPacketTypePixelBuffer];
__weak MPPGraph* weakGraph = _graph;
_graph = nil;
XCTAssertNil(weakGraph);