Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Fix static analyzer warnings - #3006

Merged
1ec5 merged 5 commits into
masterfrom
1ec5-analyzer-2
Nov 12, 2015
Merged

1ec5 merged 5 commits into
masterfrom
1ec5-analyzer-2

Conversation

@1ec5

@1ec5 1ec5 commented Nov 11, 2015

Copy link
Copy Markdown
Contributor

This PR fixes the following static analyzer warnings introduced by 5a24ac6 for #2994 and 4d5c633 for #2727:

/path/to/mapbox-gl-native/src/mbgl/storage/default_file_source.cpp
/path/to/mapbox-gl-native/src/mbgl/storage/default_file_source.cpp:328:29: The result of the '<<' expression is undefined
/path/to/mapbox-gl-native/src/mbgl/storage/default_file_source.cpp:328:29: The result of the '<<' expression is undefined
/path/to/mapbox-gl-native/src/mbgl/storage/default_file_source.cpp:333:25: The result of the '<<' expression is undefined
/path/to/mapbox-gl-native/src/mbgl/storage/default_file_source.cpp:333:25: The result of the '<<' expression is undefined
/path/to/mapbox-gl-native/src/mbgl/map/transform.cpp
/path/to/mapbox-gl-native/src/mbgl/map/transform.cpp:328:9: Value stored to 'center_x' is never read
/path/to/mapbox-gl-native/src/mbgl/map/transform.cpp:328:9: Value stored to 'center_x' is never read
/path/to/mapbox-gl-native/src/mbgl/map/transform.cpp:329:9: Value stored to 'center_y' is never read
/path/to/mapbox-gl-native/src/mbgl/map/transform.cpp:329:9: Value stored to 'center_y' is never read

More details in the commit messages.

/cc @brunoabinader @kkaefer

@1ec5 1ec5 added the bug label Nov 11, 2015
@1ec5 1ec5 self-assigned this Nov 11, 2015
@1ec5 1ec5 added this to the ios-v3.0.0 milestone Nov 11, 2015
Comment thread src/mbgl/map/transform.cpp Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simply reverted this method to before the refactoring and applied the minimal number of changes required by the new parameters. The refactoring had turned the if statement above here into a no-op, and I’m not sure beginning_center_dist was still correct.

@brunoabinader

Copy link
Copy Markdown
Contributor

@1ec5 I spent some time checking on this and took liberty to add 2 more patches here - one that makes PrecisionPoint inherit from vec2<> so we can take advantage of its operator impls, and other that cleans up Transform::rotateBy preserving the same behavior as before my changes.

@brunoabinader
brunoabinader force-pushed the 1ec5-analyzer-2 branch 3 times, most recently from fe6e94c to b2f8c17 Compare November 12, 2015 16:22
1ec5 and others added 5 commits November 12, 2015 10:46
Corrected Transform::_setScale() after the refactoring in 5a24ac6 for #2994. This change also addresses two dead store warnings from the static analyzer.
This change fixes a bug introduced in 4d5c633 for #2727. 1 << 32 would exceed the size of int64_t. The static analyzer reported undefined behavior here because std::min() might or might not return 32.
We could reuse all the operators defined in vec2<>, including operator
bool() that checks if the contained values are !NaN.
Make use of PrecisionPoint's operator functionalities inherited from
vec2<> and reduced overhead eg. offset_y is always 0 so no need to add
this to calculation inside the if.
Also renamed secondsAsDuration() to durationInSeconds(): function names should generally put the return type first, the argument type last, to avoid confusion.
@1ec5
1ec5 merged commit 48d1c40 into master Nov 12, 2015
@1ec5 1ec5 removed the in progress label Nov 12, 2015
@1ec5
1ec5 deleted the 1ec5-analyzer-2 branch November 12, 2015 19:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants