forked from yugabyte/yugabyte-db
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[yugabyte#5203] Analyze C/C++ code with PVS Studio and fix some of th…
…e warnings Summary: PVS-Studio is a static analysis tool that can help detect certain bugs. Adding infrastructure for running PVS-Studio on our codebase. This includes a new debug-mode build type ("pvs") preconfigured for this kind of analysis: - Automatically generate the compilation database (compile_commands.json file). - Disabling remote compiler invocation. - Disabling building any of the test code. Also adding a yugabytedb.pvsconfig configuration file that suppresses some of the PVS-Studio false positives on YugabyteDB code. Fixing some of the warnings found by PVS-Studio, mostly fields left uninitialized in constructors. To re-run PVS-Studio analysis, do the build and then run: build-support/run_pvs_studio_analyzer --build_root build/pvs-gcc-dynamic-ninja Other changes: - Refactor compilation database generation scripts. - Simplify wrapping libpq and yb_pgbackend (the shared library with PostgreSQL backend code) in CMake libraries. - Fixing a dependency bug with libpq not having been built prior to building tablet code that depends on it due to YSQL backfill. This produces a warning `ld: warning: directory not found for option` which is now being treated as an error. - Changing the environment variable that triggers compile_commands.json generation from CMAKE_EXPORT_COMPILE_COMMANDS to YB_EXPORT_COMPILE_COMMANDS for clarity, to avoid confusion with CMake's variable (https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html). - remote_build.py now supports auto-detecting the remote build directory based on patterns specified in the profile file, and automatically cloning the repo remotely if necessary. - Introducing the YbBuildToolBase class and using it in build_postgres.py and run_pvs_studio_analyzer.py. One more detail is that we currently run PVS-Studio with devtoolset-8's gcc8 (see yugabyte#4996) and without Linuxbrew, to minimize false positives where standard headers inside Linuxbrew are not being recognized as such by PVS-Studio. So for any of the above to work, currently the following needs to be done first: ``` . /opt/rh/devtoolset-8/enable export YB_DISABLE_LINUXBREW=1 ``` Test Plan: Jenkins Reviewers: bogdan, steve.varnau Reviewed By: steve.varnau Subscribers: kannan, ybase Differential Revision: https://phabricator.dev.yugabyte.com/D9395
- Loading branch information
Showing
67 changed files
with
1,114 additions
and
389 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Copyright (c) Yugabyte, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
# in compliance with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License | ||
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
# or implied. See the License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
set -euo pipefail | ||
. "${BASH_SOURCE%/*}/common-build-env.sh" | ||
|
||
activate_virtualenv | ||
export PYTHONPATH=$YB_SRC_ROOT/python:${PYTHONPATH:-} | ||
"$YB_SRC_ROOT"/python/yb/run_pvs_studio_analyzer.py "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[mypy] | ||
disallow_untyped_defs = True | ||
disallow_untyped_calls = True | ||
disallow_incomplete_defs = True | ||
check_untyped_defs = True | ||
disallow_untyped_decorators = True | ||
disallow_any_unimported = True |
Oops, something went wrong.