New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 648970 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Feb 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: iOS
Pri: 2
Type: Bug

Blocking:
issue 648210



Sign in to add a comment

[clang-static-analyzer]: google_landing_controller.mm: Null is returned from a method that is expected to return a non-null value

Project Member Reported by sdefresne@chromium.org, Sep 21 2016

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.
 
Screen Shot 2016-09-21 at 16.30.02.png
205 KB View Download
Cc: noyau@chromium.org
Blocking: 648210
Labels: -Restrict-View-Google -Pri-3 Pri-2
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.
Status: Started (was: Assigned)
Project Member

Comment 5 by bugdroid1@chromium.org, 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

Status: Fixed (was: Started)

Sign in to add a comment