[clang-static-analyzer]: google_landing_controller.mm: Null is returned from a method that is expected to return a non-null value |
|||||
Issue description
See screenshot for detailed error.
Summary, -collectionView:viewForSupplementaryElementOfKind:atIndexPath: can return nil if kind is not UICollectionElementKindSectionHeader.
michaeldo: can you investigate? If this is a false positive (i.e. all the possible values for kind are treated), then a NOTREACHED() at the end of the method would fix the warning.
BTW, the method would be easier to read if it was written as this:
- (UICollectionReusableView*)collectionView:(UICollectionView*)collectionView
viewForSupplementaryElementOfKind:(NSString*)kind
atIndexPath:(NSIndexPath*)indexPath {
if (kind != UICollectionElementKindSectionHeader)
return nil;
if (!_supplementaryViews)
_supplementaryViews.reset([[NSMutableArray alloc] init]);
NSUInteger section = indexPath.section;
if (section == SectionWithOmnibox) {
if (!_headerView) {
or with a DCHECK(kind == UICollectionElementKindSectionHeader) if no other value is supported.
,
Sep 21 2016
,
Jan 31 2017
This bug is still present. We are trying to set up a bot that will run clang static analyser and this bug should be fixed before we can do that, increasing priority.
,
Jan 31 2017
,
Feb 6 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/7348c2e83d2be803c1142f0842f28b295d4bd152 commit 7348c2e83d2be803c1142f0842f28b295d4bd152 Author: michaeldo <michaeldo@chromium.org> Date: Mon Feb 06 15:29:46 2017 Cleanup and add NOTREACHED to supplementaryView method. Fixes an error reported by returning nil as a supplementary view must be returned from this method. BUG= 648970 Review-Url: https://codereview.chromium.org/2663323002 Cr-Commit-Position: refs/heads/master@{#448255} [modify] https://crrev.com/7348c2e83d2be803c1142f0842f28b295d4bd152/ios/chrome/browser/ui/ntp/google_landing_controller.mm
,
Feb 6 2017
|
|||||
►
Sign in to add a comment |
|||||
Comment 1 by sdefresne@chromium.org
, Sep 21 2016