-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix miscellaneous static analyzer warnings #7670
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ - (instancetype)initWithIdentifier:(NSString *)identifier tileURLTemplates:(NS_A | |
if (self = [super initWithIdentifier:identifier tileURLTemplates:tileURLTemplates options:options]) { | ||
mbgl::Tileset tileSet = MGLTileSetFromTileURLTemplates(tileURLTemplates, options); | ||
|
||
uint16_t tileSize; | ||
uint16_t tileSize = MGLRasterSourceRetinaTileSize; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had somehow forgotten that primitive-typed stack variables are uninitialized in Objective-C just as they are in C. ARC nils out only object pointers on the stack. |
||
if (NSNumber *tileSizeNumber = options[MGLTileSourceOptionTileSize]) { | ||
if (![tileSizeNumber isKindOfClass:[NSNumber class]]) { | ||
[NSException raise:NSInvalidArgumentException | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,9 +94,7 @@ - (BOOL)isEqual:(id)other | |
|
||
- (NSUInteger)hash | ||
{ | ||
NSUInteger hash; | ||
hash += _title.hash; | ||
hash += _subtitle.hash; | ||
NSUInteger hash = _title.hash + _subtitle.hash; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a safe way to compute the hash? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A XOR over the values could improve it but I'm ok with it because this is an abstract class and can't be used directly. All concrete subclasses include the hash of the GeoJSON dictionary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a fairly conventional implementation, as far as I know. The only hard requirement for a |
||
#if !TARGET_OS_IPHONE | ||
hash += _toolTip.hash; | ||
#endif | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,15 +57,11 @@ - (BOOL)isEqual:(id)other { | |
|
||
return ((!_reuseIdentifier && !otherAnnotationImage.reuseIdentifier) || [_reuseIdentifier isEqualToString:otherAnnotationImage.reuseIdentifier]) | ||
&& _enabled == otherAnnotationImage.enabled | ||
&& ((!_image && !otherAnnotationImage.image) || [UIImagePNGRepresentation(_image) isEqualToData:UIImagePNGRepresentation(otherAnnotationImage.image)]); | ||
&& ((!_image && !otherAnnotationImage.image) || [_image isEqual:otherAnnotationImage.image]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @frederoni, any reason why comparing two UIImages for object equality isn’t good enough? (There’s a similar comparison of NSImages’ TIFF representations on the macOS side.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that Edit: I misread the test. Looks like it’s doing something pretty ordinary. |
||
} | ||
|
||
- (NSUInteger)hash { | ||
NSUInteger hash; | ||
hash += [_reuseIdentifier hash]; | ||
hash += _enabled; | ||
hash += [_image hash]; | ||
return hash; | ||
return _reuseIdentifier.hash + _enabled + _image.hash; | ||
} | ||
|
||
- (void)setImage:(UIImage *)image { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+[MGLAccountManager sharedManager]
bails in IB because MGLAccountManager spins up lots of other machinery, including MGLMapboxEvents. MGLNetworkConfiguration is intentionally isolated from anything else, so initializing the singleton within IB is no big deal.