From 581fb3849da8ce97e557bb3633b886fcc369f6cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Wed, 11 Jan 2017 03:08:05 -0800 Subject: [ios, macos] Fix miscellaneous static analyzer warnings (#7670) * [ios, macos] Fixed static analyzer warnings Fixed static analyzer warnings in MGLNetworkConfiguration, MGLRasterSource, and MGLShape. * [ios] Fixed static analyzer warnings Fixed static analyzer warnings in MGLAnnotationImage. * [macos] Fixed static analyzer warnings Fixed static analyzer warnings in MGLAnnotationImage and NSImage(MGLAdditions). * [ios, macos] Two pointer-equal images are object-equal by definition --- platform/macos/src/MGLAnnotationImage.m | 8 ++------ platform/macos/src/NSImage+MGLAdditions.mm | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'platform/macos/src') diff --git a/platform/macos/src/MGLAnnotationImage.m b/platform/macos/src/MGLAnnotationImage.m index f9f900344a..d19dbe5dfc 100644 --- a/platform/macos/src/MGLAnnotationImage.m +++ b/platform/macos/src/MGLAnnotationImage.m @@ -53,15 +53,11 @@ return ((!_reuseIdentifier && !otherAnnotationImage.reuseIdentifier) || [_reuseIdentifier isEqualToString:otherAnnotationImage.reuseIdentifier]) && _selectable == otherAnnotationImage.selectable && ((!_cursor && !otherAnnotationImage.cursor) || [_cursor isEqual:otherAnnotationImage.cursor]) - && ((!_image && !otherAnnotationImage.image) || [[_image TIFFRepresentation] isEqualToData:[otherAnnotationImage.image TIFFRepresentation]]); + && (_image == otherAnnotationImage.image || [[_image TIFFRepresentation] isEqualToData:[otherAnnotationImage.image TIFFRepresentation]]); } - (NSUInteger)hash { - NSUInteger hash; - hash += [_reuseIdentifier hash]; - hash += _selectable; - hash += [_image hash]; - return hash; + return _reuseIdentifier.hash + @(_selectable).hash + _image.hash; } @end diff --git a/platform/macos/src/NSImage+MGLAdditions.mm b/platform/macos/src/NSImage+MGLAdditions.mm index 9036ab24ae..e8e84f0a03 100644 --- a/platform/macos/src/NSImage+MGLAdditions.mm +++ b/platform/macos/src/NSImage+MGLAdditions.mm @@ -6,7 +6,7 @@ std::string png = encodePNG(spriteImage->image); NSData *data = [[NSData alloc] initWithBytes:png.data() length:png.size()]; NSBitmapImageRep *rep = [NSBitmapImageRep imageRepWithData:data]; - if ([self initWithSize:NSMakeSize(spriteImage->getWidth(), spriteImage->getHeight())]) { + if (self = [self initWithSize:NSMakeSize(spriteImage->getWidth(), spriteImage->getHeight())]) { [self addRepresentation:rep]; [self setTemplate:spriteImage->sdf]; } -- cgit v1.2.1