Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
Fix warnings found by Xcode analyzer.
Browse files Browse the repository at this point in the history
  • Loading branch information
ExtremeMan committed Sep 28, 2018
1 parent d2cf277 commit 8b4c4a8
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 61 deletions.
2 changes: 1 addition & 1 deletion Common/TaskUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void ReadOutputsAndFeedOuputLinesToBlockOnQueue(
};

size_t (^feedUnprocessedLinesToBlock)(int, dispatch_data_t, BOOL) = ^(int fd, dispatch_data_t unprocessedPart, BOOL forceUntilTheEnd) {
size_t processedSize;
size_t processedSize = 0;
NSArray *lines = LinesFromDispatchData(unprocessedPart, YES, forceUntilTheEnd, &processedSize);

for (NSString *lineToFeed in lines) {
Expand Down
2 changes: 1 addition & 1 deletion Common/XCToolUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
const char *template = [[directory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.XXXXXXX", prefix]] UTF8String];

char tempPath[PATH_MAX] = {0};
strcpy(tempPath, template);
strlcpy(tempPath, template, PATH_MAX);

int handle = mkstemp(tempPath);
NSCAssert(handle != -1, @"Failed to make temporary file name for template %s, error: %d", template, handle);
Expand Down
2 changes: 2 additions & 0 deletions otest-query/otest-query.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@
28660740183471FF000ACB87 /* otest-query-lib */,
CD9048FF1756C5B1006CF16D /* Products */,
);
indentWidth = 2;
sourceTree = "<group>";
tabWidth = 2;
};
CD9048FF1756C5B1006CF16D /* Products */ = {
isa = PBXGroup;
Expand Down
2 changes: 2 additions & 0 deletions otest-shim/otest-shim.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@
283CCA8E16C2EE4C00F2E343 /* Frameworks */,
283CCA8D16C2EE4C00F2E343 /* Products */,
);
indentWidth = 2;
sourceTree = "<group>";
tabWidth = 2;
};
283CCA8D16C2EE4C00F2E343 /* Products */ = {
isa = PBXGroup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ - (NSTextCheckingResult *)firstMatch:(NSArray *)prioritizedRegExString

@end

@interface JSONCompilationDatabaseReporter ()
@property (nonatomic, copy) NSMutableArray *compiles;
@property (nonatomic, copy) NSDictionary *currentBuildCommand;
@property (nonatomic, copy) NSMutableArray *precompiles;
@interface JSONCompilationDatabaseReporter () {
NSMutableArray *_compiles;
NSDictionary *_currentBuildCommand;
NSMutableArray *_precompiles;
}
@end

@implementation JSONCompilationDatabaseReporter
Expand Down
19 changes: 9 additions & 10 deletions reporters/junit/JUnitReporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@
#define kJUnitReporter_Suite_Results @"results"

#pragma mark Private Interface
@interface JUnitReporter ()

@property (nonatomic, copy) NSMutableArray *testSuites;
@property (nonatomic, copy) NSMutableArray *testResults;
@property (nonatomic, strong) NSDateFormatter *formatter;
@property (nonatomic, assign) int totalTests;
@property (nonatomic, assign) int totalFailures;
@property (nonatomic, assign) int totalErrors;
@property (nonatomic, assign) double totalTime;

@interface JUnitReporter () {
NSMutableArray *_testSuites;
NSMutableArray *_testResults;
NSDateFormatter *_formatter;
int _totalTests;
int _totalFailures;
int _totalErrors;
double _totalTime;
}
@end

#pragma mark Implementation
Expand Down
11 changes: 6 additions & 5 deletions reporters/phabricator/PhabricatorReporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

#import "ReporterEvents.h"

@interface PhabricatorReporter ()
@property (nonatomic, copy) NSDictionary *currentBuildCommand;
@property (nonatomic, copy) NSMutableArray *currentTargetFailures;
@property (nonatomic, copy) NSMutableArray *results;
@property (nonatomic, copy) NSString *scheme;
@interface PhabricatorReporter () {
NSDictionary *_currentBuildCommand;
NSMutableArray *_currentTargetFailures;
NSMutableArray *_results;
NSString *_scheme;
}
@end

@implementation PhabricatorReporter
Expand Down
2 changes: 2 additions & 0 deletions reporters/reporters.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,9 @@
2893A94E17960CD400EFBD28 /* Frameworks */,
2893A94D17960CD400EFBD28 /* Products */,
);
indentWidth = 2;
sourceTree = "<group>";
tabWidth = 2;
};
2893A94D17960CD400EFBD28 /* Products */ = {
isa = PBXGroup;
Expand Down
38 changes: 20 additions & 18 deletions reporters/text/TextReporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,22 @@ - (void)printLine:(NSString *)format, ... NS_FORMAT_FUNCTION(1, 2)

@end

@interface TextReporter ()
@property (nonatomic, assign) BOOL isPretty;
@property (nonatomic, assign) BOOL canOverwrite;
@property (nonatomic, strong) TestResultCounter *resultCounter;
@property (nonatomic, copy) NSDictionary *currentStatusEvent;
@property (nonatomic, copy) NSDictionary *currentBuildCommandEvent;
@property (nonatomic, assign) BOOL testHadOutput;
@property (nonatomic, assign) BOOL testOutputEndsInNewline;
@property (nonatomic, strong) ReportWriter *reportWriter;
@property (nonatomic, copy) NSMutableArray *failedTests;
@property (nonatomic, copy) NSString *currentBundle;
@property (nonatomic, copy) NSMutableArray *analyzerWarnings;
@property (nonatomic, copy) NSMutableArray *failedBuildEvents;
@property (nonatomic, copy) NSMutableArray *failedOcunitEvents;
@interface TextReporter () {
TestResultCounter *_resultCounter;
NSDictionary *_currentStatusEvent;
NSDictionary *_currentBuildCommandEvent;
BOOL _testHadOutput;
BOOL _testOutputEndsInNewline;
ReportWriter *_reportWriter;
NSMutableArray *_failedTests;
NSString *_currentBundle;
NSMutableArray *_analyzerWarnings;
NSMutableArray *_failedBuildEvents;
NSMutableArray *_failedOcunitEvents;
@protected
BOOL _isPretty;
BOOL _canOverwrite;
}
@end

@implementation TextReporter
Expand Down Expand Up @@ -919,8 +921,8 @@ @implementation PrettyTextReporter
- (instancetype)init
{
if (self = [super init]) {
self.isPretty = YES;
self.canOverwrite = YES;
_isPretty = YES;
_canOverwrite = YES;
}
return self;
}
Expand All @@ -932,7 +934,7 @@ @implementation NoOverwritePrettyTextReporter
- (instancetype)init
{
if (self = [super init]) {
self.isPretty = YES;
_isPretty = YES;
}
return self;
}
Expand All @@ -944,7 +946,7 @@ @implementation PlainTextReporter
- (instancetype)init
{
if (self = [super init]) {
self.isPretty = NO;
_isPretty = NO;
}
return self;
}
Expand Down
2 changes: 2 additions & 0 deletions xcodebuild-shim/xcodebuild-shim.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@
287A381016C876A800319E81 /* xcodebuild-fastsettings-shim */,
283CCAB216C2EE7200F2E343 /* xcodebuild-shim */,
);
indentWidth = 2;
sourceTree = "<group>";
tabWidth = 2;
};
283CCAAA16C2EE7200F2E343 /* Products */ = {
isa = PBXGroup;
Expand Down
11 changes: 6 additions & 5 deletions xctool/xctool-tests/FakeTaskManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ static id NSTask_allocWithZone(id cls, SEL sel, NSZone *zone)
(IMP)NSTask_allocWithZone);
}

