Skip to content

Commit

Permalink
Fix warning on unused return values in RCTSRWebSocket
Browse files Browse the repository at this point in the history
Summary:
Assert that the return value of these methods is sane.

Closes #8108

Reviewed By: majak

Differential Revision: D3722629

fbshipit-source-id: 2a67daae6dc380721e5dad27acd2ab67f71d0c6c
  • Loading branch information
javache authored and Facebook Github Bot 0 committed Aug 16, 2016
1 parent 1199c5a commit 2f78852
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Libraries/LinkingIOS/RCTLinking.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
WARNING_CFLAGS = (
"-Werror",
"-Wall",
);
};
name = Debug;
};
Expand Down Expand Up @@ -192,6 +196,10 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
WARNING_CFLAGS = (
"-Werror",
"-Wall",
);
};
name = Release;
};
Expand Down
6 changes: 4 additions & 2 deletions Libraries/WebSocket/RCTSRWebSocket.m
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,8 @@ - (void)didConnect
CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Host"), (__bridge CFStringRef)(_url.port ? [NSString stringWithFormat:@"%@:%@", _url.host, _url.port] : _url.host));

NSMutableData *keyBytes = [[NSMutableData alloc] initWithLength:16];
SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyBytes.mutableBytes);
int result = SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyBytes.mutableBytes);
assert(result == 0);
_secKey = [keyBytes base64EncodedStringWithOptions:0];
assert([_secKey length] == 24);

Expand Down Expand Up @@ -1331,7 +1332,8 @@ - (void)_sendFrameWithOpcode:(RCTSROpCode)opcode data:(id)data;
}
} else {
uint8_t *mask_key = frame_buffer + frame_buffer_size;
SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);
int result = SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);
assert(result == 0);
frame_buffer_size += sizeof(uint32_t);

// TODO: could probably optimize this with SIMD
Expand Down

4 comments on commit 2f78852

@rclai
Copy link
Contributor

@rclai rclai commented on 2f78852 Sep 22, 2016

Choose a reason for hiding this comment

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

@javache, this fixes the issue, but it seems to have caused the development logs to get noisy? I don't know if this is an Xcode 8 issue or this commit's side-effect.

@javache
Copy link
Member Author

@javache javache commented on 2f78852 Oct 5, 2016

Choose a reason for hiding this comment

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

I think it's a known Xcode problem: you can disable it through an environment variable: http://stackoverflow.com/questions/39585796/disable-extra-information-from-the-xcode-8-console

@rclai
Copy link
Contributor

@rclai rclai commented on 2f78852 Oct 5, 2016

Choose a reason for hiding this comment

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

I made a PR that will bootstrap new projects using that setting, I don't know if you guys looked at that yet?

@karna41317
Copy link

@karna41317 karna41317 commented on 2f78852 Oct 23, 2016

Choose a reason for hiding this comment

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

@javache -- it worked. If you get errors/warnings like

Use of undeclared identifier '_refreshControl'; did you mean 'refreshControl'?

replace it with

- (void)setRefreshControl:(RCTRefreshControl *)refreshControl
{
  if (refreshControl) {
    [refreshControl removeFromSuperview];
  }
  refreshControl = refreshControl;
  [self addSubview:refreshControl];
}


Please sign in to comment.