Skip to content

Fix all Linux host_debug clang analyzer warnings #93576

@jmagman

Description

@jmagman

Linux host_debug has hundreds of clang analyzer warnings:
https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8830722455361084417/+/u/test:_lint_test/stdout

  1. Turn off warnings that we don't want in .clang-tidy via the - prefix. For example, to turn off StackAddressEscape:
Checks: 'google-*,-clang-analyzer-core.StackAddressEscape'
  1. Fix all other warnings.

Once all warnings are fixed we can turn on this warnings-as-errors in CI and in the pre-push hook.
#93279

Some can be fixed automatically $ ci/lint.sh --lint-all --fix.

Steps to reproduce locally on Linux

Add the following lines to .clang-tidy

WarningsAsErrors: '*'

Then run:

$ ci/lint.sh  --lint-all

Sample output:

❌ Failures for clang-tidy on /b/s/w/ir/cache/builder/src/flutter/fml/synchronization/semaphore.cc:
/b/s/w/ir/cache/builder/src/flutter/fml/synchronization/semaphore.cc:109:11: error: Value stored to 'result' during its initialization is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
      int result = ::sem_destroy(&sem_);
          ^~~~~~   ~~~~~~~~~~~~~~~~~~~~
/b/s/w/ir/cache/builder/src/flutter/fml/synchronization/semaphore.cc:109:11: note: Value stored to 'result' during its initialization is never read
      int result = ::sem_destroy(&sem_);
          ^~~~~~   ~~~~~~~~~~~~~~~~~~~~
    
❌ Failures for clang-tidy on /b/s/w/ir/cache/builder/src/flutter/fml/platform/linux/message_loop_linux.cc:
/b/s/w/ir/cache/builder/src/flutter/fml/platform/linux/message_loop_linux.cc:83:8: error: Value stored to 'result' during its initialization is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
  bool result = TimerRearm(timer_fd_.get(), time_point);
       ^~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/b/s/w/ir/cache/builder/src/flutter/fml/platform/linux/message_loop_linux.cc:83:8: note: Value stored to 'result' during its initialization is never read
  bool result = TimerRearm(timer_fd_.get(), time_point);
       ^~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Jobs:  23% done, 109/491 completed,  7 in progress, 368 pending,   7 failed.    
❌ Failures for clang-tidy on /b/s/w/ir/cache/builder/src/flutter/fml/platform/linux/timerfd.cc:
/b/s/w/ir/cache/builder/src/flutter/fml/platform/linux/timerfd.cc:47:26: error: C-style casts are discouraged; use static_cast [google-readability-casting,-warnings-as-errors]
  spec.it_value.tv_sec = (time_t)(nano_secs / NSEC_PER_SEC);
                         ^~~~~~~~
                         static_cast<time_t>

etc

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work listengineflutter/engine related. See also e: labels.team-engineOwned by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions