Merge pull request #1425 from mapbox/1ec5-analyzer

Fixes for static analyzer warnings
This commit is contained in:
Minh Nguyễn
2015-05-06 14:34:28 -07:00
4 changed files with 7 additions and 29 deletions

View File

@@ -153,7 +153,7 @@ void HTTPRequest::start() {
@autoreleasepool {
NSMutableString *url = [[NSMutableString alloc] initWithString:@(resource.url.c_str())];
NSMutableString *url = [NSMutableString stringWithString:@(resource.url.c_str())];
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"mapbox_metrics_disabled"] == nil) {
if ([url rangeOfString:@"?"].location == NSNotFound) {
[url appendString:@"?"];
@@ -163,8 +163,7 @@ void HTTPRequest::start() {
[url appendString:@"events=true"];
}
NSMutableURLRequest *req = [[NSMutableURLRequest alloc]
initWithURL:[NSURL URLWithString:url]];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
if (existingResponse) {
if (!existingResponse->etag.empty()) {
[req addValue:@(existingResponse->etag.c_str()) forHTTPHeaderField:@"If-None-Match"];
@@ -179,7 +178,6 @@ void HTTPRequest::start() {
task = [context->session dataTaskWithRequest:req
completionHandler:^(NSData *data, NSURLResponse *res,
NSError *error) { handleResult(data, res, error); }];
[req release];
[task retain];
[task resume];
}

View File

@@ -1079,22 +1079,19 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
{
CGPoint doubleTapPoint = [doubleTap locationInView:doubleTap.view];
CGPoint zoomInPoint;
CGPoint zoomInPoint = doubleTapPoint;
CGPoint userPoint = [self convertCoordinate:self.userLocation.coordinate toPointToView:self];
if (self.userTrackingMode != MGLUserTrackingModeNone)
{
CGPoint userPoint = [self convertCoordinate:self.userLocation.coordinate toPointToView:self];
CGRect userLocationRect = CGRectMake(userPoint.x - 40, userPoint.y - 40, 80, 80);
if (CGRectContainsPoint(userLocationRect, doubleTapPoint))
{
zoomInPoint = userPoint;
}
}
else
if ( ! CGPointEqualToPoint(zoomInPoint, userPoint))
{
self.userTrackingMode = MGLUserTrackingModeNone;
zoomInPoint = doubleTapPoint;
}
_mbglMap->scaleBy(2, zoomInPoint.x, zoomInPoint.y, secondsAsDuration(MGLAnimationDuration));

View File

@@ -617,10 +617,11 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
NSString *ssid = nil;
CFArrayRef interfaces = CNCopySupportedInterfaces();
if (interfaces) {
NSDictionary *info = (__bridge NSDictionary *)CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(interfaces, 0));
NSDictionary *info = CFBridgingRelease(CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(interfaces, 0)));
if (info) {
ssid = info[@"SSID"];
}
CFRelease(interfaces);
}
return ssid;
@@ -699,7 +700,6 @@ NSString *const MGLEventGestureRotateStart = @"Rotation";
if([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
SecTrustRef serverTrust = [[challenge protectionSpace] serverTrust];
NSString *domain = [[challenge protectionSpace] host];
SecTrustResultType trustResult;
// Validate the certificate chain with the device's trust store anyway

View File

@@ -89,34 +89,17 @@
}
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
NSString *newStatus = nil;
switch (status) {
case kCLAuthorizationStatusNotDetermined:
newStatus = @"User Hasn't Determined Yet";
break;
case kCLAuthorizationStatusRestricted:
newStatus = @"Restricted and Can't Be Changed By User";
break;
case kCLAuthorizationStatusDenied:
newStatus = @"User Explcitly Denied";
[self stopUpdatingLocation];
[self stopMonitoringVisits];
break;
case kCLAuthorizationStatusAuthorized:
newStatus = @"User Has Authorized / Authorized Always";
[self startUpdatingLocation];
[self startMonitoringVisits];
break;
// case kCLAuthorizationStatusAuthorizedAlways:
// newStatus = @"Not Determined";
// break;
case kCLAuthorizationStatusAuthorizedWhenInUse:
newStatus = @"User Has Authorized When In Use Only";
[self startUpdatingLocation];
[self startMonitoringVisits];
break;
default:
newStatus = @"Unknown";
break;
}
}