Commit Graph

10894 Commits

Author SHA1 Message Date
ZyX
fc1ebb060e ops: Fix PVS/V614: use of uninitialized variable
I have actually no idea how code managed to work and not trigger ASAN/etc here. 
It does not look like a false positive at all.
2018-04-15 21:49:47 +03:00
ZyX
dae1975394 ops: Fix PVS/V547: allocator never returns NULL 2018-04-15 21:46:32 +03:00
ZyX
2b7a8ceeb6 ops: Fix PVS/V547: did_change is almost always set
Only exception is early `goto theend`.
2018-04-15 21:44:36 +03:00
ZyX
4a145f2036 ops: Silence PVS/V614: regtype is always initialized 2018-04-15 21:40:30 +03:00
ZyX
3b32e717d9 message: Fix PVS/V547: c is never equal to KS_ZERO
Since `c` there is a result of evaluating `TO_SPECIAL` macros it may be only one 
of the following three things:

1. K_SPECIAL
2. K_ZERO (note: not KS_ZERO)
3. negative integer resulting from evaluating TERMCAP2KEY macro.

All variants here are negative and thus fail next !IS_SPECIAL(c) check (negative 
is special). If `c` was really NUL it would fall into the `!IS_SPECIAL(c)` block 
and use whatever character is third in `<80>{a}{b}` combo. For `<Nul>` it is 
X (`<80><ff>X`).
2018-04-15 21:32:26 +03:00
ZyX
cb3230776e memline: Fix PVS/V547: allocator now never returns NULL 2018-04-15 20:56:42 +03:00
ZyX
2940af8321 memline: Fix PVS/V560: allocator now never returns NULL 2018-04-15 20:55:26 +03:00
ZyX
a2f9188418 mbyte: Fix PVS/V557: do not do useless job
I do not see how array overrun is actually possible, but still EUC encodings may 
do fine without a cycle.
2018-04-15 20:53:29 +03:00
ZyX
24ee261317 if_cscope: Fix PVS/V560: condition would result in earlier return
Previous block just checks for totmatches being zero and returns if it is. And 
totmatches is unsigned, so `totmatches > 0` may never be true.
2018-04-15 20:36:21 +03:00
ZyX
b8f69b6b9a os/fs: Fix PVS/V560: condition was already checked in while()
It is not possible to enter while loop body with unsigned2 == 0 if loop 
condition requires unsigned1 < unsigned2.
2018-04-15 20:34:27 +03:00
ZyX
3189841984 fileio: Silence PVS/V614: buffer is initialized if conv_restlen > 0 2018-04-15 20:32:21 +03:00
ZyX
cd27198526 fileio: Fix PVS/V547: split is not used
This is removed functionality, specifically no longer supported 16-bit integers.
2018-04-15 20:30:31 +03:00
ZyX
1fb4282f1c fileio: Fix PVS/V560: end was already checked
See condition at line 3309.
2018-04-15 20:27:41 +03:00
ZyX
11f6411771 file_search: Silence PVS/V614: used buffer is never uninitialized 2018-04-15 20:18:20 +03:00
ZyX
d084628c4b kvec: Silence PVS/V512: it is not needed to fill the whole array 2018-04-15 20:14:55 +03:00
ZyX
a20261fae7 viml/parser/expressions: Fix PVS/V547: condition checked earlier
See previous goto with the same label.
2018-04-15 20:11:21 +03:00
ZyX
bc235bf1f6 viml/parser/expressions: Fix PVS/V547: condition checked earlier
See previous goto with the same label.
2018-04-15 20:10:48 +03:00
ZyX
6196738a3b ex_cmds: Fix PVS/V547: expression was already checked in outer if() 2018-04-15 20:08:32 +03:00
ZyX
17e21eae24 eval: Silence PVS/V547: PVS cannot stand !known_val expressions 2018-04-15 20:07:07 +03:00
ZyX
092b4d9774 *: Add some PVS comments 2018-04-15 20:07:07 +03:00
ZyX
469ba2fb49 ex_getln: Fix PVS/V547: function is stated to never return NULL 2018-04-15 20:07:07 +03:00
ZyX
c90e9df5b5 ex_getln: Fix PVS/V560: there are no longer NULL returns for OOM 2018-04-15 20:07:07 +03:00
ZyX
cad616c94e ex_docmd: Fix PVS/V547: condition was already checked in surr. if() 2018-04-15 20:07:07 +03:00
ZyX
d7e4449adb ex_docmd: Fix PVS/V547: due to short-circuiting name_len is never > 4 2018-04-15 20:07:07 +03:00
ZyX
103be37f42 ex_cmds: Fix PVS/V557: possible array overrun in :ascii
Some calculation show that with the current setup there will not be enough bytes
occupied for that, barring the case of malicious translation. Still should be
possible to have array overrun with specially crafted translation.
2018-04-15 20:07:07 +03:00
Justin M. Keyes
b2c066409d job-control: children_kill_cb(): do not check elapsed time
1. Don't check elapsed time in children_kill_cb(), it's already implied
   by the start-time of the timer itself.
2. Restart timer from children_kill_cb() for PTY jobs, to send SIGKILL
   after SIGTERM. There is an edge case where SIGKILL might follow
   SIGTERM too quickly, if jobstop() is called near the 2-second timer
   window.  But this edge case is not worth code complication.
2018-04-15 18:23:11 +02:00
Justin M. Keyes
142ac021ac job-control: one-shot timer instead of repeating
Before f31c26f1af the timer was used to try SIGTERM *and* SIGKILL, so
a repeating timer was needed.  After f31c26f1af process_stop() sends
SIGTERM immediately, and the timer only sends SIGKILL.