@interface FakeTaskManager ()
@property (nonatomic, copy) NSMutableArray *launchedTasks;
@property (nonatomic, copy) NSMutableArray *launchedTasksToBeHidden;
@property (nonatomic, copy) NSMutableArray *launchHandlerBlocks;
@property (nonatomic, assign) BOOL fakeTasksAreEnabled;
@interface FakeTaskManager () {
NSMutableArray *_launchedTasks;
NSMutableArray *_launchedTasksToBeHidden;
NSMutableArray *_launchHandlerBlocks;
BOOL _fakeTasksAreEnabled;
}
@end

@implementation FakeTaskManager
Expand Down
9 changes: 5 additions & 4 deletions xctool/xctool/EventBuffer.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

#import "XCToolUtil.h"

@interface EventBuffer ()
@property (nonatomic, strong) id<EventSink> underlyingSink;
@property (nonatomic, copy) NSMutableArray *bufferedEventData;
@interface EventBuffer () {
id<EventSink> _underlyingSink;
NSMutableArray *_bufferedEventData;
}
@end

@implementation EventBuffer
Expand All @@ -37,7 +38,7 @@ + (NSArray *)wrapSinks:(NSArray *)sinks
+ (instancetype)eventBufferForSink:(id<EventSink>)reporter
{
EventBuffer *obj = [[EventBuffer alloc] init];
obj.underlyingSink = reporter;
obj->_underlyingSink = reporter;
return obj;
}

Expand Down
11 changes: 5 additions & 6 deletions xctool/xctool/OCTestEventState.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
#import "EventGenerator.h"
#import "ReporterEvents.h"

@interface OCTestEventState ()

@property (nonatomic, assign) CFTimeInterval beginTime;
@property (nonatomic, copy) NSMutableString *outputToPublish;
@property (nonatomic, copy) NSMutableString *outputAlreadyPublished;

@interface OCTestEventState () {
CFTimeInterval _beginTime;
NSMutableString *_outputToPublish;
NSMutableString *_outputAlreadyPublished;
}
@end

@implementation OCTestEventState
Expand Down
8 changes: 4 additions & 4 deletions xctool/xctool/SchemeGenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

#import "XCToolUtil.h"

@interface SchemeGenerator ()
@property (nonatomic, copy) NSMutableArray *buildables;
@property (nonatomic, copy) NSMutableSet *projectPaths;

@interface SchemeGenerator () {
NSMutableArray *_buildables;
NSMutableSet *_projectPaths;
}
@end

@implementation SchemeGenerator {
Expand Down
4 changes: 3 additions & 1 deletion xctool/xctool/SimulatorWrapper/SimulatorWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ + (BOOL)runHostAppTests:(NSString *)testHostBundleID
}];
}
if (appPID == -1) {
*error = launchError;
if (error != nil) {
*error = launchError;
}
ReportStatusMessageEnd(reporters,
REPORTER_MESSAGE_INFO,
@"Failed to launch '%@' on '%@': %@",
Expand Down
5 changes: 3 additions & 2 deletions xctool/xctool/TestRunState.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
#import "ReporterEvents.h"
#import "XCToolUtil.h"

@interface TestRunState ()
@interface TestRunState () {
NSMutableString *_outputBeforeTestsStart;
}
@property (nonatomic, strong) OCTestSuiteEventState *testSuiteState;
@property (nonatomic, strong) OCTestEventState *previousTestState;
@property (nonatomic, copy) NSSet *crashReportsAtStart;
@property (nonatomic, copy) NSMutableString *outputBeforeTestsStart;
@end

@implementation TestRunState
Expand Down

0 comments on commit 8b4c4a8

Please sign in to comment.