diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 25d898c5eb..4f9c0d720d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,8 +8,7 @@ If you want to help but don't know where to start, here are some low-risk/isolated tasks: - Try a [complexity:low] issue. -- Fix bugs found by [Clang](#clang-scan-build), [PVS](#pvs-studio) or - [Coverity](#coverity). +- Fix bugs found by [Clang](#clang-scan-build) or [Coverity](#coverity). - [Merge a Vim patch] (requires strong familiarity with Vim) - NOTE: read the above link before sending improvements to "runtime files" (anything in `runtime/`). - Vimscript and documentation files are (mostly) maintained by [Vim](https://github.com/vim/vim), not Nvim. @@ -147,21 +146,6 @@ View the [Clang report] to see potential bugs found by the Clang scan-build --use-analyzer=/usr/bin/clang make ``` -### PVS-Studio - -View the [PVS report](https://neovim.io/doc/reports/pvs/PVS-studio.html.d/) to -see potential bugs found by [PVS Studio](https://www.viva64.com/en/pvs-studio/). - -- Use this format for commit messages (where `{id}` is the PVS warning-id)): - ``` - fix(PVS/V{id}): {description} - ``` -- Search the Neovim commit history to find examples: - ```bash - git log --oneline --no-merges --grep PVS - ``` -- Try `./scripts/pvscheck.sh` to run PVS locally. - ### Coverity [Coverity](https://scan.coverity.com/projects/neovim-neovim) runs against the diff --git a/README.md b/README.md index 73fc2ed7ea..be8b3178f3 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ [![Coverity Scan analysis](https://scan.coverity.com/projects/2227/badge.svg)](https://scan.coverity.com/projects/2227) [![Clang analysis](https://neovim.io/doc/reports/clang/badge.svg)](https://neovim.io/doc/reports/clang) -[![PVS-Studio analysis](https://neovim.io/doc/reports/pvs/badge.svg)](https://neovim.io/doc/reports/pvs/PVS-studio.html.d) [![Packages](https://repology.org/badge/tiny-repos/neovim.svg)](https://repology.org/metapackage/neovim) [![Debian CI](https://badges.debian.net/badges/debian/testing/neovim/version.svg)](https://buildd.debian.org/neovim) [![Downloads](https://img.shields.io/github/downloads/neovim/neovim/total.svg?maxAge=2592001)](https://github.com/neovim/neovim/releases/) diff --git a/cmake.config/pathdef.c.in b/cmake.config/pathdef.c.in index 6135226dac..b7ee746852 100644 --- a/cmake.config/pathdef.c.in +++ b/cmake.config/pathdef.c.in @@ -1,5 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include "${PROJECT_SOURCE_DIR}/src/nvim/vim.h" char *default_vim_dir = "${CMAKE_INSTALL_FULL_DATAROOTDIR}/nvim"; char *default_vimruntime_dir = ""; diff --git a/scripts/pvscheck.sh b/scripts/pvscheck.sh deleted file mode 100755 index 5334dd2fb7..0000000000 --- a/scripts/pvscheck.sh +++ /dev/null @@ -1,498 +0,0 @@ -#!/bin/sh - -# Assume that "local" is available. -# shellcheck disable=SC2039 - -set -e -# Note: -u causes problems with posh, it barks at “undefined” $@ when no -# arguments provided. -test -z "$POSH_VERSION" && set -u - -log_info() { - >&2 printf "pvscheck.sh: %s\n" "$@" -} - -get_jobs_num() { - if [ -n "${TRAVIS:-}" ] ; then - # HACK: /proc/cpuinfo on Travis CI is misleading, so hardcode 1. - echo 1 - else - echo $(( $(grep -c "^processor" /proc/cpuinfo) + 1 )) - fi -} - -help() { - echo 'Usage:' - echo ' pvscheck.sh [--pvs URL] [--deps] [--environment-cc]' - echo ' [target-directory [branch]]' - echo ' pvscheck.sh [--pvs URL] [--recheck] [--environment-cc] [--update]' - echo ' [target-directory]' - echo ' pvscheck.sh [--pvs URL] --only-analyse [target-directory]' - echo ' pvscheck.sh [--pvs URL] --pvs-install {target-directory}' - echo ' pvscheck.sh --patch [--only-build]' - echo - echo ' --pvs: Fetch pvs-studio from URL.' - echo - echo ' --pvs detect: Auto-detect latest version (by scraping viva64.com).' - echo - echo ' --deps: (for regular run) Use top-level Makefile and build deps.' - echo ' Without this it assumes all dependencies are already' - echo ' installed.' - echo - echo ' --environment-cc: (for regular run and --recheck) Do not export' - echo ' CC=clang. Build is still run with CFLAGS=-O0.' - echo - echo ' --only-build: (for --patch) Only patch files in ./build directory.' - echo - echo ' --pvs-install: Only install PVS-studio to the specified location.' - echo - echo ' --patch: patch sources in the current directory.' - echo ' Does not patch already patched files.' - echo ' Does not run analysis.' - echo - echo ' --recheck: run analysis on a prepared target directory.' - echo - echo ' --update: when rechecking first do a pull.' - echo - echo ' --only-analyse: run analysis on a prepared target directory ' - echo ' without building Neovim.' - echo - echo ' target-directory: Directory where build should occur.' - echo ' Default: ../neovim-pvs' - echo - echo ' branch: Branch to check.' - echo ' Default: master.' -} - -getopts_error() { - local msg="$1" ; shift - local do_help= - if test "$msg" = "--help" ; then - msg="$1" ; shift - do_help=1 - fi - printf '%s\n' "$msg" >&2 - if test -n "$do_help" ; then - printf '\n' >&2 - help >&2 - fi - echo 'return 1' - return 1 -} - -# Usage `eval "$(getopts_long long_defs -- positionals_defs -- "$@")"` -# -# long_defs: list of pairs of arguments like `longopt action`. -# positionals_defs: list of arguments like `action`. -# -# `action` is a space-separated commands: -# -# store_const [const] [varname] [default] -# Store constant [const] (default 1) (note: eval’ed) if argument is present -# (long options only). Assumes long option accepts no arguments. -# store [varname] [default] -# Store value. Assumes long option needs an argument. -# run {func} [varname] [default] -# Run function {func} and store its output to the [varname]. Assumes no -# arguments accepted (long options only). -# modify {func} [varname] [default] -# Like run, but assumes a single argument, passed to function {func} as $1. -# -# All actions stores empty value if neither [varname] nor [default] are -# present. [default] is evaled by top-level `eval`, so be careful. Also note -# that no arguments may contain spaces, including [default] and [const]. -getopts_long() { - local positional= - local opt_bases="" - while test $# -gt 0 ; do - local arg="$1" ; shift - local opt_base= - local act= - local opt_name= - if test -z "$positional" ; then - if test "$arg" = "--" ; then - positional=0 - continue - fi - act="$1" ; shift - opt_name="$(echo "$arg" | tr '-' '_')" - opt_base="longopt_$opt_name" - else - if test "$arg" = "--" ; then - break - fi - : $(( positional+=1 )) - act="$arg" - opt_name="arg_$positional" - opt_base="positional_$positional" - fi - opt_bases="$opt_bases $opt_base" - eval "local varname_$opt_base=$opt_name" - local i=0 - for act_subarg in $act ; do - eval "local act_$(( i+=1 ))_$opt_base=\"\$act_subarg\"" - done - done - # Process options - local positional=0 - local force_positional= - while test $# -gt 0 ; do - local argument="$1" ; shift - local opt_base= - local has_equal= - local equal_arg= - local is_positional= - if test "$argument" = "--" ; then - force_positional=1 - continue - elif test -z "$force_positional" && test "${argument#--}" != "$argument" - then - local opt_name="${argument#--}" - local opt_name_striparg="${opt_name%%=*}" - if test "$opt_name" = "$opt_name_striparg" ; then - has_equal=0 - else - has_equal=1 - equal_arg="${argument#*=}" - opt_name="$opt_name_striparg" - fi - # Use trailing x to prevent stripping newlines - opt_name="$(printf '%sx' "$opt_name" | tr '-' '_')" - opt_name="${opt_name%x}" - if test -n "$(printf '%sx' "$opt_name" | tr -d 'a-z_')" ; then - getopts_error "Option contains invalid characters: $opt_name" - fi - opt_base="longopt_$opt_name" - else - : $(( positional+=1 )) - opt_base="positional_$positional" - is_positional=1 - fi - if test -n "$opt_base" ; then - eval "local occurred_$opt_base=1" - - eval "local act_1=\"\${act_1_$opt_base:-}\"" - eval "local varname=\"\${varname_$opt_base:-}\"" - local need_val= - local func= - case "$act_1" in - (store_const) - eval "local const=\"\${act_2_${opt_base}:-1}\"" - eval "local varname=\"\${act_3_${opt_base}:-$varname}\"" - printf 'local %s=%s\n' "$varname" "$const" - ;; - (store) - eval "varname=\"\${act_2_${opt_base}:-$varname}\"" - need_val=1 - ;; - (run) - eval "func=\"\${act_2_${opt_base}}\"" - eval "varname=\"\${act_3_${opt_base}:-$varname}\"" - printf 'local %s="$(%s)"\n' "$varname" "$func" - ;; - (modify) - eval "func=\"\${act_2_${opt_base}}\"" - eval "varname=\"\${act_3_${opt_base}:-$varname}\"" - need_val=1 - ;; - ("") - getopts_error --help "Wrong argument: $argument" - ;; - esac - if test -n "$need_val" ; then - local val= - if test -z "$is_positional" ; then - if test $has_equal = 1 ; then - val="$equal_arg" - else - if test $# -eq 0 ; then - getopts_error "Missing argument for $opt_name" - fi - val="$1" ; shift - fi - else - val="$argument" - fi - local escaped_val="'$(printf "%s" "$val" | sed "s/'/'\\\\''/g")'" - case "$act_1" in - (store) - printf 'local %s=%s\n' "$varname" "$escaped_val" - ;; - (modify) - printf 'local %s="$(%s %s)"\n' "$varname" "$func" "$escaped_val" - ;; - esac - fi - fi - done - # Print default values when no values were provided - local opt_base= - for opt_base in $opt_bases ; do - eval "local occurred=\"\${occurred_$opt_base:-}\"" - if test -n "$occurred" ; then - continue - fi - eval "local act_1=\"\$act_1_$opt_base\"" - eval "local varname=\"\$varname_$opt_base\"" - case "$act_1" in - (store) - eval "local varname=\"\${act_2_${opt_base}:-$varname}\"" - eval "local default=\"\${act_3_${opt_base}:-}\"" - printf 'local %s=%s\n' "$varname" "$default" - ;; - (store_const|run|modify) - eval "local varname=\"\${act_3_${opt_base}:-$varname}\"" - eval "local default=\"\${act_4_${opt_base}:-}\"" - printf 'local %s=%s\n' "$varname" "$default" - ;; - esac - done -} - -get_pvs_comment() { - local tgt="$1" ; shift - - cat > "$tgt/pvs-comment" << EOF -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - -EOF -} - -install_pvs() {( - local tgt="$1" ; shift - local pvs_url="$1" ; shift - - cd "$tgt" - - if test -d pvs-studio ; then - log_info 'install_pvs: "pvs-studio" directory already exists, skipping install' - return 0 - fi - - mkdir pvs-studio - cd pvs-studio - - curl -L -o pvs-studio.tar.gz "$pvs_url" - tar xzf pvs-studio.tar.gz - rm pvs-studio.tar.gz - local pvsdir="$(find . -maxdepth 1 -mindepth 1)" - find "$pvsdir" -maxdepth 1 -mindepth 1 -exec mv '{}' . \; - rmdir "$pvsdir" -)} - -create_compile_commands() {( - local tgt="$1" ; shift - local deps="$1" ; shift - local environment_cc="$1" ; shift - - if test -z "$environment_cc" ; then - export CC=clang - fi - export CFLAGS=' -O0 ' - - if test -z "$deps" ; then - mkdir -p "$tgt/build" - ( - cd "$tgt/build" - - cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="$PWD/root" - make -j"$(get_jobs_num)" - ) - else - ( - cd "$tgt" - - make -j"$(get_jobs_num)" CMAKE_EXTRA_FLAGS=" -DCMAKE_INSTALL_PREFIX=$PWD/root -DCMAKE_BUILD_TYPE=Debug " - ) - fi - find "$tgt/build/src/nvim/auto" -name '*.test-include.c' -delete -)} - -# Warning: realdir below only cares about directories unlike realpath. -# -# realpath is not available in Ubuntu trusty yet. -realdir() {( - local dir="$1" - local add="" - while ! cd "$dir" 2>/dev/null ; do - add="${dir##*/}/$add" - local new_dir="${dir%/*}" - if test "$new_dir" = "$dir" ; then - return 1 - fi - dir="$new_dir" - done - printf '%s\n' "$PWD/$add" -)} - -patch_sources() {( - local tgt="$1" ; shift - local only_build="${1}" ; shift - - get_pvs_comment "$tgt" - - local sh_script=' - pvs_comment="$(cat pvs-comment ; echo -n EOS)" - filehead="$(head -c $(( ${#pvs_comment} - 3 )) "$1" ; echo -n EOS)" - if test "x$filehead" != "x$pvs_comment" ; then - cat pvs-comment "$1" > "$1.tmp" - mv "$1.tmp" "$1" - fi - ' - - cd "$tgt" - - if test "$only_build" != "--only-build" ; then - find \ - src/nvim test/functional/fixtures test/unit/fixtures \ - \( -name '*.c' -a '!' -path '*xdiff*' \) \ - -exec /bin/sh -c "$sh_script" - '{}' \; - fi - - find \ - build/src/nvim/auto build/config \ - -name '*.c' -not -name '*.test-include.c' \ - -exec /bin/sh -c "$sh_script" - '{}' \; - - rm pvs-comment -)} - -run_analysis() {( - local tgt="$1" ; shift - - cd "$tgt" - - if [ ! -r PVS-Studio.lic ]; then - pvs-studio-analyzer credentials -o PVS-Studio.lic 'PVS-Studio Free' 'FREE-FREE-FREE-FREE' - fi - - # pvs-studio-analyzer exits with a non-zero exit code when there are detected - # errors, so ignore its return - pvs-studio-analyzer \ - analyze \ - --lic-file PVS-Studio.lic \ - --threads "$(get_jobs_num)" \ - --exclude-path src/cjson \ - --exclude-path src/klib \ - --exclude-path src/mpack \ - --exclude-path src/xdiff \ - --exclude-path build \ - --output-file PVS-studio.log \ - --file build/compile_commands.json \ - --sourcetree-root . || true - - rm -rf PVS-studio.{xml,err,tsk,html.d} - local plog_args="PVS-studio.log --srcRoot . --excludedCodes V002,V011,V601,V1028,V1042,V1051,V1074" - plog-converter $plog_args --renderTypes xml --output PVS-studio.xml - plog-converter $plog_args --renderTypes errorfile --output PVS-studio.err - plog-converter $plog_args --renderTypes tasklist --output PVS-studio.tsk - plog-converter $plog_args --renderTypes fullhtml --output PVS-studio.html.d -)} - -detect_url() { - local url="${1:-detect}" - if test "$url" = detect ; then - curl --silent -L 'https://pvs-studio.com/en/pvs-studio/download-all/' \ - | grep -o 'https\{0,1\}://[^"<>]\{1,\}/pvs-studio[^/"<>]*-x86_64\.tgz' \ - || echo FAILED - else - printf '%s' "$url" - fi -} - -do_check() { - local tgt="$1" ; shift - local branch="$1" ; shift - local pvs_url="$1" ; shift - local deps="$1" ; shift - local environment_cc="$1" ; shift - - if test -z "$pvs_url" || test "$pvs_url" = FAILED ; then - pvs_url="$(detect_url detect)" - if test -z "$pvs_url" || test "$pvs_url" = FAILED ; then - echo "failed to auto-detect PVS URL" - exit 1 - fi - echo "Auto-detected PVS URL: ${pvs_url}" - fi - - git clone --branch="$branch" . "$tgt" - - install_pvs "$tgt" "$pvs_url" - - do_recheck "$tgt" "$deps" "$environment_cc" "" -} - -do_recheck() { - local tgt="$1" ; shift - local deps="$1" ; shift - local environment_cc="$1" ; shift - local update="$1" ; shift - - if test -n "$update" ; then - ( - cd "$tgt" - local branch="$(git rev-parse --abbrev-ref HEAD)" - git checkout --detach - git fetch -f origin "${branch}:${branch}" - git checkout -f "$branch" - ) - fi - - create_compile_commands "$tgt" "$deps" "$environment_cc" - - do_analysis "$tgt" -} - -do_analysis() { - local tgt="$1" ; shift - - if test -d "$tgt/pvs-studio" ; then - local saved_pwd="$PWD" - cd "$tgt/pvs-studio" - export PATH="$PWD/bin${PATH+:}${PATH}" - cd "$saved_pwd" - fi - - run_analysis "$tgt" -} - -main() { - eval "$( - getopts_long \ - help store_const \ - pvs 'modify detect_url pvs_url' \ - patch store_const \ - only-build 'store_const --only-build' \ - recheck store_const \ - only-analyse store_const \ - pvs-install store_const \ - deps store_const \ - environment-cc store_const \ - update store_const \ - -- \ - 'modify realdir tgt "$PWD/../neovim-pvs"' \ - 'store branch master' \ - -- "$@" - )" - - if test -n "$help" ; then - help - return 0 - fi - - if test -n "$patch" ; then - patch_sources "$tgt" "$only_build" - elif test -n "$pvs_install" ; then - install_pvs "$tgt" "$pvs_url" - elif test -n "$recheck" ; then - do_recheck "$tgt" "$deps" "$environment_cc" "$update" - elif test -n "$only_analyse" ; then - do_analysis "$tgt" - else - do_check "$tgt" "$branch" "$pvs_url" "$deps" "$environment_cc" - fi -} - -main "$@" diff --git a/scripts/update_terminfo.sh b/scripts/update_terminfo.sh index 775048f246..2840334e99 100755 --- a/scripts/update_terminfo.sh +++ b/scripts/update_terminfo.sh @@ -61,9 +61,6 @@ print_bold "[*] Writing $target... " sorted_terms="$(echo "${!entries[@]}" | tr ' ' '\n' | sort | xargs)" cat > "$target" < (mpack_uint32_t)-1 && len > (mpack_uint32_t)-1) // -V560 + if ((size_t)-1 > (mpack_uint32_t)-1 && len > (mpack_uint32_t)-1) /* msgpack spec doesn't allow lengths > 32 bits */ len = (mpack_uint32_t)-1; assert(top == lua_gettop(L)); diff --git a/src/mpack/mpack_core.c b/src/mpack/mpack_core.c index 3424f444b9..b9b92523bd 100644 --- a/src/mpack/mpack_core.c +++ b/src/mpack/mpack_core.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include "mpack_core.h" diff --git a/src/mpack/object.c b/src/mpack/object.c index 60f49f73aa..ec128690d7 100644 --- a/src/mpack/object.c +++ b/src/mpack/object.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include "object.h" diff --git a/src/mpack/rpc.c b/src/mpack/rpc.c index 2d251284ba..3b2b328065 100644 --- a/src/mpack/rpc.c +++ b/src/mpack/rpc.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include "rpc.h" diff --git a/src/nvim/api/autocmd.c b/src/nvim/api/autocmd.c index d0efb58cb6..c15095243d 100644 --- a/src/nvim/api/autocmd.c +++ b/src/nvim/api/autocmd.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 2c80f96953..0444deff40 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Some of this code was adapted from 'if_py_both.h' from the original // vim source diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c index 9d51f2a4dc..10d8b4c768 100644 --- a/src/nvim/api/command.c +++ b/src/nvim/api/command.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c index 8edb6dbd4f..8398a3a5b1 100644 --- a/src/nvim/api/deprecated.c +++ b/src/nvim/api/deprecated.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index aeecab6bd0..84b89a7428 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c index 5b1f61b9f6..61debb70fe 100644 --- a/src/nvim/api/options.c +++ b/src/nvim/api/options.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/api/private/converter.c b/src/nvim/api/private/converter.c index d9832abd76..1188b04bdc 100644 --- a/src/nvim/api/private/converter.c +++ b/src/nvim/api/private/converter.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/api/private/dispatch.c b/src/nvim/api/private/dispatch.c index f427bba00e..53fcd148bd 100644 --- a/src/nvim/api/private/dispatch.c +++ b/src/nvim/api/private/dispatch.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include "nvim/api/private/defs.h" diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index eaee94786c..bbeaa452ba 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/api/private/validate.c b/src/nvim/api/private/validate.c index cede32f72c..17e9d081a6 100644 --- a/src/nvim/api/private/validate.c +++ b/src/nvim/api/private/validate.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/api/tabpage.c b/src/nvim/api/tabpage.c index 21eb326c3b..d6bbff6747 100644 --- a/src/nvim/api/tabpage.c +++ b/src/nvim/api/tabpage.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index d5bb474039..3d013435f7 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 86e542a1c7..1d5898c488 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index b09e4d7d87..63c1f39fb7 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index 6f38989c96..83c8ba832c 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index 53095ab019..9a788e9ce4 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c index 9dbb2c06e1..50ef761066 100644 --- a/src/nvim/arabic.c +++ b/src/nvim/arabic.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file arabic.c /// /// Functions for Arabic language. diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c index c30734de74..7f75506c1e 100644 --- a/src/nvim/arglist.c +++ b/src/nvim/arglist.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // arglist.c: functions for dealing with the argument list #include diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index b58b5784b4..80573696d4 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // autocmd.c: Autocommand related functions #include diff --git a/src/nvim/base64.c b/src/nvim/base64.c index f004e4fe8b..c647019fb1 100644 --- a/src/nvim/base64.c +++ b/src/nvim/base64.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 4ce4036ac9..677809459c 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // // buffer.c: functions for dealing with the buffer structure // @@ -1020,7 +1017,7 @@ void handle_swap_exists(bufref_T *old_curbuf) // new aborting error, interrupt, or uncaught exception. leave_cleanup(&cs); } - swap_exists_action = SEA_NONE; // -V519 + swap_exists_action = SEA_NONE; } /// do_bufdel() - delete or unload buffer(s) diff --git a/src/nvim/buffer_updates.c b/src/nvim/buffer_updates.c index 9543731c9b..39f2e07759 100644 --- a/src/nvim/buffer_updates.c +++ b/src/nvim/buffer_updates.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/bufwrite.c b/src/nvim/bufwrite.c index a3d05f28be..96211f855c 100644 --- a/src/nvim/bufwrite.c +++ b/src/nvim/bufwrite.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // bufwrite.c: functions for writing a buffer #include diff --git a/src/nvim/change.c b/src/nvim/change.c index 39229e1cf0..bee074385e 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// change.c: functions related to changing text #include diff --git a/src/nvim/channel.c b/src/nvim/channel.c index 4c355dba3f..0ad37c08ee 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 95229c5ffb..2edf9a87cc 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file charset.c /// /// Code related to character sets. @@ -1328,7 +1325,6 @@ void vim_str2nr(const char *const start, int *const prep, int *const len, const // Do the conversion manually to avoid sscanf() quirks. abort(); // Should’ve used goto earlier. - // -V:PARSE_NUMBER:560 #define PARSE_NUMBER(base, cond, conv) \ do { \ const char *const after_prefix = ptr; \ diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 23948e16bb..6a6cf9e4af 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // cmdexpand.c: functions for command-line completion #include diff --git a/src/nvim/cmdhist.c b/src/nvim/cmdhist.c index 5e196011d7..25093a2b1c 100644 --- a/src/nvim/cmdhist.c +++ b/src/nvim/cmdhist.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // cmdhist.c: Functions for the history of the command-line. #include diff --git a/src/nvim/context.c b/src/nvim/context.c index acf793c39a..3114fc8ab5 100644 --- a/src/nvim/context.c +++ b/src/nvim/context.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Context: snapshot of the entire editor state as one big object/map #include diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c index ca309757f9..4e8457eb2d 100644 --- a/src/nvim/cursor.c +++ b/src/nvim/cursor.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index 92b7568593..37fa0ccd8e 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/debugger.c b/src/nvim/debugger.c index 2d27ae4f0a..31aad11d60 100644 --- a/src/nvim/debugger.c +++ b/src/nvim/debugger.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file debugger.c /// /// Vim script debugger functions diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c index 8341f29410..b111b01fe9 100644 --- a/src/nvim/decoration.c +++ b/src/nvim/decoration.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include diff --git a/src/nvim/decoration_provider.c b/src/nvim/decoration_provider.c index 1b0171a0a5..cc1ae6ac92 100644 --- a/src/nvim/decoration_provider.c +++ b/src/nvim/decoration_provider.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 27c4899e05..aee0081e86 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file diff.c /// /// Code for diff'ing two, three or four buffers. @@ -1579,10 +1576,10 @@ static bool extract_hunk(FILE *fd, diffhunk_T *hunk, diffstyle_T *diffstyle) *diffstyle = DIFF_ED; } else if ((strncmp(line, "@@ ", 3) == 0)) { *diffstyle = DIFF_UNIFIED; - } else if ((strncmp(line, "--- ", 4) == 0) // -V501 - && (vim_fgets(line, LBUFLEN, fd) == 0) // -V501 + } else if ((strncmp(line, "--- ", 4) == 0) + && (vim_fgets(line, LBUFLEN, fd) == 0) && (strncmp(line, "+++ ", 4) == 0) - && (vim_fgets(line, LBUFLEN, fd) == 0) // -V501 + && (vim_fgets(line, LBUFLEN, fd) == 0) && (strncmp(line, "@@ ", 3) == 0)) { *diffstyle = DIFF_UNIFIED; } else { diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index de76d55977..b29b5aed72 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file digraph.c /// /// code for digraphs @@ -1624,7 +1621,7 @@ int digraph_get(int char1, int char2, bool meta_char) if (((retval = getexactdigraph(char1, char2, meta_char)) == char2) && (char1 != char2) - && ((retval = getexactdigraph(char2, char1, meta_char)) // -V764 + && ((retval = getexactdigraph(char2, char1, meta_char)) == char1)) { return char2; } diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index b5438e649c..2ef1083cf8 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // drawline.c: Functions for drawing window lines on the screen. // This is the middle level, drawscreen.c is the top and grid.c the lower level. @@ -1439,7 +1436,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl } else { // Long line, use only the last SPWORDLEN bytes. nextlinecol = (int)v - SPWORDLEN; - memmove(nextline, line + nextlinecol, SPWORDLEN); // -V1086 + memmove(nextline, line + nextlinecol, SPWORDLEN); nextline_idx = SPWORDLEN + 1; } } @@ -2146,7 +2143,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl decor_attr = get_syntax_attr((colnr_T)v - 1, spv->spv_has_spell ? &can_spell : NULL, false); - if (did_emsg) { // -V547 + if (did_emsg) { wp->w_s->b_syn_error = true; has_syntax = false; } else { diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index 1144fa6354..29f1cb2470 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // drawscreen.c: Code for updating all the windows on the screen. // This is the top level, drawline.c is the middle and grid.c/screen.c the lower level. diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 2b332ea414..42b714ef47 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // edit.c: functions for Insert mode #include diff --git a/src/nvim/eval.c b/src/nvim/eval.c index e1216663cd..7b3726486f 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // eval.c: Expression evaluation. #include diff --git a/src/nvim/eval/buffer.c b/src/nvim/eval/buffer.c index b480d25367..a26ba54ca3 100644 --- a/src/nvim/eval/buffer.c +++ b/src/nvim/eval/buffer.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // eval/buffer.c: Buffer related builtin functions #include diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index 9c47e06f69..c090d1c9fe 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include @@ -964,7 +961,7 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv) } break; case MSGPACK_OBJECT_NEGATIVE_INTEGER: - if (mobj.via.i64 >= VARNUMBER_MIN) { // -V547 + if (mobj.via.i64 >= VARNUMBER_MIN) { *rettv = (typval_T) { .v_type = VAR_NUMBER, .v_lock = VAR_UNLOCKED, diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 4a0c4ca19a..709733564e 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file encode.c /// /// File containing functions for encoding and decoding Vimscript values. diff --git a/src/nvim/eval/executor.c b/src/nvim/eval/executor.c index 7668fb129f..62c59db932 100644 --- a/src/nvim/eval/executor.c +++ b/src/nvim/eval/executor.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 6efd9733e5..c6909245af 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include @@ -4810,7 +4807,7 @@ static void f_min(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) /// "mkdir()" function static void f_mkdir(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) { - int prot = 0755; // -V536 + int prot = 0755; rettv->vval.v_number = FAIL; if (check_secure()) { @@ -5732,9 +5729,9 @@ static void read_file_or_blob(typval_T *argvars, typval_T *rettv, bool always_bl // have to shuffle buf to close gap int adjust_prevlen = 0; - if (dest < buf) { // -V782 + if (dest < buf) { // adjust_prevlen must be 1 or 2. - adjust_prevlen = (int)(buf - dest); // -V782 + adjust_prevlen = (int)(buf - dest); dest = buf; } if (readlen > p - buf + 1) { diff --git a/src/nvim/eval/gc.c b/src/nvim/eval/gc.c index 6a54c4ddc1..bcebd87f71 100644 --- a/src/nvim/eval/gc.c +++ b/src/nvim/eval/gc.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include "nvim/eval/gc.h" diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 3657e182af..8a38315706 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include @@ -4422,7 +4419,7 @@ const char *tv_get_string_buf_chk(const typval_T *const tv, char *const buf) { switch (tv->v_type) { case VAR_NUMBER: - snprintf(buf, NUMBUFLEN, "%" PRIdVARNUMBER, tv->vval.v_number); // -V576 + snprintf(buf, NUMBUFLEN, "%" PRIdVARNUMBER, tv->vval.v_number); return buf; case VAR_FLOAT: vim_snprintf(buf, NUMBUFLEN, "%g", tv->vval.v_float); diff --git a/src/nvim/eval/typval_encode.c.h b/src/nvim/eval/typval_encode.c.h index 6d29286a58..b958239223 100644 --- a/src/nvim/eval/typval_encode.c.h +++ b/src/nvim/eval/typval_encode.c.h @@ -252,8 +252,6 @@ #include "nvim/func_attr.h" #include "klib/kvec.h" -// -V::1063 - /// Dummy variable used because some macros need lvalue /// /// Must not be written to, if needed one must check that address of the @@ -347,8 +345,8 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( case VAR_PARTIAL: { partial_T *const pt = tv->vval.v_partial; (void)pt; - TYPVAL_ENCODE_CONV_FUNC_START(tv, (pt == NULL ? NULL : partial_name(pt))); // -V547 - _mp_push(*mpstack, ((MPConvStackVal) { // -V779 + TYPVAL_ENCODE_CONV_FUNC_START(tv, (pt == NULL ? NULL : partial_name(pt))); + _mp_push(*mpstack, ((MPConvStackVal) { .type = kMPConvPartial, .tv = tv, .saved_copyID = copyID - 1, @@ -396,7 +394,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( case VAR_SPECIAL: switch (tv->vval.v_special) { case kSpecialVarNull: - TYPVAL_ENCODE_CONV_NIL(tv); // -V1037 + TYPVAL_ENCODE_CONV_NIL(tv); break; } break; @@ -509,7 +507,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( } if (is_string) { TYPVAL_ENCODE_CONV_STR_STRING(tv, buf, len); - } else { // -V523 + } else { TYPVAL_ENCODE_CONV_STRING(tv, buf, len); } xfree(buf); @@ -544,8 +542,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( } list_T *const val_list = val_di->di_tv.vval.v_list; if (val_list == NULL || tv_list_len(val_list) == 0) { - TYPVAL_ENCODE_CONV_EMPTY_DICT( // -V501 - tv, TYPVAL_ENCODE_NODICT_VAR); + TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, TYPVAL_ENCODE_NODICT_VAR); break; } TV_LIST_ITER_CONST(val_list, li, { @@ -632,7 +629,7 @@ _convert_one_value_regular_dict: {} typval_encode_stop_converting_one_item: return OK; // Prevent “unused label” warnings. - goto typval_encode_stop_converting_one_item; // -V779 + goto typval_encode_stop_converting_one_item; } TYPVAL_ENCODE_SCOPE int _TYPVAL_ENCODE_ENCODE( @@ -835,5 +832,5 @@ encode_vim_to__error_ret: _mp_destroy(mpstack); return FAIL; // Prevent “unused label” warnings. - goto typval_encode_stop_converting_one_item; // -V779 + goto typval_encode_stop_converting_one_item; } diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index aff4f1de62..959dabafb5 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // User defined function support #include @@ -1214,7 +1211,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rett if (func_or_func_caller_profiling) { call_start = profile_end(call_start); - call_start = profile_sub_wait(wait_start, call_start); // -V614 + call_start = profile_sub_wait(wait_start, call_start); fp->uf_tm_total = profile_add(fp->uf_tm_total, call_start); fp->uf_tm_self = profile_self(fp->uf_tm_self, call_start, fp->uf_tm_children); @@ -1400,7 +1397,7 @@ void free_all_functions(void) // Clean up the current_funccal chain and the funccal stack. while (current_funccal != NULL) { tv_clear(current_funccal->fc_rettv); - cleanup_function_call(current_funccal); // -V595 + cleanup_function_call(current_funccal); if (current_funccal == NULL && funccal_stack != NULL) { restore_funccal(); } diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index ed79d8a681..8cc3903f7a 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // eval/vars.c: functions for dealing with variables #include diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c index f64809f2ef..c0607a4a34 100644 --- a/src/nvim/eval/window.c +++ b/src/nvim/eval/window.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // eval/window.c: Window related builtin functions #include diff --git a/src/nvim/event/libuv_process.c b/src/nvim/event/libuv_process.c index 1bb0511f12..73dec2bcab 100644 --- a/src/nvim/event/libuv_process.c +++ b/src/nvim/event/libuv_process.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include @@ -68,8 +65,7 @@ int libuv_process_spawn(LibuvProcess *uvproc) #ifdef MSWIN uvproc->uvstdio[0].flags |= proc->overlapped ? UV_OVERLAPPED_PIPE : 0; #endif - uvproc->uvstdio[0].data.stream = STRUCT_CAST(uv_stream_t, - &proc->in.uv.pipe); + uvproc->uvstdio[0].data.stream = (uv_stream_t *)(&proc->in.uv.pipe); } if (!proc->out.closed) { @@ -79,14 +75,12 @@ int libuv_process_spawn(LibuvProcess *uvproc) uvproc->uvstdio[1].flags |= proc->overlapped ? (UV_READABLE_PIPE | UV_OVERLAPPED_PIPE) : 0; #endif - uvproc->uvstdio[1].data.stream = STRUCT_CAST(uv_stream_t, - &proc->out.uv.pipe); + uvproc->uvstdio[1].data.stream = (uv_stream_t *)(&proc->out.uv.pipe); } if (!proc->err.closed) { uvproc->uvstdio[2].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; - uvproc->uvstdio[2].data.stream = STRUCT_CAST(uv_stream_t, - &proc->err.uv.pipe); + uvproc->uvstdio[2].data.stream = (uv_stream_t *)(&proc->err.uv.pipe); } else if (proc->fwd_err) { uvproc->uvstdio[2].flags = UV_INHERIT_FD; uvproc->uvstdio[2].data.fd = STDERR_FILENO; diff --git a/src/nvim/event/loop.c b/src/nvim/event/loop.c index ab2524c1a9..3d74fe7d6d 100644 --- a/src/nvim/event/loop.c +++ b/src/nvim/event/loop.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include @@ -61,9 +58,9 @@ bool loop_uv_run(Loop *loop, int64_t ms, bool once) mode = UV_RUN_NOWAIT; } - do { // -V1044 + do { uv_run(&loop->uv, mode); - } while (ms > 0 && !once && !*timeout_expired); // -V560 + } while (ms > 0 && !once && !*timeout_expired); if (ms > 0) { uv_timer_stop(&loop->poll_timer); @@ -163,7 +160,7 @@ bool loop_close(Loop *loop, bool wait) while (true) { // Run the loop to tickle close-callbacks (which should then free memory). // Use UV_RUN_NOWAIT to avoid a hang. #11820 - uv_run(&loop->uv, didstop ? UV_RUN_DEFAULT : UV_RUN_NOWAIT); // -V547 + uv_run(&loop->uv, didstop ? UV_RUN_DEFAULT : UV_RUN_NOWAIT); if ((uv_loop_close(&loop->uv) != UV_EBUSY) || !wait) { break; } diff --git a/src/nvim/event/loop.h b/src/nvim/event/loop.h index b2265a726d..7b4b724359 100644 --- a/src/nvim/event/loop.h +++ b/src/nvim/event/loop.h @@ -53,8 +53,6 @@ typedef struct loop { } \ } while (0) -// -V:LOOP_PROCESS_EVENTS_UNTIL:547 - // Poll for events until a condition or timeout #define LOOP_PROCESS_EVENTS_UNTIL(loop, multiqueue, timeout, condition) \ do { \ diff --git a/src/nvim/event/multiqueue.c b/src/nvim/event/multiqueue.c index 262d141b26..328fa68806 100644 --- a/src/nvim/event/multiqueue.c +++ b/src/nvim/event/multiqueue.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Multi-level queue for selective async event processing. // Not threadsafe; access must be synchronized externally. // diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index d612b503a7..a6646c3a7f 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include @@ -102,24 +99,21 @@ int process_spawn(Process *proc, bool in, bool out, bool err) } if (in) { - stream_init(NULL, &proc->in, -1, - STRUCT_CAST(uv_stream_t, &proc->in.uv.pipe)); + stream_init(NULL, &proc->in, -1, (uv_stream_t *)&proc->in.uv.pipe); proc->in.internal_data = proc; proc->in.internal_close_cb = on_process_stream_close; proc->refcount++; } if (out) { - stream_init(NULL, &proc->out, -1, - STRUCT_CAST(uv_stream_t, &proc->out.uv.pipe)); + stream_init(NULL, &proc->out, -1, (uv_stream_t *)&proc->out.uv.pipe); proc->out.internal_data = proc; proc->out.internal_close_cb = on_process_stream_close; proc->refcount++; } if (err) { - stream_init(NULL, &proc->err, -1, - STRUCT_CAST(uv_stream_t, &proc->err.uv.pipe)); + stream_init(NULL, &proc->err, -1, (uv_stream_t *)&proc->err.uv.pipe); proc->err.internal_data = proc; proc->err.internal_close_cb = on_process_stream_close; proc->refcount++; @@ -376,7 +370,7 @@ static void flush_stream(Process *proc, Stream *stream) } // Stream can be closed if it is empty. - if (num_bytes == stream->num_bytes) { // -V547 + if (num_bytes == stream->num_bytes) { if (stream->read_cb && !stream->did_eof) { // Stream callback could miss EOF handling if a child keeps the stream // open. But only send EOF if we haven't already. diff --git a/src/nvim/event/rstream.c b/src/nvim/event/rstream.c index a145452afd..4721bbdcb7 100644 --- a/src/nvim/event/rstream.c +++ b/src/nvim/event/rstream.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/event/signal.c b/src/nvim/event/signal.c index 8256ca2091..07223be987 100644 --- a/src/nvim/event/signal.c +++ b/src/nvim/event/signal.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include diff --git a/src/nvim/event/socket.c b/src/nvim/event/socket.c index 52a3c81449..62326de075 100644 --- a/src/nvim/event/socket.c +++ b/src/nvim/event/socket.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include @@ -64,10 +61,10 @@ int socket_watcher_init(Loop *loop, SocketWatcher *watcher, const char *endpoint uv_tcp_init(&loop->uv, &watcher->uv.tcp.handle); uv_tcp_nodelay(&watcher->uv.tcp.handle, true); - watcher->stream = STRUCT_CAST(uv_stream_t, &watcher->uv.tcp.handle); + watcher->stream = (uv_stream_t *)(&watcher->uv.tcp.handle); } else { uv_pipe_init(&loop->uv, &watcher->uv.pipe.handle, 0); - watcher->stream = STRUCT_CAST(uv_stream_t, &watcher->uv.pipe.handle); + watcher->stream = (uv_stream_t *)(&watcher->uv.pipe.handle); } watcher->stream->data = watcher; @@ -102,9 +99,8 @@ int socket_watcher_start(SocketWatcher *watcher, int backlog, socket_cb cb) // contain 0 in this case, unless uv_tcp_getsockname() is used first. uv_tcp_getsockname(&watcher->uv.tcp.handle, (struct sockaddr *)&sas, &(int){ sizeof(sas) }); - uint16_t port = (uint16_t)((sas.ss_family == AF_INET) - ? (STRUCT_CAST(struct sockaddr_in, &sas))->sin_port - : (STRUCT_CAST(struct sockaddr_in6, &sas))->sin6_port); + uint16_t port = (sas.ss_family == AF_INET) ? ((struct sockaddr_in *)(&sas))->sin_port + : ((struct sockaddr_in6 *)(&sas))->sin6_port; // v:servername uses the string from watcher->addr size_t len = strlen(watcher->addr); snprintf(watcher->addr + len, sizeof(watcher->addr) - len, ":%" PRIu16, @@ -142,11 +138,11 @@ int socket_watcher_accept(SocketWatcher *watcher, Stream *stream) uv_stream_t *client; if (watcher->stream->type == UV_TCP) { - client = STRUCT_CAST(uv_stream_t, &stream->uv.tcp); + client = (uv_stream_t *)(&stream->uv.tcp); uv_tcp_init(watcher->uv.tcp.handle.loop, (uv_tcp_t *)client); uv_tcp_nodelay((uv_tcp_t *)client, true); } else { - client = STRUCT_CAST(uv_stream_t, &stream->uv.pipe); + client = (uv_stream_t *)&stream->uv.pipe; uv_pipe_init(watcher->uv.pipe.handle.loop, (uv_pipe_t *)client, 0); } @@ -165,7 +161,7 @@ void socket_watcher_close(SocketWatcher *watcher, socket_close_cb cb) FUNC_ATTR_NONNULL_ARG(1) { watcher->close_cb = cb; - uv_close(STRUCT_CAST(uv_handle_t, watcher->stream), close_cb); + uv_close((uv_handle_t *)watcher->stream, close_cb); } static void connection_event(void **argv) @@ -242,11 +238,11 @@ tcp_retry: uv_pipe_t *pipe = &stream->uv.pipe; uv_pipe_init(&loop->uv, pipe, 0); uv_pipe_connect(&req, pipe, address, connect_cb); - uv_stream = STRUCT_CAST(uv_stream_t, pipe); + uv_stream = (uv_stream_t *)pipe; } status = 1; LOOP_PROCESS_EVENTS_UNTIL(&main_loop, NULL, timeout, status != 1); - if (status == 0) { // -V547 + if (status == 0) { stream_init(NULL, stream, -1, uv_stream); success = true; } else if (is_tcp && addrinfo->ai_next) { diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c index 0a4918636a..49b5be23c8 100644 --- a/src/nvim/event/stream.c +++ b/src/nvim/event/stream.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include @@ -37,9 +34,8 @@ int stream_set_blocking(int fd, bool blocking) uv_loop_init(&loop); uv_pipe_init(&loop, &stream, 0); uv_pipe_open(&stream, fd); - int retval = uv_stream_set_blocking(STRUCT_CAST(uv_stream_t, &stream), - blocking); - uv_close(STRUCT_CAST(uv_handle_t, &stream), NULL); + int retval = uv_stream_set_blocking((uv_stream_t *)&stream, blocking); + uv_close((uv_handle_t *)&stream, NULL); uv_run(&loop, UV_RUN_NOWAIT); // not necessary, but couldn't hurt. uv_loop_close(&loop); return retval; @@ -71,12 +67,12 @@ void stream_init(Loop *loop, Stream *stream, int fd, uv_stream_t *uvstream) dwMode |= ENABLE_VIRTUAL_TERMINAL_INPUT; SetConsoleMode(stream->uv.tty.handle, dwMode); } - stream->uvstream = STRUCT_CAST(uv_stream_t, &stream->uv.tty); + stream->uvstream = (uv_stream_t *)&stream->uv.tty; } else { #endif uv_pipe_init(&loop->uv, &stream->uv.pipe, 0); uv_pipe_open(&stream->uv.pipe, fd); - stream->uvstream = STRUCT_CAST(uv_stream_t, &stream->uv.pipe); + stream->uvstream = (uv_stream_t *)&stream->uv.pipe; #ifdef MSWIN } #endif diff --git a/src/nvim/event/time.c b/src/nvim/event/time.c index c997e3c558..0b624d9547 100644 --- a/src/nvim/event/time.c +++ b/src/nvim/event/time.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include diff --git a/src/nvim/event/wstream.c b/src/nvim/event/wstream.c index 65391ba5cf..b19ff0c7d3 100644 --- a/src/nvim/event/wstream.c +++ b/src/nvim/event/wstream.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 7400501ee3..19d1bdc8e6 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // ex_cmds.c: some functions for command line commands #include diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index e4c04007e0..10b0fd6236 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file ex_cmds2.c /// /// Some more functions for command line commands diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index e8233d512a..88c33088bd 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // ex_docmd.c: functions for executing an Ex command line. #include @@ -1127,7 +1124,7 @@ static void get_wincmd_addr_type(const char *arg, exarg_T *eap) case 'd': case Ctrl_D: // window size or any count - eap->addr_type = ADDR_OTHER; // -V1037 + eap->addr_type = ADDR_OTHER; break; case Ctrl_HAT: diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index b7c07ce02c..60dd5a076e 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file ex_eval.c /// /// Functions for Ex command line for the +eval feature. diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index ce47471976..912eab2a31 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // ex_getln.c: Functions for entering and editing an Ex command line. #include @@ -609,7 +606,7 @@ static void finish_incsearch_highlighting(int gotesc, incsearch_state_T *s, bool curwin->w_cursor = s->save_cursor; setpcmark(); } - curwin->w_cursor = s->search_start; // -V519 + curwin->w_cursor = s->search_start; } restore_viewstate(curwin, &s->old_viewstate); highlight_match = false; @@ -3386,7 +3383,7 @@ void ui_ext_cmdline_block_append(size_t indent, const char *line) { char *buf = xmallocz(indent + strlen(line)); memset(buf, ' ', indent); - memcpy(buf + indent, line, strlen(line)); // -V575 + memcpy(buf + indent, line, strlen(line)); Array item = ARRAY_DICT_INIT; ADD(item, INTEGER_OBJ(0)); diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c index 32235e158b..88c690a6a9 100644 --- a/src/nvim/ex_session.c +++ b/src/nvim/ex_session.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Functions for creating a session file, i.e. implementing: // :mkexrc // :mkvimrc diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c index 434be75af0..17335d7a4b 100644 --- a/src/nvim/extmark.c +++ b/src/nvim/extmark.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Implements extended marks for plugins. Marks sit in a MarkTree // datastructure which provides both efficient mark insertations/lookups // and adjustment to text changes. See marktree.c for more details. diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index 5bdaaa880e..2dbe93c6b2 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // File searching functions for 'path', 'tags' and 'cdpath' options. // // External visible functions: @@ -1547,7 +1544,7 @@ void do_autocmd_dirchanged(char *new_dir, CdScope scope, CdCause cause, bool pre } else { tv_dict_add_str(dict, S_LEN("cwd"), new_dir); } - tv_dict_add_str(dict, S_LEN("scope"), buf); // -V614 + tv_dict_add_str(dict, S_LEN("scope"), buf); tv_dict_add_bool(dict, S_LEN("changed_window"), cause == kCdCauseWindow); tv_dict_set_keys_readonly(dict); diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index e57fb9664b..3010ded1d0 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // fileio.c: read from and write to a file #include @@ -935,7 +932,7 @@ retry: if (conv_restlen > 0) { // Insert unconverted bytes from previous line. - memmove(ptr, conv_rest, (size_t)conv_restlen); // -V614 + memmove(ptr, conv_rest, (size_t)conv_restlen); ptr += conv_restlen; size -= conv_restlen; } diff --git a/src/nvim/fold.c b/src/nvim/fold.c index b5b55b1b16..4c596d9d96 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // vim: set fdm=marker fdl=1 fdc=3 // fold.c: code for folding @@ -2741,7 +2738,6 @@ static void truncate_fold(win_T *const wp, fold_T *fp, linenr_T end) } #define FOLD_END(fp) ((fp)->fd_top + (fp)->fd_len - 1) -// -V:VALID_FOLD:V560 #define VALID_FOLD(fp, gap) \ ((gap)->ga_len > 0 && (fp) < ((fold_T *)(gap)->ga_data + (gap)->ga_len)) #define FOLD_INDEX(fp, gap) ((size_t)((fp) - ((fold_T *)(gap)->ga_data))) diff --git a/src/nvim/garray.c b/src/nvim/garray.c index 4df6ec2431..013d7b3fb0 100644 --- a/src/nvim/garray.c +++ b/src/nvim/garray.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file garray.c /// /// Functions for handling growing arrays. diff --git a/src/nvim/generators/gen_api_dispatch.lua b/src/nvim/generators/gen_api_dispatch.lua index 02648e6c99..6cdcf56783 100644 --- a/src/nvim/generators/gen_api_dispatch.lua +++ b/src/nvim/generators/gen_api_dispatch.lua @@ -550,8 +550,6 @@ end output = io.open(lua_c_bindings_outputf, 'wb') output:write([[ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com #include #include #include diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 2370df916c..47577714bb 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // getchar.c: Code related to getting a character from the user or a script // file, manipulations with redo buffer and stuff buffer. diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 4d0a6eb854..9e09555a1b 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -426,7 +426,6 @@ EXTERN win_T *prevwin INIT( = NULL); // previous window FOR_ALL_TABS(tp) \ FOR_ALL_WINDOWS_IN_TAB(wp, tp) -// -V:FOR_ALL_WINDOWS_IN_TAB:501 #define FOR_ALL_WINDOWS_IN_TAB(wp, tp) \ for (win_T *wp = ((tp) == curtab) \ ? firstwin : (tp)->tp_firstwin; wp != NULL; wp = wp->w_next) diff --git a/src/nvim/grid.c b/src/nvim/grid.c index 45bffdcab5..15b648bb03 100644 --- a/src/nvim/grid.c +++ b/src/nvim/grid.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Most of the routines in this file perform screen (grid) manipulations. The // given operation is performed physically on the screen. The corresponding // change is also made to the internal screen image. In this way, the editor diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c index ba88d92b0a..f3ba0e8fc2 100644 --- a/src/nvim/hashtab.c +++ b/src/nvim/hashtab.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file hashtab.c /// /// Handling of a hashtable with Vim-specific properties. diff --git a/src/nvim/help.c b/src/nvim/help.c index 4040c93347..3e7577505d 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // help.c: functions for Vim help #include diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c index 6d6bcacd83..cff62e736b 100644 --- a/src/nvim/highlight.c +++ b/src/nvim/highlight.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // highlight.c: low level code for UI and syntax highlighting #include @@ -349,7 +346,7 @@ void update_window_hl(win_T *wp, bool invalid) wp->w_ns_hl_active = ns_id; wp->w_ns_hl_attr = *(NSHlAttr *)pmap_get(int)(&ns_hl_attr, ns_id); - if (!wp->w_ns_hl_attr) { // -V547 + if (!wp->w_ns_hl_attr) { // No specific highlights, use the defaults. wp->w_ns_hl_attr = highlight_attr; } diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index ec35da54d2..660e37adc2 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // highlight_group.c: code for managing highlight groups #include diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 05a4fd1450..1bf2379bd9 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index b4e56504a7..d79dea4d83 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/input.c b/src/nvim/input.c index acac240a8b..2f5eb49ce0 100644 --- a/src/nvim/input.c +++ b/src/nvim/input.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // input.c: high level functions for prompting the user or input // like yes/no or number prompts. diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 31275ff339..b62a48f056 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // insexpand.c: functions for Insert mode completion #include diff --git a/src/nvim/keycodes.c b/src/nvim/keycodes.c index e0279e39b6..dcb1b74198 100644 --- a/src/nvim/keycodes.c +++ b/src/nvim/keycodes.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/linematch.c b/src/nvim/linematch.c index 01c035a4dd..1524731fab 100644 --- a/src/nvim/linematch.c +++ b/src/nvim/linematch.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/log.c b/src/nvim/log.c index 84b6e9ece7..27bad72278 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // // Log module // diff --git a/src/nvim/lua/base64.c b/src/nvim/lua/base64.c index b6382f6eab..3f246839d5 100644 --- a/src/nvim/lua/base64.c +++ b/src/nvim/lua/base64.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index c041fdb26c..fc39fb48b6 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 876a5c34bd..716fe5e481 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/lua/secure.c b/src/nvim/lua/secure.c index 194c80fdc9..65c13f8872 100644 --- a/src/nvim/lua/secure.c +++ b/src/nvim/lua/secure.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/lua/spell.c b/src/nvim/lua/spell.c index 8f80744ac8..2575c3d95d 100644 --- a/src/nvim/lua/spell.c +++ b/src/nvim/lua/spell.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c index 606c9878e6..5072d14c0e 100644 --- a/src/nvim/lua/stdlib.c +++ b/src/nvim/lua/stdlib.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c index 57469f6358..ff942630a0 100644 --- a/src/nvim/lua/treesitter.c +++ b/src/nvim/lua/treesitter.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // lua bindings for tree-sitter. // NB: this file mostly contains a generic lua interface for tree-sitter // trees and nodes, and could be broken out as a reusable lua package diff --git a/src/nvim/lua/xdiff.c b/src/nvim/lua/xdiff.c index e131bbb586..f3f78b79f5 100644 --- a/src/nvim/lua/xdiff.c +++ b/src/nvim/lua/xdiff.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/macros.h b/src/nvim/macros.h index b4034fe4f7..6a999489e2 100644 --- a/src/nvim/macros.h +++ b/src/nvim/macros.h @@ -61,8 +61,6 @@ /// Don't apply 'langmap' if the character comes from the Stuff buffer or from a /// mapping and the langnoremap option was set. /// The do-while is just to ignore a ';' after the macro. -/// -/// -V:LANGMAP_ADJUST:560 #define LANGMAP_ADJUST(c, condition) \ do { \ if (*p_langmap \ @@ -111,8 +109,6 @@ /// error. A mechanism to detect many (though not all) of those errors at /// compile time is implemented. It works by the second division producing /// a division by zero in those cases (-Wdiv-by-zero in GCC). -/// -/// -V:ARRAY_SIZE:1063 #define ARRAY_SIZE(arr) \ ((sizeof(arr)/sizeof((arr)[0])) \ / ((size_t)(!(sizeof(arr) % sizeof((arr)[0]))))) @@ -162,18 +158,6 @@ # define UNREACHABLE #endif -// -V:STRUCT_CAST:641 - -/// Change type of structure pointers: cast `struct a *` to `struct b *` -/// -/// Used to silence PVS errors. -/// -/// @param Type Structure to cast to. -/// @param obj Object to cast. -/// -/// @return ((Type *)obj). -#define STRUCT_CAST(Type, obj) ((Type *)(obj)) - // Type of uv_buf_t.len is platform-dependent. // Related: https://github.com/libuv/libuv/pull/1236 #if defined(MSWIN) diff --git a/src/nvim/main.c b/src/nvim/main.c index bb673b51dc..f80fb98918 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Make sure extern symbols are exported on Windows #ifdef WIN32 # define EXTERN __declspec(dllexport) @@ -866,7 +863,7 @@ void preserve_exit(const char *errmsg) static int get_number_arg(const char *p, int *idx, int def) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { - if (ascii_isdigit(p[*idx])) { // -V522 + if (ascii_isdigit(p[*idx])) { def = atoi(&(p[*idx])); while (ascii_isdigit(p[*idx])) { *idx = *idx + 1; diff --git a/src/nvim/map.c b/src/nvim/map.c index 57e39b1d72..9af13182e5 100644 --- a/src/nvim/map.c +++ b/src/nvim/map.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // map.c: Hash maps and sets // // parts of the implementation derived from khash.h as part of klib (MIT license) diff --git a/src/nvim/map_glyph_cache.c b/src/nvim/map_glyph_cache.c index e79c8ecee8..ba3ee49499 100644 --- a/src/nvim/map_glyph_cache.c +++ b/src/nvim/map_glyph_cache.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Specialized version of Set() where interned strings is stored in a compact, // NUL-separated char array. // `String key` lookup keys don't need to be NULL terminated, but they diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c index 467041e310..77fdd02a14 100644 --- a/src/nvim/mapping.c +++ b/src/nvim/mapping.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // mapping.c: Code for mappings and abbreviations. #include diff --git a/src/nvim/mark.c b/src/nvim/mark.c index 2a786af802..b4d405e2f1 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // mark.c: functions for setting marks and jumping to them #include diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c index 214d228b2c..05aa4527ae 100644 --- a/src/nvim/marktree.c +++ b/src/nvim/marktree.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Tree data structure for storing marks at (row, col) positions and updating // them to arbitrary text changes. Derivative work of kbtree in klib, whose // copyright notice is reproduced below. Also inspired by the design of the diff --git a/src/nvim/match.c b/src/nvim/match.c index d153ea042d..5ecccdd1dd 100644 --- a/src/nvim/match.c +++ b/src/nvim/match.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // match.c: functions for highlighting matches #include @@ -536,7 +533,7 @@ void prepare_search_hl(win_T *wp, match_T *search_hl, linenr_T lnum) shl = search_hl; shl_flag = true; } else { - shl = &cur->mit_hl; // -V595 + shl = &cur->mit_hl; } if (shl->rm.regprog != NULL && shl->lnum == 0 @@ -614,7 +611,7 @@ bool prepare_search_hl_line(win_T *wp, linenr_T lnum, colnr_T mincol, char **lin shl = search_hl; shl_flag = true; } else { - shl = &cur->mit_hl; // -V595 + shl = &cur->mit_hl; } shl->startcol = MAXCOL; shl->endcol = MAXCOL; diff --git a/src/nvim/math.c b/src/nvim/math.c index 31c6b5af69..d51a3947ae 100644 --- a/src/nvim/math.c +++ b/src/nvim/math.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // uncrustify:off #include // uncrustify:on diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 6f830d3efd..39ee65d9d3 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// mbyte.c: Code specifically for handling multi-byte characters. /// Multibyte extensions partly by Sung-Hoon Baek /// diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c index 1cfd11e205..ae35427666 100644 --- a/src/nvim/memfile.c +++ b/src/nvim/memfile.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// An abstraction to handle blocks of memory which can be stored in a file. /// This is the implementation of a sort of virtual memory. /// diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 42852079ed..087661799a 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // for debugging // #define CHECK(c, s) do { if (c) emsg(s); } while (0) #define CHECK(c, s) do {} while (0) @@ -615,7 +612,7 @@ static bool ml_check_b0_strings(ZeroBlock *b0p) return (memchr(b0p->b0_version, NUL, 10) && memchr(b0p->b0_uname, NUL, B0_UNAME_SIZE) && memchr(b0p->b0_hname, NUL, B0_HNAME_SIZE) - && memchr(b0p->b0_fname, NUL, B0_FNAME_SIZE_CRYPT)); // -V1086 + && memchr(b0p->b0_fname, NUL, B0_FNAME_SIZE_CRYPT)); } /// Update the timestamp or the B0_SAME_DIR flag of the .swp file. @@ -984,9 +981,9 @@ void ml_recover(bool checkext) linenr_T line_count = 0; int idx = 0; // start with first index in block 1 int error = 0; - buf->b_ml.ml_stack_top = 0; // -V1048 + buf->b_ml.ml_stack_top = 0; buf->b_ml.ml_stack = NULL; - buf->b_ml.ml_stack_size = 0; // -V1048 + buf->b_ml.ml_stack_size = 0; bool cannot_open = (curbuf->b_ffname == NULL); diff --git a/src/nvim/memory.c b/src/nvim/memory.c index 27b1bfc105..4c7e42321d 100644 --- a/src/nvim/memory.c +++ b/src/nvim/memory.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Various routines dealing with allocation and deallocation of memory. #include diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 5fa731141e..0e6b91090a 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Code for menus. Used for the GUI and 'wildmenu'. // GUI/Motif support by Robert Webb diff --git a/src/nvim/message.c b/src/nvim/message.c index 916b6f2464..dbef962551 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // message.c: functions for displaying messages on the command line #include @@ -2116,7 +2113,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse) msg_ext_last_attr = attr; } // Concat pieces with the same highlight - size_t len = strnlen(str, (size_t)maxlen); // -V781 + size_t len = strnlen(str, (size_t)maxlen); ga_concat_len(&msg_ext_last_chunk, str, len); msg_ext_cur_len += len; return; diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index a9914c439b..141910f9df 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/move.c b/src/nvim/move.c index c4af2b6701..7a4e98adc5 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // move.c: Functions for moving the cursor and scrolling text. // // There are two ways to move the cursor: diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 597aa56fa7..f14612ca8a 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index 5a3f31b7f5..02897e339c 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/msgpack_rpc/server.c b/src/nvim/msgpack_rpc/server.c index c6a0a4d8cc..328d902f0f 100644 --- a/src/nvim/msgpack_rpc/server.c +++ b/src/nvim/msgpack_rpc/server.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/msgpack_rpc/unpacker.c b/src/nvim/msgpack_rpc/unpacker.c index 9b7fc3fbb7..9fd80e506a 100644 --- a/src/nvim/msgpack_rpc/unpacker.c +++ b/src/nvim/msgpack_rpc/unpacker.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include @@ -381,7 +378,6 @@ bool unpacker_parse_redraw(Unpacker *p) size_t size = p->read_size; GridLineEvent *g = p->grid_line_event; -// -V:NEXT_TYPE:501 #define NEXT_TYPE(tok, typ) \ result = mpack_rtoken(&data, &size, &tok); \ if (result == MPACK_EOF) { \ diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 418097a82a..f0f3d35468 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // // normal.c: Contains the main routine for processing characters in command // mode. Communicates closely with the code in ops.c to handle @@ -1712,7 +1709,7 @@ size_t find_ident_at_pos(win_T *wp, linenr_T lnum, colnr_T startcol, char **text col = 0; // Search for point of changing multibyte character class. this_class = mb_get_class(ptr); - while (ptr[col] != NUL // -V781 + while (ptr[col] != NUL && ((i == 0 ? mb_get_class(ptr + col) == this_class : mb_get_class(ptr + col) != 0) diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 8acbf10efd..bcaad27040 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // ops.c: implementation of various operators: op_shift, op_delete, op_tilde, // op_change, op_yank, do_put, do_join @@ -3837,7 +3834,7 @@ void ex_display(exarg_T *eap) n -= 2; } for (p = yb->y_array[j]; - *p != NUL && (n -= ptr2cells(p)) >= 0; p++) { // -V1019 + *p != NUL && (n -= ptr2cells(p)) >= 0; p++) { clen = utfc_ptr2len(p); msg_outtrans_len(p, clen, 0); p += clen - 1; @@ -6733,7 +6730,7 @@ static void set_clipboard(int name, yankreg_T *reg) list_T *args = tv_list_alloc(3); tv_list_append_list(args, lines); - tv_list_append_string(args, ®type, 1); // -V614 + tv_list_append_string(args, ®type, 1); tv_list_append_string(args, ((char[]) { (char)name }), 1); (void)eval_call_provider("clipboard", "set", args, true); diff --git a/src/nvim/option.c b/src/nvim/option.c index 1461911609..23d5960579 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // User-settable options. Checklist for adding a new option: // - Put it in options.lua // - For a global option: Add a variable for it in option_defs.h. @@ -3614,7 +3611,7 @@ static const char *did_set_option(int opt_idx, void *varp, OptVal old_value, Opt } // Unset new_value as it is no longer valid. - new_value = NIL_OPTVAL; // -V1001 NOLINT(clang-analyzer-deadcode.DeadStores) + new_value = NIL_OPTVAL; // NOLINT(clang-analyzer-deadcode.DeadStores) return errmsg; } diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c index 80f879e9db..e363f02644 100644 --- a/src/nvim/optionstr.c +++ b/src/nvim/optionstr.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/os/dl.c b/src/nvim/os/dl.c index 519cef7876..67164f56b4 100644 --- a/src/nvim/os/dl.c +++ b/src/nvim/os/dl.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// Functions for using external native libraries #include diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index dbea6f01df..20dc6a159c 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Environment inspection #include @@ -933,7 +930,7 @@ char *vim_getenv(const char *name) if (append_path(exe_name, "share" _PATHSEPSTR "nvim" _PATHSEPSTR "runtime" _PATHSEPSTR, MAXPATHL) == OK) { - vim_path = exe_name; // -V507 + vim_path = exe_name; } } diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c index 119a42f074..ed0a97aac9 100644 --- a/src/nvim/os/fileio.c +++ b/src/nvim/os/fileio.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file fileio.c /// /// Buffered reading/writing to a file. Unlike fileio.c this is not dealing with @@ -53,7 +50,6 @@ int file_open(FileDescriptor *const ret_fp, const char *const fname, const int f { int os_open_flags = 0; TriState wr = kNone; - // -V:FLAG:501 #define FLAG(flags, flag, fcntl_flags, wrval, cond) \ do { \ if (flags & flag) { \ diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 9a448d69ae..6b3f79abb2 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // fs.c -- filesystem access #include #include diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 03418f4548..5c26a94196 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/os/lang.c b/src/nvim/os/lang.c index 602dcc9bd3..d14c086a4f 100644 --- a/src/nvim/os/lang.c +++ b/src/nvim/os/lang.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #ifdef __APPLE__ # define Boolean CFBoolean // Avoid conflict with API's Boolean # define FileInfo CSFileInfo // Avoid conflict with API's Fileinfo diff --git a/src/nvim/os/mem.c b/src/nvim/os/mem.c index 0b7e8065ef..3e6264c691 100644 --- a/src/nvim/os/mem.c +++ b/src/nvim/os/mem.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// Functions for accessing system memory information. #include diff --git a/src/nvim/os/os_win_console.c b/src/nvim/os/os_win_console.c index 006e27d28f..af0c28a308 100644 --- a/src/nvim/os/os_win_console.c +++ b/src/nvim/os/os_win_console.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/os/os_win_console.h" diff --git a/src/nvim/os/process.c b/src/nvim/os/process.c index a636689f97..889d1f453f 100644 --- a/src/nvim/os/process.c +++ b/src/nvim/os/process.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// OS process functions /// /// psutil is a good reference for cross-platform syscall voodoo: diff --git a/src/nvim/os/pty_conpty_win.c b/src/nvim/os/pty_conpty_win.c index 32067ad49f..819b6fcf77 100644 --- a/src/nvim/os/pty_conpty_win.c +++ b/src/nvim/os/pty_conpty_win.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include "nvim/os/os.h" diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c index efd476ae7b..f3a841f7d0 100644 --- a/src/nvim/os/pty_process_unix.c +++ b/src/nvim/os/pty_process_unix.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Some of the code came from pangoterm and libuv #include diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index 763d30d4a2..19eedd14cd 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 2f52895357..b3ce4a3c91 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index 4c4ac9df1e..e73a579a27 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/os/stdpaths.c b/src/nvim/os/stdpaths.c index 8ea30ff21e..5aeecb8cda 100644 --- a/src/nvim/os/stdpaths.c +++ b/src/nvim/os/stdpaths.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c index ac98f0cf9a..8aa3170963 100644 --- a/src/nvim/os/time.c +++ b/src/nvim/os/time.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/os/tty.c b/src/nvim/os/tty.c index b5124bd83a..e683b9383f 100644 --- a/src/nvim/os/tty.c +++ b/src/nvim/os/tty.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // // Terminal/console utils // diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c index b23d2b7b13..b61dcd1e4b 100644 --- a/src/nvim/os/users.c +++ b/src/nvim/os/users.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // users.c -- operating system user information #include diff --git a/src/nvim/path.c b/src/nvim/path.c index f552f24495..d08866ed14 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include @@ -736,7 +733,7 @@ static size_t do_path_expand(garray_T *gap, const char *path, size_t wildoff, in || starts_with_dot || ((flags & EW_DODOT) && name[1] != NUL - && (name[1] != '.' || name[2] != NUL))) // -V557 + && (name[1] != '.' || name[2] != NUL))) && ((regmatch.regprog != NULL && vim_regexec(®match, name, 0)) || ((flags & EW_NOTWILD) && path_fnamencmp(path + (s - buf), name, (size_t)(e - s)) == 0))) { diff --git a/src/nvim/plines.c b/src/nvim/plines.c index 64dd3ff4d4..3a168320e4 100644 --- a/src/nvim/plines.c +++ b/src/nvim/plines.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // plines.c: calculate the vertical and horizontal size of text in a window #include diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c index 0a5da7d36e..7db8fe01b7 100644 --- a/src/nvim/popupmenu.c +++ b/src/nvim/popupmenu.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file popupmenu.c /// /// Popup menu (PUM) diff --git a/src/nvim/profile.c b/src/nvim/profile.c index 69be4ba5fd..3e824fc34f 100644 --- a/src/nvim/profile.c +++ b/src/nvim/profile.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index a9d048d998..19b34b52b4 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // quickfix.c: functions for quickfix mode, using a file with error messages #include @@ -2812,8 +2809,8 @@ static int qf_jump_edit_buffer(qf_info_T *qi, qfline_T *qf_ptr, int forceit, int return QF_ABORT; } - if (old_qf_curlist != qi->qf_curlist // -V560 - || old_changetick != qfl->qf_changedtick // -V560 + if (old_qf_curlist != qi->qf_curlist + || old_changetick != qfl->qf_changedtick || !is_qf_entry_present(qfl, qf_ptr)) { if (qfl_type == QFLT_QUICKFIX) { emsg(_(e_current_quickfix_list_was_changed)); @@ -2921,7 +2918,7 @@ static int qf_jump_open_window(qf_info_T *qi, qfline_T *qf_ptr, bool newwin, int } } if (old_qf_curlist != qi->qf_curlist - || old_changetick != qfl->qf_changedtick // -V560 + || old_changetick != qfl->qf_changedtick || !is_qf_entry_present(qfl, qf_ptr)) { if (qfl_type == QFLT_QUICKFIX) { emsg(_(e_current_quickfix_list_was_changed)); diff --git a/src/nvim/rbuffer.c b/src/nvim/rbuffer.c index 1088dd3778..dd6402a70d 100644 --- a/src/nvim/rbuffer.c +++ b/src/nvim/rbuffer.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/rbuffer.h b/src/nvim/rbuffer.h index 63d5119004..dddf34b095 100644 --- a/src/nvim/rbuffer.h +++ b/src/nvim/rbuffer.h @@ -38,8 +38,6 @@ struct rbuffer; // // Note that the rbuffer_{produced,consumed} calls are necessary or these macros // create infinite loops -// -// -V:RBUFFER_UNTIL_EMPTY:1044 #define RBUFFER_UNTIL_EMPTY(buf, rptr, rcnt) \ for (size_t rcnt = 0, _r = 1; _r; _r = 0) /* NOLINT(readability/braces) */ \ for (char *rptr = rbuffer_read_ptr(buf, &rcnt); /* NOLINT(readability/braces) */ \ diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index c908f94e5d..8151d2e12a 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Handling of regular expressions: vim_regcomp(), vim_regexec(), vim_regsub() // By default: do not create debugging logs or files related to regular @@ -1004,7 +1001,7 @@ static int64_t getoctchrs(void) int c; int i; - for (i = 0; i < 3 && nr < 040; i++) { // -V536 + for (i = 0; i < 3 && nr < 040; i++) { c = (uint8_t)regparse[0]; if (c < '0' || c > '7') { break; @@ -2301,7 +2298,7 @@ char *reg_submatch(int no) } len += rsm.sm_mmatch->endpos[no].col; if (round == 2) { - retval[len] = NUL; // -V595 + retval[len] = NUL; } len++; } @@ -2583,7 +2580,6 @@ static void init_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_ #define UPPER 47 // Match uppercase char #define NUPPER 48 // Match non-uppercase char #define LAST_NL NUPPER + ADD_NL -// -V:WITH_NL:560 #define WITH_NL(op) ((op) >= FIRST_NL && (op) <= LAST_NL) #define MOPEN 80 // -89 Mark this point in input as start of @@ -9818,7 +9814,7 @@ static int nfa_regatom(void) case Magic('|'): case Magic('&'): case Magic(')'): - semsg(_(e_misplaced), (char)no_Magic(c)); // -V1037 + semsg(_(e_misplaced), (char)no_Magic(c)); return FAIL; case Magic('='): @@ -12911,7 +12907,7 @@ skip_add: if (state->c == NFA_ZSTART) { subidx = 0; sub = &subs->norm; - } else if (state->c >= NFA_ZOPEN && state->c <= NFA_ZOPEN9) { // -V560 + } else if (state->c >= NFA_ZOPEN && state->c <= NFA_ZOPEN9) { subidx = state->c - NFA_ZOPEN; sub = &subs->synt; } else { @@ -12966,7 +12962,7 @@ skip_add: break; } // "subs" may have changed, need to set "sub" again. - if (state->c >= NFA_ZOPEN && state->c <= NFA_ZOPEN9) { // -V560 + if (state->c >= NFA_ZOPEN && state->c <= NFA_ZOPEN9) { sub = &subs->synt; } else { sub = &subs->norm; @@ -13016,7 +13012,7 @@ skip_add: if (state->c == NFA_ZEND) { subidx = 0; sub = &subs->norm; - } else if (state->c >= NFA_ZCLOSE && state->c <= NFA_ZCLOSE9) { // -V560 + } else if (state->c >= NFA_ZCLOSE && state->c <= NFA_ZCLOSE9) { subidx = state->c - NFA_ZCLOSE; sub = &subs->synt; } else { @@ -13054,7 +13050,7 @@ skip_add: break; } // "subs" may have changed, need to set "sub" again. - if (state->c >= NFA_ZCLOSE && state->c <= NFA_ZCLOSE9) { // -V560 + if (state->c >= NFA_ZCLOSE && state->c <= NFA_ZCLOSE9) { sub = &subs->synt; } else { sub = &subs->norm; diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index 47bbe64c96..1438385e66 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file runtime.c /// /// Management of runtime files (including packages) diff --git a/src/nvim/search.c b/src/nvim/search.c index aa942d8185..6c0616ffb9 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // search.c: code for normal mode searching commands #include @@ -1171,7 +1168,7 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char *pat, int count, in // Get the offset, so we know how long it is. if (!cmd_silent && (spats[0].off.line || spats[0].off.end || spats[0].off.off)) { - p = off_buf; // -V507 + p = off_buf; *p++ = (char)dirc; if (spats[0].off.end) { *p++ = 'e'; diff --git a/src/nvim/sha256.c b/src/nvim/sha256.c index cc988812d5..d179a0c279 100644 --- a/src/nvim/sha256.c +++ b/src/nvim/sha256.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file sha256.c /// /// FIPS-180-2 compliant SHA-256 implementation diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 0729368b9c..97d9ae07a5 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include @@ -3896,7 +3893,7 @@ shada_read_next_item_start: // XXX: Temporarily reassign `i` because the macros depend on it. const size_t j = i; { - for (i = 0; i < unpacked_2.data.via.map.size; i++) { // -V535 + for (i = 0; i < unpacked_2.data.via.map.size; i++) { CHECK_KEY_IS_STR(unpacked_2, "buffer list entry") INTEGER_KEY(unpacked_2, "buffer list entry", KEY_LNUM, entry->data.buffer_list.buffers[j].pos.lnum) diff --git a/src/nvim/sign.c b/src/nvim/sign.c index b70429928d..73ef1580ba 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // sign.c: functions for managing with signs #include diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 5f5cabdc40..5f3bd0ae06 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // spell.c: code for spell checking // // See spellfile.c for the Vim spell file format. diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 555af8bc50..9bf5ef3ed8 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // spellfile.c: code for reading and writing spell files. // // See spell.c for information about spell checking. @@ -1692,7 +1689,7 @@ static int spell_read_tree(FILE *fd, uint8_t **bytsp, int *bytsp_len, idx_T **id if (len < 0) { return SP_TRUNCERROR; } - if ((size_t)len >= SIZE_MAX / sizeof(int)) { // -V547 + if ((size_t)len >= SIZE_MAX / sizeof(int)) { // Invalid length, multiply with sizeof(int) would overflow. return SP_FORMERROR; } diff --git a/src/nvim/spellsuggest.c b/src/nvim/spellsuggest.c index 15ec652859..15a58a4434 100644 --- a/src/nvim/spellsuggest.c +++ b/src/nvim/spellsuggest.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // spellsuggest.c: functions for spelling suggestions #include @@ -1173,7 +1170,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun // word). int depth = 0; trystate_T *sp = &stack[0]; - CLEAR_POINTER(sp); // -V1086 + CLEAR_POINTER(sp); sp->ts_curi = 1; if (soundfold) { diff --git a/src/nvim/state.c b/src/nvim/state.c index d2466e4248..1c00a00d8c 100644 --- a/src/nvim/state.c +++ b/src/nvim/state.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index 200478231a..2f989491d0 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 26da38f284..007d088bbb 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include @@ -603,7 +600,7 @@ static const void *tv_ptr(const typval_T *const tvs, int *const idxp) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { #define OFF(attr) offsetof(union typval_vval_union, attr) - STATIC_ASSERT(OFF(v_string) == OFF(v_list) // -V568 + STATIC_ASSERT(OFF(v_string) == OFF(v_list) && OFF(v_string) == OFF(v_dict) && OFF(v_string) == OFF(v_partial) && sizeof(tvs[0].vval.v_string) == sizeof(tvs[0].vval.v_list) diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 42b2302fa5..67d762d546 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // syntax.c: code for syntax highlighting #include @@ -239,8 +236,6 @@ static keyentry_T dumkey; #define HIKEY2KE(p) ((keyentry_T *)((p) - (dumkey.keyword - (char *)&dumkey))) #define HI2KE(hi) HIKEY2KE((hi)->hi_key) -// -V:HI2KE:782 - // To reduce the time spent in keepend(), remember at which level in the state // stack the first item with "keepend" is present. When "-1", there is no // "keepend" on the stack. @@ -5059,7 +5054,7 @@ static int get_id_list(char **const arg, const int keylen, int16_t **const list, xfree(retval); round = 1; } else { - retval[count] = (int16_t)(i + 1); // -V522 + retval[count] = (int16_t)(i + 1); } } count++; diff --git a/src/nvim/tag.c b/src/nvim/tag.c index a916313982..198a4c51a1 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Code to handle tags and the tag stack #include @@ -340,7 +337,7 @@ void do_tag(char *tag, int type, int count, int forceit, int verbose) // Don't add a tag to the tagstack if 'tagstack' has been reset. assert(tag != NULL); - if (!p_tgst && *tag != NUL) { // -V522 + if (!p_tgst && *tag != NUL) { use_tagstack = false; new_tag = true; if (g_do_tagpreview != 0) { @@ -3021,7 +3018,7 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help) } } p_ws = save_p_ws; - p_ic = save_p_ic; // -V519 + p_ic = save_p_ic; p_scs = save_p_scs; // A search command may have positioned the cursor beyond the end diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 465d1d0cbc..ca9777f1d6 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // VT220/xterm-like terminal emulator. // Powered by libvterm http://www.leonerd.org.uk/code/libvterm // @@ -236,7 +233,7 @@ void terminal_open(Terminal **termpp, buf_T *buf, TerminalOptions opts) aucmd_prepbuf(&aco, buf); refresh_screen(rv, buf); - set_option_value("buftype", STATIC_CSTR_AS_OPTVAL("terminal"), OPT_LOCAL); // -V666 + set_option_value("buftype", STATIC_CSTR_AS_OPTVAL("terminal"), OPT_LOCAL); // Default settings for terminal buffers buf->b_p_ma = false; // 'nomodifiable' @@ -259,7 +256,7 @@ void terminal_open(Terminal **termpp, buf_T *buf, TerminalOptions opts) aucmd_restbuf(&aco); - if (*termpp == NULL) { // -V547 + if (*termpp == NULL) { return; // Terminal has already been destroyed. } @@ -731,7 +728,7 @@ void terminal_paste(int count, char **y_array, size_t y_size) vterm_keyboard_start_paste(curbuf->terminal->vt); size_t buff_len = strlen(y_array[0]); char *buff = xmalloc(buff_len); - for (int i = 0; i < count; i++) { // -V756 + for (int i = 0; i < count; i++) { // feed the lines to the terminal for (size_t j = 0; j < y_size; j++) { if (j) { diff --git a/src/nvim/testing.c b/src/nvim/testing.c index eea75f3021..4120da745f 100644 --- a/src/nvim/testing.c +++ b/src/nvim/testing.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // testing.c: Support for tests #include @@ -703,7 +700,7 @@ static int assert_inrange(typval_T *argvars) char expected_str[200]; vim_snprintf(expected_str, sizeof(expected_str), "range %" PRIdVARNUMBER " - %" PRIdVARNUMBER ",", - lower, upper); // -V576 + lower, upper); fill_assert_error(&ga, &argvars[3], expected_str, NULL, &argvars[2], ASSERT_OTHER); assert_error(&ga); ga_clear(&ga); diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c index 564934aa51..96beae0d31 100644 --- a/src/nvim/textformat.c +++ b/src/nvim/textformat.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // textformat.c: text formatting functions #include diff --git a/src/nvim/textobject.c b/src/nvim/textobject.c index c17273255d..00038c7d6d 100644 --- a/src/nvim/textobject.c +++ b/src/nvim/textobject.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // textobject.c: functions for text objects #include diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 4ebf9177de..36d6566c7d 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/tui/terminfo.c b/src/nvim/tui/terminfo.c index d630a34ce2..ff636fb839 100644 --- a/src/nvim/tui/terminfo.c +++ b/src/nvim/tui/terminfo.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Built-in fallback terminfo entries. #include diff --git a/src/nvim/tui/terminfo_defs.h b/src/nvim/tui/terminfo_defs.h index 0bc4972dd3..d010b41574 100644 --- a/src/nvim/tui/terminfo_defs.h +++ b/src/nvim/tui/terminfo_defs.h @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // uncrustify:off // diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 260bf55093..177ef0c3cf 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Terminal UI functions. Invoked (by ui_client.c) on the UI process. #include @@ -439,7 +436,7 @@ static void tui_terminal_after_startup(TUIData *tui) /// stop the terminal but allow it to restart later (like after suspend) static void tui_terminal_stop(TUIData *tui) { - if (uv_is_closing(STRUCT_CAST(uv_handle_t, &tui->output_handle))) { + if (uv_is_closing((uv_handle_t *)&tui->output_handle)) { // Race between SIGCONT (tui.c) and SIGHUP (os/signal.c)? #8075 ELOG("TUI already stopped (race?)"); tui->stopped = true; @@ -1174,9 +1171,8 @@ void tui_mode_change(TUIData *tui, String mode, Integer mode_idx) tui->showing_mode = (ModeShape)mode_idx; } -void tui_grid_scroll(TUIData *tui, Integer g, Integer startrow, // -V751 - Integer endrow, Integer startcol, Integer endcol, Integer rows, - Integer cols FUNC_ATTR_UNUSED) +void tui_grid_scroll(TUIData *tui, Integer g, Integer startrow, Integer endrow, Integer startcol, + Integer endcol, Integer rows, Integer cols FUNC_ATTR_UNUSED) { UGrid *grid = &tui->grid; int top = (int)startrow, bot = (int)endrow - 1; @@ -2250,8 +2246,8 @@ static void flush_buf(TUIData *tui) fwrite(bufs[i].base, bufs[i].len, 1, tui->screenshot); } } else { - int ret = uv_write(&req, STRUCT_CAST(uv_stream_t, &tui->output_handle), - bufs, (unsigned)(bufp - bufs), NULL); + int ret + = uv_write(&req, (uv_stream_t *)&tui->output_handle, bufs, (unsigned)(bufp - bufs), NULL); if (ret) { ELOG("uv_write failed: %s", uv_strerror(ret)); } diff --git a/src/nvim/ugrid.c b/src/nvim/ugrid.c index d3a1097aba..3a422ff2f2 100644 --- a/src/nvim/ugrid.c +++ b/src/nvim/ugrid.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include diff --git a/src/nvim/ugrid.h b/src/nvim/ugrid.h index 1c73c43867..a71179d74f 100644 --- a/src/nvim/ugrid.h +++ b/src/nvim/ugrid.h @@ -22,8 +22,6 @@ struct ugrid { UCell **cells; }; -// -V:UGRID_FOREACH_CELL:625 - #define UGRID_FOREACH_CELL(grid, row, startcol, endcol, code) \ do { \ UCell *row_cells = (grid)->cells[row]; \ diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 90d475e7e7..dc38c061b0 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c index 8e60af478b..dac690822b 100644 --- a/src/nvim/ui_client.c +++ b/src/nvim/ui_client.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// Nvim's own UI client, which attaches to a child or remote Nvim server. #include diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c index 8c16380f1f..2c586e3e22 100644 --- a/src/nvim/ui_compositor.c +++ b/src/nvim/ui_compositor.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // Compositor: merge floating grids with the main grid for display in // TUI and non-multigrid UIs. // diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 741c8b36e5..31a50c0b98 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // undo.c: multi level undo facility // The saved lines are stored in a list of lists (one for each buffer): @@ -1088,7 +1085,7 @@ static u_entry_T *unserialize_uep(bufinfo_T *bi, bool *error, const char *file_n char **array = NULL; if (uep->ue_size > 0) { - if ((size_t)uep->ue_size < SIZE_MAX / sizeof(char *)) { // -V547 + if ((size_t)uep->ue_size < SIZE_MAX / sizeof(char *)) { array = xmalloc(sizeof(char *) * (size_t)uep->ue_size); memset(array, 0, sizeof(char *) * (size_t)uep->ue_size); } @@ -1514,7 +1511,7 @@ void u_read_undo(char *name, const uint8_t *hash, const char *orig_name FUNC_ATT // sequence numbers of the headers. // When there are no headers uhp_table is NULL. if (num_head > 0) { - if ((size_t)num_head < SIZE_MAX / sizeof(*uhp_table)) { // -V547 + if ((size_t)num_head < SIZE_MAX / sizeof(*uhp_table)) { uhp_table = xmalloc((size_t)num_head * sizeof(*uhp_table)); } } diff --git a/src/nvim/usercmd.c b/src/nvim/usercmd.c index e7fa7cec2c..a575d7f4ac 100644 --- a/src/nvim/usercmd.c +++ b/src/nvim/usercmd.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - // usercmd.c: User defined command support #include diff --git a/src/nvim/version.c b/src/nvim/version.c index ddfadeb44e..e3429efbd5 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// @file version.c /// /// Nvim was forked from Vim 7.4.160. diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 0ab58a8b37..784d5c1210 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// Vimscript expression parser // Planned incompatibilities (to be included into vim_diff.txt when this parser diff --git a/src/nvim/viml/parser/parser.c b/src/nvim/viml/parser/parser.c index 1547feba90..b854aedca6 100644 --- a/src/nvim/viml/parser/parser.c +++ b/src/nvim/viml/parser/parser.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include "nvim/viml/parser/parser.h" #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/window.c b/src/nvim/window.c index 929047a330..42c6ff7c60 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include @@ -6713,7 +6710,7 @@ void win_set_inner_size(win_T *wp, bool valid_cursor) // call win_new_height() recursively. validate_cursor(); } - if (wp->w_height_inner != prev_height) { // -V547 + if (wp->w_height_inner != prev_height) { return; // Recursive call already changed the size, bail out. } if (wp->w_wrow != wp->w_prev_fraction_row) { diff --git a/test/functional/fixtures/printargs-test.c b/test/functional/fixtures/printargs-test.c index be54605817..2c25cf8447 100644 --- a/test/functional/fixtures/printargs-test.c +++ b/test/functional/fixtures/printargs-test.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include int main(int argc, char **argv) diff --git a/test/functional/fixtures/printenv-test.c b/test/functional/fixtures/printenv-test.c index 295b4f04c3..f826a28db4 100644 --- a/test/functional/fixtures/printenv-test.c +++ b/test/functional/fixtures/printenv-test.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #ifdef MSWIN diff --git a/test/functional/fixtures/shell-test.c b/test/functional/fixtures/shell-test.c index 4196716799..ef9f23e3f9 100644 --- a/test/functional/fixtures/shell-test.c +++ b/test/functional/fixtures/shell-test.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include diff --git a/test/functional/fixtures/streams-test.c b/test/functional/fixtures/streams-test.c index be40edfe7e..5a59abb33b 100644 --- a/test/functional/fixtures/streams-test.c +++ b/test/functional/fixtures/streams-test.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /// Helper program to exit and keep stdout open (like "xclip -i -loops 1"). #include diff --git a/test/functional/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c index 6ee7715021..f94af2fd12 100644 --- a/test/functional/fixtures/tty-test.c +++ b/test/functional/fixtures/tty-test.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include @@ -11,8 +8,6 @@ # include #endif -// -V:STRUCT_CAST:641 -#define STRUCT_CAST(Type, obj) ((Type *)(obj)) #define is_terminal(stream) (uv_guess_handle(fileno(stream)) == UV_TTY) #define BUF_SIZE 0xfff #define CTRL_C 0x03 @@ -108,10 +103,10 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf) .len = (size_t)cnt #endif }; - uv_write(&req, STRUCT_CAST(uv_stream_t, &out), &b, 1, NULL); + uv_write(&req, (uv_stream_t *)&out, &b, 1, NULL); uv_run(&write_loop, UV_RUN_DEFAULT); - uv_close(STRUCT_CAST(uv_handle_t, &out), NULL); + uv_close((uv_handle_t *)&out, NULL); uv_run(&write_loop, UV_RUN_DEFAULT); if (uv_loop_close(&write_loop)) { abort(); @@ -181,7 +176,7 @@ int main(int argc, char **argv) #endif uv_tty_set_mode(&tty, UV_TTY_MODE_RAW); tty.data = &interrupted; - uv_read_start(STRUCT_CAST(uv_stream_t, &tty), alloc_cb, read_cb); + uv_read_start((uv_stream_t *)&tty, alloc_cb, read_cb); #ifndef MSWIN struct sigaction sa; sigemptyset(&sa.sa_mask); diff --git a/test/old/memfile_test.c b/test/old/memfile_test.c index 41316bcc2d..a352619469 100644 --- a/test/old/memfile_test.c +++ b/test/old/memfile_test.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - /* vi:set ts=8 sts=4 sw=4 noet: * * VIM - Vi IMproved by Bram Moolenaar diff --git a/test/unit/fixtures/multiqueue.c b/test/unit/fixtures/multiqueue.c index 4f4f5989d9..3a5ddab4b8 100644 --- a/test/unit/fixtures/multiqueue.c +++ b/test/unit/fixtures/multiqueue.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include #include #include "nvim/event/multiqueue.h" diff --git a/test/unit/fixtures/rbuffer.c b/test/unit/fixtures/rbuffer.c index efa7ab1986..d587d6b054 100644 --- a/test/unit/fixtures/rbuffer.c +++ b/test/unit/fixtures/rbuffer.c @@ -1,6 +1,3 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - #include "nvim/rbuffer.h" #include "rbuffer.h" @@ -15,7 +12,7 @@ void ut_rbuffer_each_read_chunk(RBuffer *buf, each_ptr_cb cb) void ut_rbuffer_each_write_chunk(RBuffer *buf, each_ptr_cb cb) { - RBUFFER_UNTIL_FULL(buf, wptr, wcnt) { // -V1044 + RBUFFER_UNTIL_FULL(buf, wptr, wcnt) { cb(wptr, wcnt); rbuffer_produced(buf, wcnt); }