So we don't need a repeating timer.
- Simplifies the logic: don't need to call uv_timer_stop() explicitly.
- Avoids a problem: if process_stop() is called more than once in the
  2-second window, the first on_process_exit() would call
  uv_timer_stop() which stops the timer for all stopped processes.
2018-04-15 18:23:11 +02:00
Justin M. Keyes
8fa0b8051d job-control: mitigate process-kill race
children_kill_cb() is racey. One obvious problem is that
process_close_handles() is *queued* by on_process_exit(), so when
children_kill_cb() is invoked, the dead process might still be in the
`loop->children` list.  If the OS already reclaimed the dead PID, Nvim
may try to SIGKILL it.

Avoid that by checking `proc->status`.

Vim doesn't have this problem because it doesn't attempt to kill
processes that ignored SIGTERM after a timeout.

closes #8269
2018-04-15 18:23:11 +02:00
Justin M. Keyes
c8f409c2f2 loop: remove children_stop_requests
It serves no purpose because process_stop() is already guarded by
`proc->stopped_time`.
2018-04-15 18:23:11 +02:00
Justin M. Keyes
7598e6cf17
Merge #8120 'test: win: prefer cmd.exe' 2018-04-15 18:16:37 +02:00
ZyX
aa5008c1f0 ex_cmds: Simplify do_ascii
Specifically apply constants like enc_utf8 (which are constants *now*) and 
simplify conditions after that. Also some style changes.
2018-04-15 19:01:58 +03:00
ZyX
db7f80302b ex_cmds: Remove #ifdef USE_GUI
`ag` shows that this identifier (`USE_GUI`) is found in exactly one place (zero 
after this commit). So I assume macros is never defined.
2018-04-15 18:52:37 +03:00
ZyX
1df9ac1c03 eval: Fix PVS/V547: skipping is now done using eval0 2018-04-15 18:50:02 +03:00
ZyX
f8d574225b eval: Silence PVS/V547: E882 may be triggered
I failed to deduce why analyzer thinks E882 may not be triggered, though 
conditions for triggering it are strange: it would trigger E882 only in the 
single case “function returned non-number”. Cases “function thrown exception”, 
or “built-in sorter encountered error” will neither yield E882 nor stop 
sort()/uniq().

Note though that searching test code revealed that neither E702 nor E882 are not 
tested anywhere.
2018-04-15 18:45:12 +03:00
geekodour
1e71978cf0 events: VimSuspend, VimResume #8280
closes #3648
ref #5959
2018-04-15 15:05:02 +02:00
Justin M. Keyes
1e7d5e8cdf
Merge #6272 'stdpath()' 2018-04-15 04:09:30 +02:00
Jan Edmund Lazo
5abfa94ed2 test: win: use "start" to test backgrounded job (#8171) 2018-04-15 02:43:18 +02:00
Justin M. Keyes
a7e7f7bd83
Merge #8160 'win: oldtests: prefer cmd.exe' 2018-04-15 02:37:22 +02:00
b-r-o-c-k
ee4e1fd8ec win: Fix reading content from stdin (#8267)
Fixes #6890 by reading from the Windows console input buffer after
stdin has been closed.

Vim defines HAVE_DUP for Windows and does the close-dup dance[1]:

    close(0);
    dup(2);

which always fails, then falls back to reading from the Windows console
input buffer[2].

[1] e7499ddc33/src/fileio.c (L2397-L2398)
[2] e7499ddc33/src/os_win32.c (L1703-L1714)
2018-04-14 21:59:07 +02:00
b-r-o-c-k
387fbcd95c win: Fix reading from stdin
* Reading from stdin on Windows is fixed in the same way as it was in
  #8267.
* The file_read function was returning without filling the
  destination buffer when it was called with a non-blocking file
  descriptor.
2018-04-14 14:21:36 -05:00
b-r-o-c-k
ad999eaa77 Merge branch 'master' into s-dash-stdin 2018-04-14 14:17:51 -05:00
Justin M. Keyes
ef4feab0e7
version: rename "0.2.3" to "0.3.0" (#8268)
0.2.1 was a big release, it should have been renamed to 0.3.0.
0.2.3 also has significant changes, so rename it.
2018-04-13 22:15:52 +02:00
Jan Edmund Lazo
51b9d85bb4 ci/win: redirect stderr to fix mingw build 2018-04-13 13:42:12 -04:00
Jan Edmund Lazo
ad30907814 Revert "ci/win: don't use lastexitcode hack on mingw build"
This reverts commit bc43d2559f.

stderr redirection should make the workaround work for mingw builds.
2018-04-13 13:38:31 -04:00
Jan Edmund Lazo
8e87d89a99 oldtests: win: skip test49
Vim doesn't test it on Windows.
See https://github.com/vim/vim/blob/master/src/testdir/Make_all.mak
2018-04-12 21:11:55 -04:00
John Szakmeister
27e26b10a2 tui: abort on unexpected enum value (#8266)
ref #8261
2018-04-13 01:03:00 +02:00
Justin M. Keyes
1c3a849881
API/nvim_command_output: handle :echon capture (#8265)
ref https://github.com/neovim/python-client/pull/290
2018-04-13 00:49:37 +02:00
Justin M. Keyes
5e18550ddd
Merge #7813 'channels: delay free'
fix #7699
2018-04-13 00:35:50 +02:00
Björn Linse
0865adbbc2 channels: cleanup channel freeing code 2018-04-12 22:33:05 +02:00
Björn Linse
aea079a25d channels: delay free so that libuv can cleanup handles
add test for a crash this caused
2018-04-12 18:22:47 +02:00