Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some static analysis warnings #1958

Closed
wants to merge 1 commit into from
Closed

Fix some static analysis warnings #1958

wants to merge 1 commit into from

Conversation

ZevEisenberg
Copy link
Contributor

Didn't fix all of them, just a couple that were easy.

@@ -65,7 +65,7 @@ ASInterfaceState ASInterfaceStateForDisplayNode(ASDisplayNode *displayNode, UIWi
// if not already, about to be set to invisible as it is not possible for an element to be visible
// while outside of a window.
ASInterfaceState interfaceState = displayNode.pendingInterfaceState;
return (window == nil ? (interfaceState &= (~ASInterfaceStateVisible)) : interfaceState);
return (window == nil ? (interfaceState & (~ASInterfaceStateVisible)) : interfaceState);
Copy link
Contributor

Choose a reason for hiding this comment

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

while Xcode may flag this, I think the comment above indicates its intentional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't believe it is intentional. The stuff about directly clearing the interface bit would be satisfied by interfaceState & (~ASInterfaceStateVisible). The &= is also leaving interfaceState different after the expression is run, but it doesn't matter because interfaceState is never used again. This code is only working because &= also returns the value of the newly mutated variable. You couldn't write this code in Swift, because I believe &= doesn't return anything by default.

Copy link
Contributor

Choose a reason for hiding this comment

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

regardless, since I have no idea, but that seems more in-depth thinking is required than the other one. I think splitting this PR up is best.

For this change, I think I'd want unit tests that ensure the existing behavior persists. I've no idea how much work that would be w/o an expert weighing in on this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened a new PR for this. If you still want a unit test after reading my description, I'm happy to add one :)

@@ -2385,7 +2385,7 @@ static void ASTextDrawRun(ASTextLine *line, CTRunRef run, CGContextRef context,
if (mode) { // CJK glyph, need rotated
CGFloat ofs = (ascent - descent) * 0.5;
CGFloat w = glyphAdvances[g].width * 0.5;
CGFloat x = x = line.position.x + verticalOffset + glyphPositions[g].y + (ofs - w);
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems good. small diffs are terrific. Would you mind splitting this up? Thanks.

@ZevEisenberg
Copy link
Contributor Author

Closing in favor of #1960 and #1961

@ZevEisenberg ZevEisenberg deleted the chore/zeveisenberg/fix-some-static-analysis-warnings branch January 29, 2021 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants